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
d627aea9
Commit
d627aea9
authored
Mar 04, 2017
by
Davis King
Browse files
Made the image_display widget draw mouse cross-hairs when the user holds shift.
parent
9be82fdc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
3 deletions
+60
-3
dlib/gui_widgets/widgets.cpp
dlib/gui_widgets/widgets.cpp
+59
-3
dlib/gui_widgets/widgets.h
dlib/gui_widgets/widgets.h
+1
-0
No files found.
dlib/gui_widgets/widgets.cpp
View file @
d627aea9
...
...
@@ -6012,7 +6012,8 @@ namespace dlib
part_width(15), // width part circles are drawn on the screen
overlay_editing_enabled(true),
highlight_timer(*this, &image_display::timer_event_unhighlight_rect),
highlighted_rect
(
std
::
numeric_limits
<
unsigned
long
>::
max
())
highlighted_rect(std::numeric_limits<unsigned long>::max()),
holding_shift_key(false)
{
enable_mouse_drag();
...
...
@@ -6250,16 +6251,26 @@ namespace dlib
const point origin(total_rect().tl_corner());
// draw the image on the screen
const double scale = zoom_out_scale/(double)zoom_in_scale;
const rectangle img_area = total_rect().intersect(area);
for (long row = img_area.top(); row <= img_area.bottom(); ++row)
{
const long rc = row-c.top();
const long rimg = (row-origin.y())*scale;
for (long col = img_area.left(); col <= img_area.right(); ++col)
{
assign_pixel
(
c
[
r
ow
-
c
.
top
()
][
col
-
c
.
left
()],
img
[
(
row
-
origin
.
y
())
*
zoom_out_scale
/
zoom_in_scale
][(
col
-
origin
.
x
())
*
zoom_out_scale
/
zoom_in_
scale
]);
assign_pixel(c[r
c
][col-c.left()],
img[
rimg][(col-origin.x())*
scale]);
}
}
// draw the mouse cross-hairs
if (holding_shift_key && total_rect().contains(lastx,lasty) )
{
draw_line(c, point(lastx,-10000), point(lastx,100000),rgb_pixel(255,255,0), area);
draw_line(c, point(-10000,lasty), point(100000,lasty),rgb_pixel(255,255,0), area);
}
// now draw all the overlay rectangles
for (unsigned long i = 0; i < overlay_rects.size(); ++i)
{
...
...
@@ -6393,6 +6404,20 @@ namespace dlib
{
scrollable_region::on_keydown(key,is_printable, state);
if (!is_printable && key==base_window::KEY_SHIFT)
{
if (!holding_shift_key)
{
holding_shift_key = true;
parent.invalidate_rectangle(rect);
}
}
else if (holding_shift_key)
{
holding_shift_key = false;
parent.invalidate_rectangle(rect);
}
if (!is_printable && !hidden && enabled && rect_is_selected &&
(key == base_window::KEY_BACKSPACE || key == base_window::KEY_DELETE))
{
...
...
@@ -6459,6 +6484,16 @@ namespace dlib
{
scrollable_region::on_mouse_down(btn, state, x, y, is_double_click);
if (state&base_window::SHIFT)
{
holding_shift_key = true;
}
else if (holding_shift_key)
{
holding_shift_key = false;
parent.invalidate_rectangle(rect);
}
if (rect.contains(x,y) == false || hidden || !enabled)
return;
...
...
@@ -6757,6 +6792,16 @@ namespace dlib
{
scrollable_region::on_mouse_up(btn,state,x,y);
if (state&base_window::SHIFT)
{
holding_shift_key = true;
}
else if (holding_shift_key)
{
holding_shift_key = false;
parent.invalidate_rectangle(rect);
}
if (drawing_rect && btn == base_window::LEFT && (state&base_window::SHIFT) &&
!hidden && enabled)
{
...
...
@@ -6817,6 +6862,17 @@ namespace dlib
{
scrollable_region::on_mouse_move(state,x,y);
if (enabled && !hidden)
{
if (holding_shift_key)
parent.invalidate_rectangle(rect);
if (state&base_window::SHIFT)
holding_shift_key = true;
else if (holding_shift_key)
holding_shift_key = false;
}
if (drawing_rect)
{
if ((state&base_window::LEFT) && (state&base_window::SHIFT) && !hidden && enabled)
...
...
dlib/gui_widgets/widgets.h
View file @
d627aea9
...
...
@@ -3593,6 +3593,7 @@ namespace dlib
bool
overlay_editing_enabled
;
timer
<
image_display
>
highlight_timer
;
unsigned
long
highlighted_rect
;
bool
holding_shift_key
;
bool
moving_overlay
;
unsigned
long
moving_rect
;
...
...
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