Blame c++/freetype/src/view.h

b8976b
#ifndef VIEW_H
b8976b
#define VIEW_H
b8976b
b8976b
b8976b
#include <vector></vector>
b8976b
b8976b
#include <gtkmm drawingarea.h=""></gtkmm>
b8976b
b8976b
#include "common.h"
b8976b
#include "surface.h"
b8976b
#include "matrix.h"
b8976b
b8976b
b8976b
class View: public Gtk::DrawingArea {
b8976b
public:
b8976b
	class Point: public Shared {
b8976b
	public:
b8976b
		Vector2 position;
b8976b
		Color color;
b8976b
		Real radius;
b8976b
		bool selected;
b8976b
		
b8976b
		inline explicit Point(
b8976b
			const Vector2 &position = Vector2(),
b8976b
			const Color &color = Color(1, 1, 0, 1),
b8976b
			Real radius = 5.0,
b8976b
			bool selected = false
b8976b
		):
b8976b
			position(position),
b8976b
			color(color),
b8976b
			radius(radius),
b8976b
			selected(selected)
b8976b
		{ }
b8976b
		
b8976b
		virtual void draw(
b8976b
			const Cairo::RefPtr<cairo::context>& context,</cairo::context>
b8976b
			View &view );
b8976b
	};
b8976b
b8976b
	typedef RefPtr<point> PointPtr;</point>
b8976b
	typedef std::vector<pointptr> PointList;</pointptr>
b8976b
b8976b
public:
b8976b
	Matrix transform;
b8976b
	PointList points;
b8976b
b8976b
private:
b8976b
	bool dragging;
b8976b
	PointPtr selected_point;
b8976b
	Vector2 selected_point_offset;
b8976b
	Vector2 mouse_position; // relative to center of widget
b8976b
b8976b
public:
b8976b
	View();
b8976b
	virtual ~View();
b8976b
b8976b
	sigc::signal<void, cairo::refptr<cairo::context="" const="">&> signal_draw_view;</void,>
b8976b
	sigc::signal<void, const="" pointptr&=""> signal_point_motion;</void,>
b8976b
	sigc::signal<void, const="" pointptr&=""> signal_point_changed;</void,>
b8976b
	sigc::signal<void> signal_transform_changed;</void>
b8976b
	
b8976b
	void point_motion(const PointPtr &point)
b8976b
		{ signal_point_motion(point); }
b8976b
	void point_changed(const PointPtr &point)
b8976b
		{ point_motion(point); signal_point_changed(point); }
b8976b
b8976b
	Real get_pixel_size() const;
b8976b
	Pair2 get_bounds() const;
b8976b
	
b8976b
	Matrix transform_to_pixels() const;
b8976b
	Matrix transform_from_pixels() const;
b8976b
	
b8976b
protected:
b8976b
	bool on_draw(const Cairo::RefPtr<cairo::context> &context) override;</cairo::context>
b8976b
	bool on_motion_notify_event(GdkEventMotion *event) override;
b8976b
	bool on_button_press_event(GdkEventButton *event) override;
b8976b
	bool on_button_release_event(GdkEventButton *event) override;
b8976b
b8976b
	virtual void on_draw_view(const Cairo::RefPtr<cairo::context> &context);</cairo::context>
b8976b
	virtual void on_point_motion(const PointPtr &point);
b8976b
	virtual void on_point_changed(const PointPtr &point);
b8976b
	virtual void on_transform_changed();
b8976b
};
b8976b
b8976b
b8976b
#endif