From 7a428206fec3018f2535768b8a1f20ab9f02aa22 Mon Sep 17 00:00:00 2001 From: Robert Hernandez Date: Thu, 30 Mar 2017 23:35:57 -0400 Subject: Fixed WindowDialog not aligning properly --- scene/gui/dialogs.cpp | 13 ++++++++++++- scene/gui/patch_9_rect.cpp | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'scene/gui') diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index 35d54d9843..df8bfcf691 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -177,7 +177,18 @@ void WindowDialog::_notification(int p_what) { Size2 size = get_size(); Ref panel = get_stylebox("panel", "WindowDialog"); - panel->draw(canvas, Rect2(Point2(), size)); + int margin_left = static_cast(panel->get_margin(MARGIN_LEFT)); + int margin_top = static_cast(panel->get_margin(MARGIN_TOP)); + int margin_right = static_cast(panel->get_margin(MARGIN_RIGHT)); + int margin_bottom = static_cast(panel->get_margin(MARGIN_BOTTOM)); + + Rect2 rect; + rect.pos.x = -margin_left; + rect.pos.y = -margin_top; + rect.size.width = size.width + margin_left + margin_right; + rect.size.height = size.height + margin_top + margin_bottom; + + panel->draw(canvas, rect); int title_height = get_constant("title_height", "WindowDialog"); Color title_color = get_color("title_color", "WindowDialog"); diff --git a/scene/gui/patch_9_rect.cpp b/scene/gui/patch_9_rect.cpp index 77178b902f..f53036085f 100644 --- a/scene/gui/patch_9_rect.cpp +++ b/scene/gui/patch_9_rect.cpp @@ -39,9 +39,9 @@ void NinePatchRect::_notification(int p_what) { Rect2 rect = Rect2(Point2(), get_size()); Rect2 src_rect = region_rect; - + texture->get_rect_region(rect, src_rect, rect, src_rect); - + RID ci = get_canvas_item(); VS::get_singleton()->canvas_item_add_nine_patch(ci, rect, src_rect, texture->get_rid(), Vector2(margin[MARGIN_LEFT], margin[MARGIN_TOP]), Vector2(margin[MARGIN_RIGHT], margin[MARGIN_BOTTOM]), VS::NINE_PATCH_STRETCH, VS::NINE_PATCH_STRETCH, draw_center); } -- cgit v1.2.3