3 #include "drag_selection.hpp"
6 #include "triangle_renderer.hpp"
7 #include "selectables_renderer.hpp"
8 #include "util/msd_animator.hpp"
10 #include <glm/glm.hpp>
11 #include "appearance.hpp"
12 #include "annotation.hpp"
13 #include "snap_filter.hpp"
14 #include "picture_renderer.hpp"
15 #include "selection_filter.hpp"
31 enum class SelectionMode { HOVER, NORMAL };
32 void set_selection_mode(SelectionMode mode);
33 SelectionMode get_selection_mode()
const;
34 typedef sigc::signal<void, SelectionMode> type_signal_selection_mode_changed;
35 type_signal_selection_mode_changed signal_selection_mode_changed()
37 return s_signal_selection_mode_changed;
40 enum class SelectionTool { BOX, LASSO, PAINT };
41 SelectionTool selection_tool = SelectionTool::BOX;
43 enum class SelectionQualifier { INCLUDE_ORIGIN, INCLUDE_BOX, TOUCH_BOX, AUTO };
44 SelectionQualifier selection_qualifier = SelectionQualifier::INCLUDE_ORIGIN;
46 enum class HighlightMode { HIGHLIGHT, DIM, SHADOW };
47 void set_highlight_mode(HighlightMode mode);
48 HighlightMode get_highlight_mode()
const;
49 void set_highlight_enabled(
bool x);
50 void set_highlight_on_top(
bool on_top);
52 enum class LayerMode { AS_IS, WORK_ONLY, SHADOW_OTHER };
53 void set_layer_mode(LayerMode mode);
55 std::set<SelectableRef> get_selection();
56 void set_selection(
const std::set<SelectableRef> &sel,
bool emit =
true);
58 void set_cursor_pos(
const Coordi &c);
59 void set_cursor_external(
bool v);
61 Coordf get_cursor_pos_win();
62 Target get_current_target();
63 void set_selection_allowed(
bool a);
64 std::pair<float, Coordf> get_scale_and_offset();
65 void set_scale_and_offset(
float sc,
Coordf ofs);
66 Coordi snap_to_grid(
const Coordi &c,
unsigned int div = 1)
const;
68 void set_flip_view(
bool fl);
69 bool get_flip_view()
const override;
71 void set_cursor_size(
float size);
72 void set_cursor_size(Appearance::CursorSize);
74 void clear()
override;
76 typedef sigc::signal<void> type_signal_selection_changed;
77 type_signal_selection_changed signal_selection_changed()
79 return s_signal_selection_changed;
82 type_signal_selection_changed signal_hover_selection_changed()
84 return s_signal_hover_selection_changed;
87 typedef sigc::signal<void, const Coordi &> type_signal_cursor_moved;
88 type_signal_cursor_moved signal_cursor_moved()
90 return s_signal_cursor_moved;
93 typedef sigc::signal<void, unsigned int> type_signal_grid_mul_changed;
94 type_signal_grid_mul_changed signal_grid_mul_changed()
96 return s_signal_grid_mul_changed;
98 unsigned int get_grid_mul()
const
103 typedef sigc::signal<std::string, ObjectType, UUID> type_signal_request_display_name;
104 type_signal_request_display_name signal_request_display_name()
106 return s_signal_request_display_name;
109 typedef sigc::signal<void, bool &> type_signal_can_steal_focus;
110 type_signal_can_steal_focus signal_can_steal_focus()
112 return s_signal_can_steal_focus;
115 typedef sigc::signal<void> type_signal_scale_changed;
116 type_signal_scale_changed signal_scale_changed()
118 return s_signal_scale_changed;
121 void center_and_zoom(
const Coordi ¢er,
float scale = -1);
123 void zoom_to_bbox(
const std::pair<Coordf, Coordf> &bb);
124 void ensure_min_size(
float w,
float h);
126 Glib::PropertyProxy<int> property_work_layer()
128 return p_property_work_layer.get_proxy();
130 Glib::PropertyProxy<float> property_layer_opacity()
132 return p_property_layer_opacity.get_proxy();
134 Glib::PropertyProxy_ReadOnly<float> property_layer_opacity()
const
136 return Glib::PropertyProxy_ReadOnly<float>(
this,
"layer-opacity");
139 void update_markers()
override;
141 std::set<SelectableRef> get_selection_at(
const Coordi &c);
143 void update_cursor_pos(
double x,
double y);
147 const Color &get_color(ColorP colorp)
const;
149 bool touchpad_pan =
false;
151 bool smooth_zoom =
true;
152 bool snap_to_targets =
true;
154 void inhibit_drag_selection();
156 int _animate_step(GdkFrameClock *frame_clock);
158 float get_width()
const
162 float get_height()
const
169 bool layer_is_annotation(
int l)
const;
171 std::set<SnapFilter> snap_filter;
175 Coordi get_grid_spacing()
const;
176 void set_grid_origin(
const Coordi &c);
180 bool layer_is_visible(
int layer)
const;
182 void set_colors2(
const std::vector<ColorI> &c);
185 void push()
override;
186 void request_push()
override;
189 static const int MAT3_XX = 0;
190 static const int MAT3_X0 = 2;
191 static const int MAT3_YY = 4;
192 static const int MAT3_Y0 = 5;
194 float m_width, m_height;
199 glm::mat3 viewmat_noflip;
200 bool flip_view =
false;
201 void update_viewmat();
205 bool cursor_external =
false;
208 GLuint stencilrenderbuffer;
210 bool needs_resize =
false;
213 PF_TRIANGLES = (1 << 0),
214 PF_CURSOR = (1 << 1),
215 PF_SELECTABLES = (1 << 2),
216 PF_MARKER = (1 << 3),
217 PF_DRAG_SELECTION = (1 << 4),
220 PushFilter push_filter = PF_ALL;
221 void request_push(PushFilter filter);
223 void resize_buffers();
234 void pan_drag_begin(GdkEventButton *button_event);
235 void pan_drag_end(GdkEventButton *button_event);
236 void pan_drag_move(GdkEventMotion *motion_event);
237 void pan_drag_move(GdkEventScroll *scroll_event);
238 void pan_zoom(GdkEventScroll *scroll_event,
bool to_cursor =
true);
239 void cursor_move(GdkEvent *motion_event);
240 void hover_prelight_update(GdkEvent *motion_event);
241 bool pan_dragging =
false;
245 void set_scale(
float x,
float y,
float new_scale);
247 bool selection_allowed =
true;
248 Glib::Property<int> p_property_work_layer;
249 Glib::Property<float> p_property_layer_opacity;
251 Gtk::Menu *clarify_menu;
253 HighlightMode highlight_mode = HighlightMode::HIGHLIGHT;
254 bool highlight_enabled =
false;
255 bool highlight_on_top =
false;
258 LayerMode layer_mode = LayerMode::AS_IS;
260 bool drag_selection_inhibited =
false;
263 float zoom_animation_scale_orig = 1;
264 Coordf zoom_animation_pos;
266 Gdk::ModifierType grid_fine_modifier = Gdk::MOD1_MASK;
267 float cursor_size = 20;
269 static const int first_annotation_layer = 20000;
270 int annotation_layer_current = first_annotation_layer;
271 std::map<int, CanvasAnnotation> annotations;
273 void draw_bitmap_text(
const Coordf &p,
float scale,
const std::string &rtext,
int angle, ColorP color,
275 std::pair<Coordf, Coordf> measure_bitmap_text(
const std::string &text)
const override;
276 void draw_bitmap_text_box(
const Placement &q,
float width,
float height,
const std::string &s, ColorP color,
277 int layer, TextBoxMode mode)
override;
279 SelectionMode selection_mode = SelectionMode::HOVER;
281 Glib::RefPtr<Gtk::GestureZoom> gesture_zoom;
282 void zoom_gesture_begin_cb(GdkEventSequence *seq);
283 void zoom_gesture_update_cb(GdkEventSequence *seq);
286 float gesture_zoom_scale_orig = 1;
288 Glib::RefPtr<Gtk::GestureDrag> gesture_drag;
291 void drag_gesture_begin_cb(GdkEventSequence *seq);
292 void drag_gesture_update_cb(GdkEventSequence *seq);
294 bool can_snap_to_target(
const Target &t)
const;
296 std::vector<ColorI> colors2;
299 void on_size_allocate(Gtk::Allocation &alloc)
override;
300 void on_realize()
override;
301 bool on_render(
const Glib::RefPtr<Gdk::GLContext> &context)
override;
302 bool on_button_press_event(GdkEventButton *button_event)
override;
303 bool on_button_release_event(GdkEventButton *button_event)
override;
304 bool on_motion_notify_event(GdkEventMotion *motion_event)
override;
305 bool on_scroll_event(GdkEventScroll *scroll_event)
override;
306 Glib::RefPtr<Gdk::GLContext> on_create_context()
override;
308 type_signal_selection_changed s_signal_selection_changed;
309 type_signal_selection_changed s_signal_hover_selection_changed;
310 type_signal_selection_mode_changed s_signal_selection_mode_changed;
311 type_signal_cursor_moved s_signal_cursor_moved;
312 type_signal_grid_mul_changed s_signal_grid_mul_changed;
313 type_signal_request_display_name s_signal_request_display_name;
314 type_signal_can_steal_focus s_signal_can_steal_focus;
315 type_signal_scale_changed s_signal_scale_changed;