Blob Blame Raw
#ifndef ACTIVEAREA_H
#define ACTIVEAREA_H


#include <list>

#include <gtkmm/drawingarea.h>

#include "activepoint.h"
#include "context.h"


class ActiveArea: public Gtk::DrawingArea {
public:
	typedef std::list<ActivePoint::Handle> PointList;

private:
	PointList points;
	ActivePoint::Handle hover_point;
	ActivePoint::Handle drag_point;
	Vector drag_offset;

public:
	ActiveArea();

	const PointList& get_points() const { return points; }
	bool is_point_added(const ActivePoint::Handle &point) const;
	void add_point(const ActivePoint::Handle &point);
	void remove_point(const ActivePoint::Handle &point);
	void bring_to_front(const ActivePoint::Handle &point);

	ActivePoint::Handle get_point_at(const Vector &position) const;

protected:
	virtual void on_point_move(const ActivePoint::Handle &point, const Vector &oldposition, const Vector &newposition);
	virtual void on_draw(const Context &context);
	virtual void on_draw_content(const Context &context);

	bool on_draw(const Cairo::RefPtr<Cairo::Context> &context) override;
	bool on_button_press_event(GdkEventButton* event) override;
	bool on_button_release_event(GdkEventButton* event) override;
	bool on_motion_notify_event(GdkEventMotion* event) override;
};


#endif