Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
fb2992f7
Commit
fb2992f7
authored
Dec 12, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added on_view_changed() callback to zoomable_region and scrollable_region gui
widgets.
parent
d2e933e3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
0 deletions
+46
-0
base_widgets.cpp
dlib/gui_widgets/base_widgets.cpp
+18
-0
base_widgets.h
dlib/gui_widgets/base_widgets.h
+4
-0
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