Commit fb2992f7 authored by Davis King's avatar Davis King

Added on_view_changed() callback to zoomable_region and scrollable_region gui

widgets.
parent d2e933e3
......@@ -2297,11 +2297,15 @@ namespace dlib
{
point gui_p(lastx,lasty);
point graph_p(gui_to_graph_space(gui_p));
const double old_scale = scale;
scale *= zoom_increment_;
if (scale < min_scale)
scale = min_scale;
redraw_graph();
adjust_origin(gui_p, graph_p);
if (scale != old_scale)
on_view_changed();
}
}
......@@ -2317,11 +2321,15 @@ namespace dlib
{
point gui_p(lastx,lasty);
point graph_p(gui_to_graph_space(gui_p));
const double old_scale = scale;
scale /= zoom_increment_;
if (scale > max_scale)
scale = max_scale;
redraw_graph();
adjust_origin(gui_p, graph_p);
if (scale != old_scale)
on_view_changed();
}
}
......@@ -2338,6 +2346,7 @@ namespace dlib
{
adjust_origin(point(x,y), drag_screen_point);
redraw_graph();
on_view_changed();
}
// check if the mouse isn't being dragged anymore
......@@ -2396,6 +2405,8 @@ namespace dlib
{
gr_orig.x() = hsb.slider_pos();
redraw_graph();
on_view_changed();
}
// ----------------------------------------------------------------------------------------
......@@ -2406,6 +2417,8 @@ namespace dlib
{
gr_orig.y() = vsb.slider_pos();
redraw_graph();
on_view_changed();
}
// ----------------------------------------------------------------------------------------
......@@ -2984,6 +2997,7 @@ namespace dlib
rectangle new_rect(translate_rect(display_rect(), drag_origin - current_delta));
new_rect = centered_rect(new_rect, new_rect.width()-hscroll_bar_inc, new_rect.height()-vscroll_bar_inc);
scroll_to_rect(new_rect);
on_view_changed();
}
else
{
......@@ -3112,6 +3126,8 @@ namespace dlib
{
total_rect_ = move_rect(total_rect_, display_rect_.left()-hscroll_bar_inc*hsb.slider_pos(), total_rect_.top());
parent.invalidate_rectangle(display_rect_);
if (events_are_enabled())
on_view_changed();
}
// ----------------------------------------------------------------------------------------
......@@ -3122,6 +3138,8 @@ namespace dlib
{
total_rect_ = move_rect(total_rect_, total_rect_.left(), display_rect_.top()-vscroll_bar_inc*vsb.slider_pos());
parent.invalidate_rectangle(display_rect_);
if (events_are_enabled())
on_view_changed();
}
// ----------------------------------------------------------------------------------------
......
......@@ -2254,6 +2254,8 @@ namespace dlib
protected:
virtual void on_view_changed () {}
point graph_to_gui_space (
const vector<double,2>& p
) const;
......@@ -2499,6 +2501,8 @@ namespace dlib
protected:
virtual void on_view_changed () {}
const rectangle& display_rect (
) const;
......
......@@ -1946,6 +1946,18 @@ namespace dlib
- invalidates the display_rect() so that it will be redrawn
!*/
virtual void on_view_changed (
) {}
/*!
requires
- events_are_enabled() == true
- mutex drawable::m is locked
ensures
- on_view_changed() is called whenever the user causes the view of the
zoomable_region to change. That is, this function is called when the
user scrolls or zooms around in the region.
!*/
// ---------------------------- event handlers ----------------------------
// The following event handlers are used in this object. So if you
// use any of them in your derived object you should pass the events
......@@ -2235,6 +2247,18 @@ namespace dlib
the display_rect() rectangle on the screen.
!*/
virtual void on_view_changed (
) {}
/*!
requires
- events_are_enabled() == true
- mutex drawable::m is locked
ensures
- on_view_changed() is called whenever the user causes the view of the
scrollable_region to change. That is, this function is called when the
user scrolls around in the region.
!*/
// ---------------------------- event handlers ----------------------------
// The following event handlers are used in this object. So if you
// use any of them in your derived object you should pass the events
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment