WizardPage.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (c) 2021, Nick Vella <nick@nxk.io>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibGUI/BoxLayout.h>
  7. #include <LibGUI/Label.h>
  8. #include <LibGUI/SeparatorWidget.h>
  9. #include <LibGUI/Widget.h>
  10. #include <LibGUI/Wizards/WizardPage.h>
  11. #include <LibGfx/Font/FontDatabase.h>
  12. #include <LibGfx/SystemTheme.h>
  13. namespace GUI {
  14. WizardPage::WizardPage(String const& title_text, String const& subtitle_text)
  15. : AbstractWizardPage()
  16. {
  17. set_layout<VerticalBoxLayout>();
  18. layout()->set_spacing(0);
  19. auto& header_widget = add<Widget>();
  20. header_widget.set_fill_with_background_color(true);
  21. header_widget.set_background_role(Gfx::ColorRole::Base);
  22. header_widget.set_fixed_height(58);
  23. header_widget.set_layout<VerticalBoxLayout>();
  24. header_widget.layout()->set_margins({ 15, 30, 0 });
  25. m_title_label = header_widget.add<Label>(title_text);
  26. m_title_label->set_font(Gfx::FontDatabase::default_font().bold_variant());
  27. m_title_label->set_fixed_height(m_title_label->font().glyph_height() + 2);
  28. m_title_label->set_text_alignment(Gfx::TextAlignment::TopLeft);
  29. m_subtitle_label = header_widget.add<Label>(subtitle_text);
  30. m_subtitle_label->set_text_alignment(Gfx::TextAlignment::TopLeft);
  31. m_subtitle_label->set_fixed_height(m_subtitle_label->font().glyph_height());
  32. header_widget.layout()->add_spacer();
  33. auto& separator = add<SeparatorWidget>(Gfx::Orientation::Horizontal);
  34. separator.set_fixed_height(2);
  35. m_body_widget = add<Widget>();
  36. m_body_widget->set_layout<VerticalBoxLayout>();
  37. m_body_widget->layout()->set_margins(20);
  38. }
  39. void WizardPage::set_page_title(String const& text)
  40. {
  41. m_title_label->set_text(text);
  42. }
  43. void WizardPage::set_page_subtitle(String const& text)
  44. {
  45. m_subtitle_label->set_text(text);
  46. }
  47. }