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
c26367a8
Commit
c26367a8
authored
Apr 20, 2013
by
Davis King
Browse files
Added image_window::get_next_keypress()
parent
9dfcd9a5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
106 additions
and
4 deletions
+106
-4
dlib/gui_widgets/widgets.cpp
dlib/gui_widgets/widgets.cpp
+47
-2
dlib/gui_widgets/widgets.h
dlib/gui_widgets/widgets.h
+30
-2
dlib/gui_widgets/widgets_abstract.h
dlib/gui_widgets/widgets_abstract.h
+29
-0
No files found.
dlib/gui_widgets/widgets.cpp
View file @
c26367a8
...
...
@@ -6480,6 +6480,51 @@ namespace dlib
return
base_window
::
CLOSE_WINDOW
;
}
// ----------------------------------------------------------------------------------------
bool
image_window
::
get_next_keypress
(
unsigned
long
&
key
,
bool
&
is_printable
,
unsigned
long
&
state
)
{
auto_mutex
lock
(
wm
);
while
(
have_last_keypress
==
false
&&
!
window_has_closed
)
{
clicked_signaler
.
wait
();
}
if
(
window_has_closed
)
return
false
;
// Mark that we are taking the key click so the next call to get_next_keypress()
// will have to wait for another click.
have_last_keypress
=
false
;
key
=
next_key
;
is_printable
=
next_is_printable
;
state
=
next_state
;
return
true
;
}
// ----------------------------------------------------------------------------------------
void
image_window
::
on_keydown
(
unsigned
long
key
,
bool
is_printable
,
unsigned
long
state
)
{
dlib
::
base_window
::
on_keydown
(
key
,
is_printable
,
state
);
have_last_keypress
=
true
;
next_key
=
key
;
next_is_printable
=
is_printable
;
next_state
=
state
;
clicked_signaler
.
signal
();
}
// ----------------------------------------------------------------------------------------
bool
image_window
::
...
...
@@ -6497,8 +6542,8 @@ namespace dlib
if
(
window_has_closed
)
return
false
;
// Mark that we are taking the point click so the next call to
get_next_click()
// will have to wait for another click.
// Mark that we are taking the point click so the next call to
//
get_next_double_click()
will have to wait for another click.
have_last_click
=
false
;
mouse_button
=
mouse_btn
;
p
=
last_clicked_point
;
...
...
dlib/gui_widgets/widgets.h
View file @
c26367a8
...
...
@@ -3564,7 +3564,8 @@ namespace dlib
window_has_closed
(
false
),
have_last_click
(
false
),
mouse_btn
(
0
),
clicked_signaler
(
this
->
wm
)
clicked_signaler
(
this
->
wm
),
have_last_keypress
(
false
)
{
gui_img
.
set_image_clicked_handler
(
*
this
,
&
image_window
::
on_image_clicked
);
set_image
(
img
);
...
...
@@ -3580,7 +3581,8 @@ namespace dlib
window_has_closed
(
false
),
have_last_click
(
false
),
mouse_btn
(
0
),
clicked_signaler
(
this
->
wm
)
clicked_signaler
(
this
->
wm
),
have_last_keypress
(
false
)
{
gui_img
.
set_image_clicked_handler
(
*
this
,
&
image_window
::
on_image_clicked
);
set_image
(
img
);
...
...
@@ -3758,6 +3760,21 @@ namespace dlib
return
get_next_double_click
(
p
,
mouse_button
);
}
bool
get_next_keypress
(
unsigned
long
&
key
,
bool
&
is_printable
,
unsigned
long
&
state
);
bool
get_next_keypress
(
unsigned
long
&
key
,
bool
&
is_printable
)
{
unsigned
long
state
;
return
get_next_keypress
(
key
,
is_printable
,
state
);
}
private:
virtual
base_window
::
on_close_return_code
on_window_close
(
...
...
@@ -3772,6 +3789,12 @@ namespace dlib
unsigned
long
btn
);
virtual
void
on_keydown
(
unsigned
long
key
,
bool
is_printable
,
unsigned
long
state
);
// restricted functions
image_window
(
image_window
&
);
image_window
&
operator
=
(
image_window
&
);
...
...
@@ -3784,6 +3807,11 @@ namespace dlib
point
last_clicked_point
;
unsigned
long
mouse_btn
;
rsignaler
clicked_signaler
;
bool
have_last_keypress
;
unsigned
long
next_key
;
bool
next_is_printable
;
unsigned
long
next_state
;
};
// ----------------------------------------------------------------------------------------
...
...
dlib/gui_widgets/widgets_abstract.h
View file @
c26367a8
...
...
@@ -3045,6 +3045,35 @@ namespace dlib
dlib::base_window::MIDDLE, or dlib::base_window::RIGHT
!*/
bool
get_next_keypress
(
unsigned
long
&
key
,
bool
&
is_printable
,
unsigned
long
&
state
);
/*!
ensures
- This function blocks until the user presses a keyboard key or the
window is closed by the user.
- if (this function returns true) then
- The keyboard button press is recorded into #key, #is_printable, and
#state. In particular, these variables are populated with the three
identically named arguments to the base_window::on_keydown(key,is_printable,state)
event.
!*/
bool
get_next_keypress
(
unsigned
long
&
key
,
bool
&
is_printable
);
/*!
ensures
- This function blocks until the user presses a keyboard key or the
window is closed by the user.
- This function is the equivalent to calling get_next_keypress(key,is_printable,temp)
and then discarding temp.
!*/
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