22 #ifndef GtkCRNImage_HEADER
23 #define GtkCRNImage_HEADER
25 #include <libgtkcrnmm_config.h>
44 #ifdef CRN_USING_GTKMM3
57 #ifndef CRN_USING_GTKMM3
85 #ifdef CRN_USING_GTKMM3
91 #ifdef CRN_USING_GTKMM3
101 Glib::RefPtr<Gio::SimpleActionGroup>
get_actions() {
return image_actions; }
112 Glib::RefPtr<Gtk::ActionGroup>
get_actions() {
return image_actions; }
116 enum class MouseMode {
NONE,
SCROLL,
DRAW,
MOVE,
STRETCH_LEFT,
STRETCH_BOTTOM_LEFT,
STRETCH_BOTTOM,
STRETCH_BOTTOM_RIGHT,
STRETCH_RIGHT,
STRETCH_TOP_RIGHT,
STRETCH_TOP,
STRETCH_TOP_LEFT,
MOVEPOINT,
USER };
120 sigc::signal<void, guint, guint32, std::vector<std::pair<crn::String, crn::String> >, int,
int >
signal_rmb_clicked() {
return rmb_clicked; }
124 sigc::signal<void, Glib::RefPtr<Gdk::Pixbuf> >
signal_drawing() {
return drawing; }
131 #ifdef CRN_USING_GTKMM3
132 Glib::RefPtr<Gtk::Adjustment>
get_hadjustment() {
return hscrollbar.get_adjustment(); }
137 #ifdef CRN_USING_GTKMM3
138 Glib::RefPtr<Gtk::Adjustment>
get_vadjustment() {
return vscrollbar.get_adjustment(); }
207 #ifdef CRN_USING_GTKMM3
289 #ifdef CRN_USING_GTKMM3
290 bool expose(
const Cairo::RefPtr<Cairo::Context> &cc);
292 bool expose(GdkEventExpose *ev);
295 bool configure(GdkEventConfigure *ev);
297 bool mouse_motion(GdkEventMotion *ev);
299 bool button_clicked(GdkEventButton *ev);
301 bool mouse_wheel(GdkEventScroll *ev);
308 sigc::connection refresher;
312 Glib::RefPtr<Gdk::Pixbuf> image;
317 Glib::RefPtr<Gdk::Pixbuf> buffer;
318 static int selection_margin;
319 #ifdef CRN_USING_GTKMM3
320 Glib::RefPtr<Gio::SimpleActionGroup> image_actions;
322 Glib::RefPtr<Gtk::ActionGroup> image_actions;
328 struct Overlay_internal
330 OverlayConfig config;
331 std::map<crn::String, std::unique_ptr<OverlayItem> > items;
334 std::map<crn::String, Overlay_internal> overlays;
344 #ifndef CRN_USING_GTKMM3
349 #ifndef CRN_USING_GTKMM3
350 Glib::RefPtr<Gdk::GC> da_gc;
352 #ifdef CRN_USING_GTKMM3
353 Gtk::Scrollbar hscrollbar;
354 Gtk::Scrollbar vscrollbar;
356 Gtk::HScrollbar hscrollbar;
357 Gtk::VScrollbar vscrollbar;
359 #ifdef CRN_USING_GTKMM3
360 Gdk::CursorType scroll_cursor;
361 Gdk::CursorType select_cursor;
362 Gdk::CursorType move_cursor;
363 Gdk::CursorType move_1_cursor;
364 Gdk::CursorType drag_left_cursor;
365 Gdk::CursorType drag_bottom_left_cursor;
366 Gdk::CursorType drag_bottom_cursor;
367 Gdk::CursorType drag_bottom_right_cursor;
368 Gdk::CursorType drag_right_cursor;
369 Gdk::CursorType drag_top_right_cursor;
370 Gdk::CursorType drag_top_cursor;
371 Gdk::CursorType drag_top_left_cursor;
372 Gdk::CursorType user_cursor;
374 Gdk::Cursor scroll_cursor;
375 Gdk::Cursor select_cursor;
376 Gdk::Cursor move_cursor;
377 Gdk::Cursor move_1_cursor;
378 Gdk::Cursor drag_left_cursor;
379 Gdk::Cursor drag_bottom_left_cursor;
380 Gdk::Cursor drag_bottom_cursor;
381 Gdk::Cursor drag_bottom_right_cursor;
382 Gdk::Cursor drag_right_cursor;
383 Gdk::Cursor drag_top_right_cursor;
384 Gdk::Cursor drag_top_cursor;
385 Gdk::Cursor drag_top_left_cursor;
386 Gdk::Cursor user_cursor;
388 sigc::signal<void, crn::String, crn::String, MouseMode> overlay_changed;
389 sigc::signal<void, guint, guint32, std::vector<std::pair<crn::String, crn::String> >, int,
int > rmb_clicked;
390 sigc::signal<void, int, int> user_mouse;
391 sigc::signal<void, Glib::RefPtr<Gdk::Pixbuf> > drawing;
392 sigc::signal<void> zoom_changed;
393 sigc::signal<void, int, int> scrolled_event;
void clear_overlays()
Clears all overlays.
OverlayConfig()
Default constructor.
void set_overlay_visible(const crn::String &id, bool visible)
Shows or hides an overlay.
Polygon(std::vector< crn::Point2DInt > &&po, const crn::StringUTF8 &lab="")
Rectangle & operator=(const Rectangle &)=delete
Glib::ustring font_family
void set_user_cursor(const Gdk::Cursor &cur)
Sets the cursor in user mouse mode.
Polygon & operator=(const Polygon &)=delete
OverlayConfig & get_overlay_config(const crn::String &id)
Gets the configuration of an overlay.
sigc::signal< void, Glib::RefPtr< Gdk::Pixbuf > > signal_drawing()
Returns a signal that indicates that the image will be redrawn. Binds to void on_redraw(Glib::RefPtr<...
sigc::signal< void, guint, guint32, std::vector< std::pair< crn::String, crn::String > >, int, int > signal_rmb_clicked()
Returns a signal that can be used to generate pop-up menus. Binds to void on_rmb_clicked(guint mouse_...
OverlayItem & operator=(const OverlayItem &)=delete
void zoom_in()
Increments the zoom level by 10%.
sigc::signal< void > signal_zoom_changed()
Returns a signal that indicates that the zoom was changed. Binds to void on_zoom_changed().
const crn::Rect & get_selection_as_rect() const
Gets the mouse selection as a rectangle.
Glib::RefPtr< Gtk::ActionGroup > get_actions()
Creates a tool button connected to the zoom_fit method.
sigc::signal< void, int, int > signal_scrolled_event()
Returns a signal emitted when the image is scrolled. Binds to void on_scroll(int x, int y).
Text(const crn::Point2DInt &p, const crn::StringUTF8 &lab="")
std::vector< crn::Point2DInt > points
Line(const crn::Point2DInt &p1_, const crn::Point2DInt &p2_, const crn::StringUTF8 &lab="")
void zoom_out()
Decrements the zoom level by 10%.
A UTF32 character string class.
Overlay get_selection_type() const
Gets the mouse selection type.
const crn::Point2DInt & get_selection_as_point() const
Gets the mouse selection as a point.
void zoom_100()
Sets the zoom level to 100%.
void set_selection_type(Overlay typ)
Sets the mouse selection type.
void hide_overlay(const crn::String &id)
Hides an overlay.
const crn::Point2DInt & get_offset()
Returns to offset of the image (at scale 1:1)
OverlayItem(const crn::StringUTF8 &lab="")
void clear_overlay(const crn::String &id)
Clears an overlay.
std::pair< crn::Point2DInt, crn::Point2DInt > get_selection_as_line() const
Gets the mouse selection as a line.
Text & operator=(const Text &)=delete
OverlayConfig & get_selection_config()
Gets the mouse selection configuration.
bool has_selection() const
Is there a mouse selection?
double get_zoom() const
Gets the zoom level.
virtual ~Image() override
Destructor.
Point & operator=(const Point &)=delete
void focus_on(int x, int y)
Focus the image on a point.
void add_overlay_item(const crn::String &overlay_id, const crn::String &item_id, const crn::Rect &r, const crn::StringUTF8 &label="")
Adds a rectangle to an overlay.
void show_overlay(const crn::String &id)
Shows an hidden overlay.
Polygon(const std::vector< crn::Point2DInt > &po, const crn::StringUTF8 &lab="")
A widget that holds an image.
void set_rulers_visible(bool is_visible)
Are the rulers visible?
sigc::signal< void, int, int > signal_user_mouse()
Returns a signal that indicates a user mouse click. Binds to void on_mouse_clicked(int x...
Gtk::Adjustment & get_hadjustment()
Gets the horizontal adjustment of the scrollbars.
static const crn::String & selection_overlay()
Returns the name of the mouse selection overlay.
Gtk::Adjustment & get_vadjustment()
Gets the vertical adjustment of the scrollbars.
void set_zoom(double z)
Sets the zoom level.
void force_redraw()
Force the image to redraw.
MouseMode
State of the mouse activity.
void set_pixbuf(Glib::RefPtr< Gdk::Pixbuf > pb)
Sets the new image to display.
void clear_selection()
Clears the mouse selection.
An overlay configuration.
A character string class.
Line & operator=(const Line &)=delete
Rectangle(const crn::Rect &r, const crn::StringUTF8 &lab="")
sigc::signal< void, crn::String, crn::String, MouseMode > signal_overlay_changed()
Returns the signal associated to changes in selections. Binds to void on_overlay_changed(crn::String ...
void zoom_fit()
Sets the zoom level to fit the image's size.
OverlayItem & get_overlay_item(const crn::String &overlay_id, const crn::String &item_id)
Gets an overlay item.
void remove_overlay_item(const crn::String &overlay_id, const crn::String &item_id)
Removes an overlay item.
Point(const crn::Point2DInt &p, const crn::StringUTF8 &lab="")
Overlay
Overlay types and mouse selection modes.
void set_selection(const crn::Rect &r)
Sets the mouse selection.