From 0f5cbc6d9eaa8c8fa4e405e8ab94c2e107c4b92a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matt=C3=A9o=20Delabre?= Date: Fri, 29 Apr 2016 02:50:56 +0200 Subject: [PATCH] =?UTF-8?q?Correction=20des=20probl=C3=A8mes=20de=20layout?= =?UTF-8?q?=20des=20modales?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/gui/modal.hpp | 6 ++---- res/gui.theme | 4 ---- src/gui/modal.cpp | 18 +++++++----------- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/include/gui/modal.hpp b/include/gui/modal.hpp index 7f38df4..8a6ac0e 100644 --- a/include/gui/modal.hpp +++ b/include/gui/modal.hpp @@ -6,13 +6,11 @@ #include /** - * Classe de base pour les fenêtres modales - * qui bloquent l'accès aux autres éléments du jeu + * Classe pour les dialogues d'information du jeu */ class Modal { protected: - sfg::Window::Ptr modal_main_window; - sfg::Window::Ptr modal_inner_window; + sfg::Window::Ptr modal_window; sfg::Box::Ptr layout_box; sfg::Box::Ptr buttons_box; diff --git a/res/gui.theme b/res/gui.theme index 935057f..7386ab4 100644 --- a/res/gui.theme +++ b/res/gui.theme @@ -23,10 +23,6 @@ Window { } Window.modal { - BackgroundColor: #00000000; -} - -Window.modal Window { Gap: 20; } diff --git a/src/gui/modal.cpp b/src/gui/modal.cpp index 1465fdb..6549645 100644 --- a/src/gui/modal.cpp +++ b/src/gui/modal.cpp @@ -3,10 +3,8 @@ Modal::Modal() { // création des fenêtres - modal_main_window = sfg::Window::Create(sfg::Window::Style::BACKGROUND); - modal_inner_window = sfg::Window::Create(sfg::Window::Style::BACKGROUND); - - modal_main_window->SetClass("modal"); + modal_window = sfg::Window::Create(sfg::Window::Style::BACKGROUND); + modal_window->SetClass("modal"); // la fenêtre interne est alignée au centre de la principale sfg::Alignment::Ptr inner_alignment = sfg::Alignment::Create(); @@ -27,14 +25,11 @@ Modal::Modal() { layout_box->PackEnd(subtitle_label); layout_box->PackEnd(spacer); layout_box->PackEnd(buttons_box); - modal_inner_window->Add(layout_box); - - inner_alignment->Add(modal_inner_window); - modal_main_window->Add(inner_alignment); + modal_window->Add(layout_box); } sfg::Window::Ptr Modal::getWindow() { - return modal_main_window; + return modal_window; } sfg::Box::Ptr Modal::getLayoutBox() { @@ -62,7 +57,8 @@ void Modal::setSubtitle(sf::String label) { } void Modal::resize(sf::Vector2u size) { - modal_main_window->SetAllocation(sf::FloatRect( - 0, 0, size.x, size.y + modal_window->SetAllocation(sf::FloatRect( + (sf::Vector2f) size / 2.f - modal_window->GetRequisition() / 2.f, + modal_window->GetRequisition() / 2.f )); }