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
567aeab0
Commit
567aeab0
authored
Jan 17, 2013
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added an overload of get_next_double_click() that allows the user to find out
which mouse button was double clicked.
parent
578107c3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
17 deletions
+43
-17
widgets.cpp
dlib/gui_widgets/widgets.cpp
+8
-3
widgets.h
dlib/gui_widgets/widgets.h
+18
-12
widgets_abstract.h
dlib/gui_widgets/widgets_abstract.h
+17
-2
No files found.
dlib/gui_widgets/widgets.cpp
View file @
567aeab0
...
...
@@ -6096,7 +6096,7 @@ namespace dlib
p
=
p
*
zoom_out_scale
;
if
(
dlib
::
get_rect
(
img
).
contains
(
p
))
image_clicked_handler
(
p
,
is_double_click
);
image_clicked_handler
(
p
,
is_double_click
,
btn
);
}
if
(
btn
==
base_window
::
RIGHT
&&
rect_is_selected
)
...
...
@@ -6450,6 +6450,7 @@ namespace dlib
gui_img
(
*
this
),
window_has_closed
(
false
),
have_last_click
(
false
),
mouse_btn
(
0
),
clicked_signaler
(
this
->
wm
)
{
...
...
@@ -6485,7 +6486,8 @@ namespace dlib
bool
image_window
::
get_next_double_click
(
point
&
p
point
&
p
,
unsigned
long
&
mouse_button
)
{
auto_mutex
lock
(
wm
);
...
...
@@ -6500,6 +6502,7 @@ namespace dlib
// Mark that we are taking the point click so the next call to get_next_click()
// will have to wait for another click.
have_last_click
=
false
;
mouse_button
=
mouse_btn
;
p
=
last_clicked_point
;
return
true
;
}
...
...
@@ -6509,13 +6512,15 @@ namespace dlib
void
image_window
::
on_image_clicked
(
const
point
&
p
,
bool
is_double_click
bool
is_double_click
,
unsigned
long
btn
)
{
if
(
is_double_click
)
{
have_last_click
=
true
;
last_clicked_point
=
p
;
mouse_btn
=
btn
;
clicked_signaler
.
signal
();
}
}
...
...
dlib/gui_widgets/widgets.h
View file @
567aeab0
...
...
@@ -3435,7 +3435,7 @@ namespace dlib
>
void
set_image_clicked_handler
(
T
&
object
,
void
(
T
::*
event_handler_
)(
const
point
&
p
,
bool
is_double_click
)
void
(
T
::*
event_handler_
)(
const
point
&
p
,
bool
is_double_click
,
unsigned
long
btn
)
)
{
auto_mutex
M
(
m
);
...
...
@@ -3443,7 +3443,7 @@ namespace dlib
}
void
set_image_clicked_handler
(
const
any_function
<
void
(
const
point
&
p
,
bool
is_double_click
)
>&
event_handler_
const
any_function
<
void
(
const
point
&
p
,
bool
is_double_click
,
unsigned
long
btn
)
>&
event_handler_
)
{
auto_mutex
M
(
m
);
...
...
@@ -3532,7 +3532,7 @@ namespace dlib
std
::
string
default_rect_label
;
any_function
<
void
()
>
event_handler
;
any_function
<
void
(
const
overlay_rect
&
orect
)
>
orect_selected_event_handler
;
any_function
<
void
(
const
point
&
p
,
bool
is_double_click
)
>
image_clicked_handler
;
any_function
<
void
(
const
point
&
p
,
bool
is_double_click
,
unsigned
long
btn
)
>
image_clicked_handler
;
popup_menu_region
parts_menu
;
point
last_right_click_pos
;
const
int
part_width
;
...
...
@@ -3563,6 +3563,7 @@ namespace dlib
gui_img
(
*
this
),
window_has_closed
(
false
),
have_last_click
(
false
),
mouse_btn
(
0
),
clicked_signaler
(
this
->
wm
)
{
gui_img
.
set_image_clicked_handler
(
*
this
,
&
image_window
::
on_image_clicked
);
...
...
@@ -3578,6 +3579,7 @@ namespace dlib
gui_img
(
*
this
),
window_has_closed
(
false
),
have_last_click
(
false
),
mouse_btn
(
0
),
clicked_signaler
(
this
->
wm
)
{
gui_img
.
set_image_clicked_handler
(
*
this
,
&
image_window
::
on_image_clicked
);
...
...
@@ -3744,15 +3746,17 @@ namespace dlib
);
bool
get_next_double_click
(
point
&
p
point
&
p
,
unsigned
long
&
mouse_button
);
/*!
ensures
- This function blocks until the user double clicks on the image
or the window is closed by the user.
- if (this function returns true) then
- #p == the next place the user clicked
!*/
bool
get_next_double_click
(
point
&
p
)
{
unsigned
long
mouse_button
;
return
get_next_double_click
(
p
,
mouse_btn
);
}
private
:
...
...
@@ -3764,7 +3768,8 @@ namespace dlib
void
on_image_clicked
(
const
point
&
p
,
bool
is_double_click
bool
is_double_click
,
unsigned
long
btn
);
// restricted functions
...
...
@@ -3777,6 +3782,7 @@ namespace dlib
bool
window_has_closed
;
bool
have_last_click
;
point
last_clicked_point
;
unsigned
long
mouse_btn
;
rsignaler
clicked_signaler
;
};
...
...
dlib/gui_widgets/widgets_abstract.h
View file @
567aeab0
...
...
@@ -3024,12 +3024,27 @@ namespace dlib
);
/*!
ensures
- This function blocks until the user double
left clicks on the image or
the
window is closed by the user.
- This function blocks until the user double
clicks on the image or the
window is closed by the user.
- if (this function returns true) then
- #p == the next image pixel the user clicked.
!*/
bool
get_next_double_click
(
point
&
p
,
unsigned
long
&
mouse_button
);
/*!
ensures
- This function blocks until the user double clicks on the image or the
window is closed by the user.
- if (this function returns true) then
- #p == the next image pixel the user clicked.
- #mouse_button == the mouse button which was used to double click.
This will be either dlib::base_window::LEFT,
dlib::base_window::MIDDLE, or dlib::base_window::RIGHT
!*/
private
:
// restricted functions
...
...
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