mirror of https://github.com/davisking/dlib.git
Added an event handler for when the user selects an overlay rectangle.
This commit is contained in:
parent
92ac70dc6d
commit
0fae5ae6c3
|
@ -5922,6 +5922,8 @@ namespace dlib
|
|||
{
|
||||
rect_is_selected = true;
|
||||
selected_rect = best_idx;
|
||||
if (orect_selected_event_handler.is_set())
|
||||
orect_selected_event_handler(overlay_rects[best_idx]);
|
||||
}
|
||||
|
||||
if (rect_is_selected || rect_was_selected)
|
||||
|
|
|
@ -3341,6 +3341,26 @@ namespace dlib
|
|||
event_handler = event_handler_;
|
||||
}
|
||||
|
||||
template <
|
||||
typename T
|
||||
>
|
||||
void set_overlay_rect_selected_handler (
|
||||
T& object,
|
||||
void (T::*event_handler_)(const overlay_rect& orect)
|
||||
)
|
||||
{
|
||||
auto_mutex M(m);
|
||||
orect_selected_event_handler = make_mfp(object,event_handler_);
|
||||
}
|
||||
|
||||
void set_overlay_rects_changed_handler (
|
||||
const any_function<void(const overlay_rect& orect)>& event_handler_
|
||||
)
|
||||
{
|
||||
auto_mutex M(m);
|
||||
orect_selected_event_handler = event_handler_;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
@ -3402,6 +3422,7 @@ namespace dlib
|
|||
rgb_alpha_pixel default_rect_color;
|
||||
std::string default_rect_label;
|
||||
any_function<void()> event_handler;
|
||||
any_function<void(const overlay_rect& orect)> orect_selected_event_handler;
|
||||
|
||||
// restricted functions
|
||||
image_display(image_display&); // copy constructor
|
||||
|
|
|
@ -2011,7 +2011,7 @@ namespace dlib
|
|||
>
|
||||
void set_graph_modified_handler (
|
||||
T& object,
|
||||
void (T::*event_handler_)()
|
||||
void (T::*event_handler)()
|
||||
);
|
||||
/*!
|
||||
requires
|
||||
|
@ -2550,7 +2550,7 @@ namespace dlib
|
|||
>
|
||||
void set_overlay_rects_changed_handler (
|
||||
T& object,
|
||||
void (T::*event_handler_)()
|
||||
void (T::*event_handler)()
|
||||
);
|
||||
/*
|
||||
requires
|
||||
|
@ -2579,6 +2579,42 @@ namespace dlib
|
|||
- std::bad_alloc
|
||||
*/
|
||||
|
||||
template <
|
||||
typename T
|
||||
>
|
||||
void set_overlay_rect_selected_handler (
|
||||
T& object,
|
||||
void (T::*event_handler)(const overlay_rect& orect)
|
||||
);
|
||||
/*
|
||||
requires
|
||||
- event_handler is a valid pointer to a member function in T
|
||||
ensures
|
||||
- The event_handler function is called on object when the user selects
|
||||
an overlay rectangle by double clicking on it. The selected rectangle
|
||||
will be passed to event_handler().
|
||||
- any previous calls to this function are overridden by this new call.
|
||||
(i.e. you can only have one event handler associated with this
|
||||
event at a time)
|
||||
throws
|
||||
- std::bad_alloc
|
||||
*/
|
||||
|
||||
void set_overlay_rects_changed_handler (
|
||||
const any_function<void(const overlay_rect& orect)>& event_handler
|
||||
);
|
||||
/*
|
||||
ensures
|
||||
- The event_handler function is called when the user selects an overlay
|
||||
rectangle by double clicking on it. The selected rectangle will be
|
||||
passed to event_handler().
|
||||
- any previous calls to this function are overridden by this new call.
|
||||
(i.e. you can only have one event handler associated with this
|
||||
event at a time)
|
||||
throws
|
||||
- std::bad_alloc
|
||||
*/
|
||||
|
||||
private:
|
||||
|
||||
// restricted functions
|
||||
|
|
Loading…
Reference in New Issue