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