Fixed WindowDialog not aligning properly

This commit is contained in:
Robert Hernandez 2017-03-30 23:35:57 -04:00
parent a4a12a2b7b
commit 7a428206fe
4 changed files with 17 additions and 6 deletions

View file

@ -177,7 +177,18 @@ void WindowDialog::_notification(int p_what) {
Size2 size = get_size();
Ref<StyleBox> panel = get_stylebox("panel", "WindowDialog");
panel->draw(canvas, Rect2(Point2(), size));
int margin_left = static_cast<int>(panel->get_margin(MARGIN_LEFT));
int margin_top = static_cast<int>(panel->get_margin(MARGIN_TOP));
int margin_right = static_cast<int>(panel->get_margin(MARGIN_RIGHT));
int margin_bottom = static_cast<int>(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");

View file

@ -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);
}

View file

@ -544,7 +544,7 @@ void fill_default_theme(Ref<Theme> &t, const Ref<Font> &default_font, const Ref<
t->set_font("title_font", "WindowDialog", large_font);
t->set_color("title_color", "WindowDialog", Color(0, 0, 0));
t->set_constant("title_height", "WindowDialog", 18 * scale);
t->set_constant("title_height", "WindowDialog", 20 * scale);
t->set_icon("close", "WindowDialog", make_icon(close_png));
t->set_icon("close_hilite", "WindowDialog", make_icon(close_hl_png));

View file

@ -134,9 +134,9 @@ void StyleBoxTexture::draw(RID p_canvas_item, const Rect2 &p_rect) const {
Rect2 rect = p_rect;
Rect2 src_rect = region_rect;
texture->get_rect_region(rect, src_rect, rect, src_rect);
VisualServer::get_singleton()->canvas_item_add_nine_patch(p_canvas_item, 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, modulate);
}