neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
normal_title_bar.hpp
Go to the documentation of this file.
1// normal_title_bar.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2020 Leigh Johnston. All Rights Reserved.
5
6 This program is free software: you can redistribute it and / or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19#pragma once
20
21#include <neogfx/neogfx.hpp>
29
30namespace neogfx
31{
32 extern template class widget<i_title_bar>;
33
35 {
37 public:
39 private:
40 template <typename WidgetType, widget_part_e WidgetPart>
41 class non_client_item : public WidgetType
42 {
43 public:
44 template <typename... Args>
45 non_client_item(Args&&... aArgs) :
46 WidgetType{ std::forward<Args>(aArgs)... }
47 {
48 }
49 public:
50 widget_part part(const point&) const override
51 {
52 return widget_part{ this->root().as_widget(), WidgetPart};
53 }
54 bool ignore_non_client_mouse_events(bool aConsiderAncestors = true) const override
55 {
56 return false;
57 };
58 };
59 private:
60 enum texture_index_e
61 {
62 TextureMinimize,
63 TextureMaximize,
64 TextureRestore,
65 TextureClose
66 };
67 public:
68 normal_title_bar(i_standard_layout_container& aContainer, std::string const& aTitle = std::string{});
69 normal_title_bar(i_standard_layout_container& aContainer, const i_texture& aIcon, std::string const& aTitle = std::string{});
70 normal_title_bar(i_standard_layout_container& aContainer, const i_image& aIcon, std::string const& aTitle = std::string{});
71 public:
72 void set_icon(i_texture const& aIcon) override;
73 i_string const& title() const override;
74 void set_title(i_string const& aTitle) override;
75 public:
76 const image_widget& icon_widget() const override;
78 const text_widget& title_widget() const override;
80 public:
81 neogfx::size_policy size_policy() const override;
82 public:
84 widget_part part(const point&) const override;
85 public:
86 color palette_color(color_role aColorRole) const override;
87 private:
88 void init();
89 void update_textures();
90 private:
91 horizontal_layout iOuterLayout;
92 horizontal_layout iInnerLayout;
93 horizontal_layout iButtonLayout;
94 non_client_item<image_widget, widget_part::SystemMenu> iIcon;
95 non_client_item<text_widget, widget_part::TitleBar> iTitle;
96 vertical_spacer iButtonSpacer;
97 non_client_item<push_button, widget_part::MinimizeButton> iMinimizeButton;
98 non_client_item<push_button, widget_part::MaximizeButton> iMaximizeButton;
99 non_client_item<push_button, widget_part::MaximizeButton> iRestoreButton;
100 non_client_item<push_button, widget_part::CloseButton> iCloseButton;
101 sink iSink;
102 mutable std::optional<std::pair<color, texture>> iTextures[4];
103 };
104
105 template <>
106 inline widget_part normal_title_bar::non_client_item<image_widget, widget_part::SystemMenu>::part(const point&) const
107 {
108 if ((static_cast<const normal_title_bar&>(parent()).root().style() & window_style::SystemMenu) == window_style::SystemMenu)
109 return widget_part{ root().as_widget(), widget_part::SystemMenu };
110 return widget_part{ root().as_widget(), widget_part::TitleBar };
111 }
112}
neogfx::size_policy size_policy() const override
widget_part part(const point &) const override
normal_title_bar(i_standard_layout_container &aContainer, const i_image &aIcon, std::string const &aTitle=std::string{})
normal_title_bar(i_standard_layout_container &aContainer, const i_texture &aIcon, std::string const &aTitle=std::string{})
const text_widget & title_widget() const override
void set_icon(i_texture const &aIcon) override
normal_title_bar(i_standard_layout_container &aContainer, std::string const &aTitle=std::string{})
image_widget & icon_widget() override
neogfx::widget_type widget_type() const override
void set_title(i_string const &aTitle) override
text_widget & title_widget() override
i_string const & title() const override
color palette_color(color_role aColorRole) const override
const image_widget & icon_widget() const override
#define meta_object(...)
Definition i_object.hpp:28