Browse Source

Correction des problèmes de layout des modales

master
Mattéo Delabre 7 years ago
parent
commit
0f5cbc6d9e
  1. 6
      include/gui/modal.hpp
  2. 4
      res/gui.theme
  3. 18
      src/gui/modal.cpp

6
include/gui/modal.hpp

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

4
res/gui.theme

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

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

Loading…
Cancel
Save