From 77d65c98a8330a00d9cad8c10177660ebc685f9c Mon Sep 17 00:00:00 2001
From: Alexander Sulfrian <alexander@sulfrian.net>
Date: Fri, 26 Oct 2012 18:38:30 +0200
Subject: menu: fix calculate window coordinates

---
 src/menu/clipping_helper.cpp  | 6 +++++-
 src/menu/container.cpp        | 7 ++++---
 src/menu/drawable_control.cpp | 5 +++++
 src/menu/drawable_control.hpp | 1 +
 4 files changed, 15 insertions(+), 4 deletions(-)

(limited to 'src')

diff --git a/src/menu/clipping_helper.cpp b/src/menu/clipping_helper.cpp
index 425e9dec..1a92d3f1 100644
--- a/src/menu/clipping_helper.cpp
+++ b/src/menu/clipping_helper.cpp
@@ -45,7 +45,11 @@ namespace usdx
 		// calculate window coordinates of rectangle
 		if (parent) {
 			int offset = parent->get_size().get_height() - rect.get_bottom();
-			new_scissor_box.set_top(parent->get_window_coords().get_y() + offset);
+			new_scissor_box.set_top(parent->get_window_coords().get_y() +
+									offset);
+
+			new_scissor_box.set_left(parent->get_window_coords().get_x() +
+								 rect.get_left());
 		}
 
 		// calculate intersection of old clipping and requested clipping
diff --git a/src/menu/container.cpp b/src/menu/container.cpp
index 84811d3a..65b85aec 100644
--- a/src/menu/container.cpp
+++ b/src/menu/container.cpp
@@ -98,10 +98,11 @@ namespace usdx
 	void Container::recalculate_window_coords(void)
 	{
 		if (parent) {
-			window_coords.set_x(parent->get_width() -
-								(get_left() + get_width()));
+			window_coords.set_x(parent->get_window_coords().get_x() +
+								get_left());
 
-			window_coords.set_y(parent->get_height() -
+			window_coords.set_y(parent->get_window_coords().get_y() +
+								get_parent()->get_height() -
 								(get_top() + get_height()));
 		}
 	}
diff --git a/src/menu/drawable_control.cpp b/src/menu/drawable_control.cpp
index 8b2246c5..74ef77a3 100644
--- a/src/menu/drawable_control.cpp
+++ b/src/menu/drawable_control.cpp
@@ -180,6 +180,11 @@ namespace usdx
 		return size.get_height();
 	}
 
+	Container* DrawableControl::get_parent(void) const
+	{
+		return parent;
+	}
+
 	void DrawableControl::remove_parent(void)
 	{
 		if (parent) {
diff --git a/src/menu/drawable_control.hpp b/src/menu/drawable_control.hpp
index be53fbf8..9f33b376 100644
--- a/src/menu/drawable_control.hpp
+++ b/src/menu/drawable_control.hpp
@@ -118,6 +118,7 @@ namespace usdx
 		int get_width(void) const;
 		int get_height(void) const;
 
+		Container* get_parent(void) const;
 		void remove_parent(void);
 
 		void set_background(Background*);
-- 
cgit v1.2.3