neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
push_button.hpp
Go to the documentation of this file.
1// push_button.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2015, 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
20#pragma once
21
22#include <neogfx/neogfx.hpp>
25
26namespace neogfx
27{
28 extern template class widget<i_push_button>;
29 extern template class button<i_push_button>;
30
32 {
34 public:
35 static const uint32_t kMaxAnimationFrame = 10;
36 public:
38 push_button(std::string const& aText, push_button_style aStyle = push_button_style::Normal);
41 push_button(std::string const& aText, const i_texture& aTexture, push_button_style aStyle = push_button_style::Normal);
42 push_button(std::string const& aText, const i_image& aImage, push_button_style aStyle = push_button_style::Normal);
44 push_button(i_widget& aParent, std::string const& aText, push_button_style aStyle = push_button_style::Normal);
47 push_button(i_widget& aParent, std::string const& aText, const i_texture& aTexture, push_button_style aStyle = push_button_style::Normal);
48 push_button(i_widget& aParent, std::string const& aText, const i_image& aImage, push_button_style aStyle = push_button_style::Normal);
50 push_button(i_layout& aLayout, std::string const& aText, push_button_style aStyle = push_button_style::Normal);
53 push_button(i_layout& aLayout, std::string const& aText, const i_texture& aTexture, push_button_style aStyle = push_button_style::Normal);
54 push_button(i_layout& aLayout, std::string const& aText, const i_image& aImage, push_button_style aStyle = push_button_style::Normal);
55 // button
56 public:
57 size minimum_size(optional_size const& aAvailableSpace = optional_size{}) const override;
58 size maximum_size(optional_size const& aAvailableSpace = optional_size{}) const override;
59 public:
60 void paint_non_client(i_graphics_context& aGc) const override;
61 void paint(i_graphics_context& aGc) const override;
62 public:
63 color palette_color(color_role aColorRole) const override;
64 public:
65 void mouse_entered(const point& aPosition) override;
66 void mouse_left() override;
67 // i_push_button
68 public:
69 push_button_style style() const override;
70 virtual bool has_face_color() const;
71 virtual color face_color() const;
72 virtual void set_face_color(const optional_color& aFaceColor = optional_color{});
73 virtual bool has_hover_color() const;
74 virtual color hover_color() const;
75 virtual void set_hover_color(const optional_color& aHoverColor = optional_color{});
76 // push_button
77 protected:
78 virtual rect path_bounding_rect() const;
79 virtual neogfx::path path() const;
80 virtual bool spot_color() const;
81 virtual color border_color() const;
82 virtual bool perform_hover_animation() const;
83 virtual void animate();
84 virtual bool finished_animation() const;
85 virtual color effective_face_color() const;
87 virtual color animation_color(uint32_t aAnimationFrame) const;
88 private:
89 void init();
90 private:
91 widget_timer iAnimator;
92 uint32_t iAnimationFrame;
93 push_button_style iStyle;
94 optional_color iFaceColor;
95 optional_color iHoverColor;
96 mutable std::optional<std::pair<neogfx::font, size>> iStandardButtonWidth;
97 };
98}
void paint(i_graphics_context &aGc) const override
virtual color effective_hover_color() const
push_button(i_widget &aParent, std::string const &aText, const i_image &aImage, push_button_style aStyle=push_button_style::Normal)
void mouse_entered(const point &aPosition) override
void paint_non_client(i_graphics_context &aGc) const override
push_button(std::string const &aText, const i_image &aImage, push_button_style aStyle=push_button_style::Normal)
push_button(const i_image &aImage, push_button_style aStyle=push_button_style::Normal)
virtual bool has_face_color() const
push_button_style style() const override
size maximum_size(optional_size const &aAvailableSpace=optional_size{}) const override
virtual void set_face_color(const optional_color &aFaceColor=optional_color{})
virtual color face_color() const
push_button(i_widget &aParent, const i_texture &aTexture, push_button_style aStyle=push_button_style::Normal)
push_button(i_widget &aParent, std::string const &aText, push_button_style aStyle=push_button_style::Normal)
virtual bool spot_color() const
color palette_color(color_role aColorRole) const override
push_button(i_widget &aParent, std::string const &aText, const i_texture &aTexture, push_button_style aStyle=push_button_style::Normal)
push_button(i_layout &aLayout, std::string const &aText, const i_image &aImage, push_button_style aStyle=push_button_style::Normal)
push_button(std::string const &aText, push_button_style aStyle=push_button_style::Normal)
push_button(const i_texture &aTexture, push_button_style aStyle=push_button_style::Normal)
push_button(i_widget &aParent, push_button_style aStyle=push_button_style::Normal)
virtual void animate()
push_button(i_layout &aLayout, const i_texture &aTexture, push_button_style aStyle=push_button_style::Normal)
push_button(std::string const &aText, const i_texture &aTexture, push_button_style aStyle=push_button_style::Normal)
virtual color hover_color() const
virtual rect path_bounding_rect() const
push_button(i_layout &aLayout, push_button_style aStyle=push_button_style::Normal)
virtual bool has_hover_color() const
push_button(i_widget &aParent, const i_image &aImage, push_button_style aStyle=push_button_style::Normal)
virtual bool finished_animation() const
size minimum_size(optional_size const &aAvailableSpace=optional_size{}) const override
virtual color animation_color(uint32_t aAnimationFrame) const
virtual neogfx::path path() const
virtual color border_color() const
virtual bool perform_hover_animation() const
virtual void set_hover_color(const optional_color &aHoverColor=optional_color{})
virtual color effective_face_color() const
void mouse_left() override
push_button(i_layout &aLayout, std::string const &aText, push_button_style aStyle=push_button_style::Normal)
push_button(push_button_style aStyle=push_button_style::Normal)
push_button(i_layout &aLayout, const i_image &aImage, push_button_style aStyle=push_button_style::Normal)
push_button(i_layout &aLayout, std::string const &aText, const i_texture &aTexture, push_button_style aStyle=push_button_style::Normal)
#define meta_object(...)
Definition i_object.hpp:28