1//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************//
2//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
3#pragma once
4
5#include "BsPrerequisites.h"
6#include "GUI/BsGUIButtonBase.h"
7#include "GUI/BsGUIContent.h"
8
9namespace bs
10{
11 /** @addtogroup GUI
12 * @{
13 */
14
15 /** GUI button that can be clicked. Has normal, hover and active states with an optional label. */
16 class BS_EXPORT GUIButton : public GUIButtonBase
17 {
18 public:
19 /**
20 * Returns type name of the GUI element used for finding GUI element styles.
21 */
22 static const String& getGUITypeName();
23
24 /**
25 * Creates a new button with the specified label.
26 *
27 * @param[in] text Label to display on the button.
28 * @param[in] styleName Optional style to use for the element. Style will be retrieved from GUISkin of the
29 * GUIWidget the element is used on. If not specified default button style is used.
30 */
31 static GUIButton* create(const HString& text, const String& styleName = StringUtil::BLANK);
32
33 /**
34 * Creates a new button with the specified label.
35 *
36 * @param[in] text Label to display on the button.
37 * @param[in] options Options that allow you to control how is the element positioned and sized.
38 * This will override any similar options set by style.
39 * @param[in] styleName Optional style to use for the element. Style will be retrieved from GUISkin of the
40 * GUIWidget the element is used on. If not specified default button style is used.
41 */
42 static GUIButton* create(const HString& text, const GUIOptions& options, const String& styleName = StringUtil::BLANK);
43
44 /**
45 * Creates a new button with the specified label.
46 *
47 * @param[in] content Content to display on a button. May include a label, image and a tooltip.
48 * @param[in] styleName Optional style to use for the element. Style will be retrieved from GUISkin of the
49 * GUIWidget the element is used on. If not specified default button style is used.
50 */
51 static GUIButton* create(const GUIContent& content, const String& styleName = StringUtil::BLANK);
52
53 /**
54 * Creates a new button with the specified label.
55 *
56 * @param[in] content Content to display on a button. May include a label, image and a tooltip.
57 * @param[in] options Options that allow you to control how is the element positioned and sized. This will
58 * override any similar options set by style.
59 * @param[in] styleName Optional style to use for the element. Style will be retrieved from GUISkin of the
60 * GUIWidget the element is used on. If not specified default button style is used.
61 */
62 static GUIButton* create(const GUIContent& content, const GUIOptions& options, const String& styleName = StringUtil::BLANK);
63
64 public: // ***** INTERNAL ******
65 /** @name Internal
66 * @{
67 */
68
69 /** @copydoc GUIElement::_getElementType */
70 ElementType _getElementType() const override { return ElementType::Button; }
71
72 /** @} */
73 private:
74 GUIButton(const String& styleName, const GUIContent& content, const GUIDimensions& dimensions);
75
76 /** @copydoc GUIButtonBase::_commandEvent */
77 bool _commandEvent(const GUICommandEvent& ev) override;
78 };
79
80 /** @} */
81}