From 3ee941b5196cd9328f8e6d5de8fb0aeeae9e39f1 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Fri, 18 Jan 2013 19:40:54 +0100 Subject: menu: add get_component_at to get component This is the basis for mouse focus handling. --- src/menu/drawable_control.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/menu/drawable_control.cpp') diff --git a/src/menu/drawable_control.cpp b/src/menu/drawable_control.cpp index 47df96db..76749840 100644 --- a/src/menu/drawable_control.cpp +++ b/src/menu/drawable_control.cpp @@ -230,4 +230,26 @@ namespace usdx boost::shared_lock lock(background_mutex); return background; } + + const Rectangle DrawableControl::get_absolut_rect(void) const + { + Rectangle rect(get_position(), get_size()); + + if (parent) { + Rectangle parent_rect = parent->get_absolut_rect(); + rect += Point(parent_rect.get_left(), + parent_rect.get_top()); + } + + return rect; + } + + DrawableControl* DrawableControl::get_component_at(const Point& p) + { + if (focusable && get_absolut_rect().is_in(p)) { + return this; + } + + return NULL; + } }; -- cgit v1.2.3