| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- #pragma once
- #include "BsEditorPrerequisites.h"
- #include "GUI/BsGUIToggle.h"
- #include "GUI/BsGUIToggleGroup.h"
- #include "2D/BsImageSprite.h"
- #include "Utility/BsEvent.h"
- namespace bs
- {
- /** @addtogroup GUI-Editor-Internal
- * @{
- */
- /**
- * Specialization of a GUIToggle element used for displaying tabs in a GUITabbedTitleBar. Aside from being toggleable
- * these buttons also track drag and drop operations.
- */
- class GUITabButton : public GUIToggle
- {
- public:
- /** Returns type name of the GUI element used for finding GUI element styles. */
- static const String& getGUITypeName();
- /**
- * Creates a new GUI tab button element.
- *
- * @param[in] toggleGroup A toggle group that forms a link between related tab buttons.
- * @param[in] index Unique index that can be used for identifying a tab.
- * @param[in] text Label to display in the button.
- * @param[in] styleName Optional style to use for the element. Style will be retrieved from GUISkin of the
- * GUIWidget the element is used on. If not specified default style is used.
- */
- static GUITabButton* create(const SPtr<GUIToggleGroup>& toggleGroup, UINT32 index, const HString& text,
- const String& styleName = StringUtil::BLANK);
- /**
- * Creates a new GUI tab button element.
- *
- * @param[in] toggleGroup A toggle group that forms a link between related tab buttons.
- * @param[in] index Unique index that can be used for identifying a tab.
- * @param[in] text Label to display in the button.
- * @param[in] options Options that allow you to control how is the element positioned and sized.
- * This will override any similar options set by style.
- * @param[in] styleName Optional style to use for the element. Style will be retrieved from GUISkin of the
- * GUIWidget the element is used on. If not specified default style is used.
- */
- static GUITabButton* create(const SPtr<GUIToggleGroup>& toggleGroup, UINT32 index, const HString& text,
- const GUIOptions& options, const String& styleName = StringUtil::BLANK);
-
- /**
- * Creates a new GUI tab button element.
- *
- * @param[in] toggleGroup A toggle group that forms a link between related tab buttons.
- * @param[in] index Unique index that can be used for identifying a tab.
- * @param[in] content Content to display in the button.
- * @param[in] styleName Optional style to use for the element. Style will be retrieved from GUISkin of the
- * GUIWidget the element is used on. If not specified default style is used.
- */
- static GUITabButton* create(const SPtr<GUIToggleGroup>& toggleGroup, UINT32 index, const GUIContent& content,
- const String& styleName = StringUtil::BLANK);
- /**
- * Creates a new GUI tab button element.
- *
- * @param[in] toggleGroup A toggle group that forms a link between related tab buttons.
- * @param[in] index Unique index that can be used for identifying a tab.
- * @param[in] content Content to display in the button.
- * @param[in] options Options that allow you to control how is the element positioned and sized.
- * This will override any similar options set by style.
- * @param[in] styleName Optional style to use for the element. Style will be retrieved from GUISkin of the
- * GUIWidget the element is used on. If not specified default style is used.
- */
- static GUITabButton* create(const SPtr<GUIToggleGroup>& toggleGroup, UINT32 index, const GUIContent& content,
- const GUIOptions& options, const String& styleName = StringUtil::BLANK);
- /** Returns the unique index for this tab button. */
- UINT32 getIndex() const { return mIndex; }
- /** Changes the button state to dragged or not dragged, resulting primarily in a visual change. */
- void _setDraggedState(bool active);
- /**
- * Triggered when the user starts dragging the tab button. Reported parameters are the unique index of the tab and
- * pointer position relative to parent GUIWidget.
- */
- Event<void(UINT32, const Vector2I&)> onDragged;
- /**
- * Triggered when the user ends dragging the tab button. Reported parameters are the unique index of the tab and
- * pointer position relative to parent GUIWidget.
- */
- Event<void(UINT32, const Vector2I&)> onDragEnd;
- protected:
- GUITabButton(const String& styleName, const SPtr<GUIToggleGroup>& toggleGroup, UINT32 index, const GUIContent& content, const GUIDimensions& dimensions);
- /** @copydoc GUIToggle::toggleOn */
- void _toggleOn(bool triggerEvents) override;
- /** @copydoc GUIToggle::toggleOff */
- void _toggleOff(bool triggerEvents) override;
- /** @copydoc GUIElement::_mouseEvent */
- bool _mouseEvent(const GUIMouseEvent& ev) override;
- UINT32 mIndex;
- Vector2I mDragStartPosition;
- bool mDraggedState;
- GUIElementState mInactiveState;
- static const UINT32 DRAG_MIN_DISTANCE;
- };
- /** @} */
- }
|