Correction des problèmes de layout des modales
This commit is contained in:
parent
8684953938
commit
0f5cbc6d9e
|
@ -6,13 +6,11 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classe de base pour les fenêtres modales
|
* Classe pour les dialogues d'information du jeu
|
||||||
* qui bloquent l'accès aux autres éléments du jeu
|
|
||||||
*/
|
*/
|
||||||
class Modal {
|
class Modal {
|
||||||
protected:
|
protected:
|
||||||
sfg::Window::Ptr modal_main_window;
|
sfg::Window::Ptr modal_window;
|
||||||
sfg::Window::Ptr modal_inner_window;
|
|
||||||
|
|
||||||
sfg::Box::Ptr layout_box;
|
sfg::Box::Ptr layout_box;
|
||||||
sfg::Box::Ptr buttons_box;
|
sfg::Box::Ptr buttons_box;
|
||||||
|
|
|
@ -23,10 +23,6 @@ Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
Window.modal {
|
Window.modal {
|
||||||
BackgroundColor: #00000000;
|
|
||||||
}
|
|
||||||
|
|
||||||
Window.modal Window {
|
|
||||||
Gap: 20;
|
Gap: 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,8 @@
|
||||||
|
|
||||||
Modal::Modal() {
|
Modal::Modal() {
|
||||||
// création des fenêtres
|
// création des fenêtres
|
||||||
modal_main_window = sfg::Window::Create(sfg::Window::Style::BACKGROUND);
|
modal_window = sfg::Window::Create(sfg::Window::Style::BACKGROUND);
|
||||||
modal_inner_window = sfg::Window::Create(sfg::Window::Style::BACKGROUND);
|
modal_window->SetClass("modal");
|
||||||
|
|
||||||
modal_main_window->SetClass("modal");
|
|
||||||
|
|
||||||
// la fenêtre interne est alignée au centre de la principale
|
// la fenêtre interne est alignée au centre de la principale
|
||||||
sfg::Alignment::Ptr inner_alignment = sfg::Alignment::Create();
|
sfg::Alignment::Ptr inner_alignment = sfg::Alignment::Create();
|
||||||
|
@ -27,14 +25,11 @@ Modal::Modal() {
|
||||||
layout_box->PackEnd(subtitle_label);
|
layout_box->PackEnd(subtitle_label);
|
||||||
layout_box->PackEnd(spacer);
|
layout_box->PackEnd(spacer);
|
||||||
layout_box->PackEnd(buttons_box);
|
layout_box->PackEnd(buttons_box);
|
||||||
modal_inner_window->Add(layout_box);
|
modal_window->Add(layout_box);
|
||||||
|
|
||||||
inner_alignment->Add(modal_inner_window);
|
|
||||||
modal_main_window->Add(inner_alignment);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sfg::Window::Ptr Modal::getWindow() {
|
sfg::Window::Ptr Modal::getWindow() {
|
||||||
return modal_main_window;
|
return modal_window;
|
||||||
}
|
}
|
||||||
|
|
||||||
sfg::Box::Ptr Modal::getLayoutBox() {
|
sfg::Box::Ptr Modal::getLayoutBox() {
|
||||||
|
@ -62,7 +57,8 @@ void Modal::setSubtitle(sf::String label) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Modal::resize(sf::Vector2u size) {
|
void Modal::resize(sf::Vector2u size) {
|
||||||
modal_main_window->SetAllocation(sf::FloatRect(
|
modal_window->SetAllocation(sf::FloatRect(
|
||||||
0, 0, size.x, size.y
|
(sf::Vector2f) size / 2.f - modal_window->GetRequisition() / 2.f,
|
||||||
|
modal_window->GetRequisition() / 2.f
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue