Correction des problèmes de layout des modales

This commit is contained in:
Mattéo Delabre 2016-04-29 02:50:56 +02:00
parent 8684953938
commit 0f5cbc6d9e
3 changed files with 9 additions and 19 deletions

View File

@ -6,13 +6,11 @@
#include <functional>
/**
* 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;

View File

@ -23,10 +23,6 @@ Window {
}
Window.modal {
BackgroundColor: #00000000;
}
Window.modal Window {
Gap: 20;
}

View File

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