Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
fb2992f7
"vscode:/vscode.git/clone" did not exist on "4025fc5e8b4e7161005406d81e0d3b9b8a8d2657"
Commit
fb2992f7
authored
Dec 11, 2012
by
Davis King
Browse files
Added on_view_changed() callback to zoomable_region and scrollable_region gui
widgets.
parent
d2e933e3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
0 deletions
+46
-0
dlib/gui_widgets/base_widgets.cpp
dlib/gui_widgets/base_widgets.cpp
+18
-0
dlib/gui_widgets/base_widgets.h
dlib/gui_widgets/base_widgets.h
+4
-0
dlib/gui_widgets/base_widgets_abstract.h
dlib/gui_widgets/base_widgets_abstract.h
+24
-0
No files found.
dlib/gui_widgets/base_widgets.cpp
View file @
fb2992f7
...
...
@@ -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
();
}
// ----------------------------------------------------------------------------------------
...
...
dlib/gui_widgets/base_widgets.h
View file @
fb2992f7
...
...
@@ -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
;
...
...
dlib/gui_widgets/base_widgets_abstract.h
View file @
fb2992f7
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment