Commit 8ac87abe authored by Davis King's avatar Davis King

Added the option to disable overlay editing to the image_display. Also made

the image_window not allow overlay editing.
parent b6bf552c
...@@ -5689,7 +5689,8 @@ namespace dlib ...@@ -5689,7 +5689,8 @@ namespace dlib
selected_rect(0), selected_rect(0),
default_rect_color(255,0,0,255), default_rect_color(255,0,0,255),
parts_menu(w), parts_menu(w),
part_width(15) // width part circles are drawn on the screen part_width(15), // width part circles are drawn on the screen
overlay_editing_enabled(true)
{ {
enable_mouse_drag(); enable_mouse_drag();
...@@ -6097,6 +6098,9 @@ namespace dlib ...@@ -6097,6 +6098,9 @@ namespace dlib
image_clicked_handler(p, is_double_click, btn); image_clicked_handler(p, is_double_click, btn);
} }
if (!overlay_editing_enabled)
return;
if (btn == base_window::RIGHT && rect_is_selected) if (btn == base_window::RIGHT && rect_is_selected)
{ {
last_right_click_pos = point(x,y); last_right_click_pos = point(x,y);
...@@ -6454,6 +6458,7 @@ namespace dlib ...@@ -6454,6 +6458,7 @@ namespace dlib
{ {
gui_img.set_image_clicked_handler(*this, &image_window::on_image_clicked); gui_img.set_image_clicked_handler(*this, &image_window::on_image_clicked);
gui_img.disable_overlay_editing();
// show this window on the screen // show this window on the screen
show(); show();
} }
......
...@@ -3457,6 +3457,22 @@ namespace dlib ...@@ -3457,6 +3457,22 @@ namespace dlib
void clear_labelable_part_names ( void clear_labelable_part_names (
); );
void enable_overlay_editing (
) { auto_mutex M(m); overlay_editing_enabled = true; }
void disable_overlay_editing (
)
{
auto_mutex M(m);
overlay_editing_enabled = false;
rect_is_selected = false;
drawing_rect = false;
parent.invalidate_rectangle(rect);
}
bool overlay_editing_is_enabled (
) const { auto_mutex M(m); return overlay_editing_enabled; }
private: private:
void draw ( void draw (
...@@ -3537,6 +3553,7 @@ namespace dlib ...@@ -3537,6 +3553,7 @@ namespace dlib
point last_right_click_pos; point last_right_click_pos;
const int part_width; const int part_width;
std::set<std::string> part_names; std::set<std::string> part_names;
bool overlay_editing_enabled;
// restricted functions // restricted functions
image_display(image_display&); // copy constructor image_display(image_display&); // copy constructor
...@@ -3569,6 +3586,7 @@ namespace dlib ...@@ -3569,6 +3586,7 @@ namespace dlib
tie_input_events(false) tie_input_events(false)
{ {
gui_img.set_image_clicked_handler(*this, &image_window::on_image_clicked); gui_img.set_image_clicked_handler(*this, &image_window::on_image_clicked);
gui_img.disable_overlay_editing();
set_image(img); set_image(img);
show(); show();
} }
...@@ -3587,6 +3605,7 @@ namespace dlib ...@@ -3587,6 +3605,7 @@ namespace dlib
tie_input_events(false) tie_input_events(false)
{ {
gui_img.set_image_clicked_handler(*this, &image_window::on_image_clicked); gui_img.set_image_clicked_handler(*this, &image_window::on_image_clicked);
gui_img.disable_overlay_editing();
set_image(img); set_image(img);
set_title(title); set_title(title);
show(); show();
......
...@@ -2324,6 +2324,7 @@ namespace dlib ...@@ -2324,6 +2324,7 @@ namespace dlib
- get_default_overlay_rect_label() == "" - get_default_overlay_rect_label() == ""
- get_default_overlay_rect_color() == rgb_alpha_pixel(255,0,0,255) (i.e. RED) - get_default_overlay_rect_color() == rgb_alpha_pixel(255,0,0,255) (i.e. RED)
- This object does not have any user labelable parts defined. - This object does not have any user labelable parts defined.
- overlay_editing_is_enabled() == true
WHAT THIS OBJECT REPRESENTS WHAT THIS OBJECT REPRESENTS
This object represents an image inside a scrollable region. This object represents an image inside a scrollable region.
...@@ -2680,6 +2681,29 @@ namespace dlib ...@@ -2680,6 +2681,29 @@ namespace dlib
- R.tl_corner() == (0,0) - R.tl_corner() == (0,0)
!*/ !*/
void enable_overlay_editing (
);
/*!
ensures
- #overlay_editing_is_enabled() == true
!*/
void disable_overlay_editing (
);
/*!
ensures
- #overlay_editing_is_enabled() == false
!*/
bool overlay_editing_is_enabled (
) const;
/*!
ensures
- if this function returns true then it is possible for the user to add or
remove overlay objects (e.g. rectangles) using the mouse and keyboard.
If it returns false then the overlay is not user editable.
!*/
template < template <
typename T typename T
> >
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment