|
FifeGUI 0.2.0
A C++ GUI library designed for games.
|
#include <horizontalbar.hpp>
Public Types | |
| enum class | Alignment { Start , Center , End } |
| Public Types inherited from fcn::Container | |
| enum class | LayoutPolicy : uint8_t { Absolute = 0 , AutoSize , Vertical , Horizontal , Circular } |
| Public Types inherited from fcn::Widget | |
| enum | BorderSide : uint8_t { BORDER_NONE = 0 , BORDER_LEFT = 1 << 0 , BORDER_TOP = 1 << 1 , BORDER_RIGHT = 1 << 2 , BORDER_BOTTOM = 1 << 3 , BORDER_ALL = BORDER_LEFT | BORDER_TOP | BORDER_RIGHT | BORDER_BOTTOM } |
| enum | BorderStyle : uint8_t { BORDER_STYLE_BEVEL = 0 , BORDER_STYLE_FLAT = 1 } |
| enum class | SelectionMode : uint8_t { None = 0 , Border = 1 , Background = 2 } |
Public Member Functions | |
| void | adjustSize () override |
| void | draw (Graphics *graphics) override |
| unsigned int | getFixedHeight () const |
| unsigned int | getPadding () const |
| unsigned int | getSpacing () const |
| HorizontalBar () | |
| HorizontalBar (HorizontalBar &&)=delete | |
| HorizontalBar (HorizontalBar const &)=delete | |
| bool | isClipping () const |
| bool | isExpandChildren () const |
| HorizontalBar & | operator= (HorizontalBar &&)=delete |
| HorizontalBar & | operator= (HorizontalBar const &)=delete |
| void | resizeToContent (bool recursion=true) override |
| void | setClipping (bool clip) |
| void | setExpandChildren (bool expand) |
| void | setFixedHeight (unsigned int height) |
| void | setPadding (unsigned int padding) |
| void | setSpacing (unsigned int spacing) |
| Public Member Functions inherited from fcn::Container | |
| virtual void | add (Widget *widget) |
| virtual void | add (Widget *widget, int x, int y) |
| void | addContainerListener (ContainerListener *containerListener) |
| virtual void | addWidget (std::unique_ptr< Widget > widget) |
| virtual void | addWidget (std::unique_ptr< Widget > widget, int x, int y) |
| Container () | |
| Container (Container &&)=delete | |
| Container (Container const &)=delete | |
| void | expandContent () |
| void | expandContent (bool recursion) override |
| Widget * | findWidgetById (std::string const &id) override |
| Widget * | getBackgroundWidget () |
| Widget * | getChild (unsigned int index) const |
| Rectangle | getChildrenArea () override |
| virtual unsigned int | getHorizontalSpacing () const |
| virtual LayoutPolicy | getLayout () const |
| virtual unsigned int | getVerticalSpacing () const |
| bool | isLayouted () override |
| virtual bool | isOpaque () const |
| virtual bool | isUniformSize () const |
| Container & | operator= (Container &&)=delete |
| Container & | operator= (Container const &)=delete |
| void | remove (Widget *widget) override |
| void | removeAllChildren () override |
| void | removeContainerListener (ContainerListener *containerListener) |
| void | setBackgroundWidget (Widget *widget) |
| virtual void | setHorizontalSpacing (unsigned int spacing) |
| virtual void | setLayout (LayoutPolicy policy) |
| virtual void | setOpacity (float opacity) |
| virtual void | setOpaque (bool opaque) |
| virtual void | setUniformSize (bool uniform) |
| virtual void | setVerticalSpacing (unsigned int spacing) |
| Public Member Functions inherited from fcn::Widget | |
| virtual void | _draw (Graphics *graphics) |
| virtual FocusHandler * | _getFocusHandler () |
| virtual std::list< FocusListener * > const & | _getFocusListeners () |
| virtual FocusHandler * | _getInternalFocusHandler () |
| virtual std::list< KeyListener * > const & | _getKeyListeners () |
| virtual std::list< MouseListener * > const & | _getMouseListeners () |
| virtual void | _logic () |
| virtual void | _setFocusHandler (FocusHandler *focusHandler) |
| virtual void | _setParent (Widget *parent) |
| void | adaptLayout () |
| virtual void | adaptLayout (bool top) |
| void | addActionListener (ActionListener *actionListener) |
| void | addDeathListener (DeathListener *deathListener) |
| void | addDropTargetListener (DropTargetListener *listener) |
| void | addFocusListener (FocusListener *focusListener) |
| void | addKeyListener (KeyListener *keyListener) |
| void | addMouseListener (MouseListener *mouseListener) |
| void | addWidgetListener (WidgetListener *widgetListener) |
| bool | captureMouse () |
| bool | contains (int x, int y) const |
| virtual void | drawBorder (Graphics *graphics) |
| void | drawBorder (Graphics *graphics, unsigned int sides) |
| virtual void | drawOutline (Graphics *graphics) |
| virtual void | drawSelectionFrame (Graphics *graphics) |
| void | expandContent () |
| virtual void | focusNext () |
| virtual void | focusPrevious () |
| virtual void | fontChanged () |
| virtual void | getAbsolutePosition (int &x, int &y) const |
| std::string const & | getActionEventId () const |
| Color const & | getBackgroundColor () const |
| Color const & | getBaseColor () const |
| Color const & | getBorderColor () const |
| unsigned int | getBorderSides () const |
| unsigned int | getBorderSize () const |
| unsigned int | getBorderStyle () const |
| unsigned int | getChildrenCount () const |
| Rectangle const & | getDimension () const |
| Size const & | getFixedSize () const |
| Font * | getFont () const |
| Color const & | getForegroundColor () const |
| int | getHeight () const |
| std::string const & | getId () const |
| void | getLastPosition (int &x, int &y) const |
| int | getMarginBottom () const |
| int | getMarginLeft () const |
| int | getMarginRight () const |
| int | getMarginTop () const |
| Size const & | getMaxSize () const |
| Size const & | getMinSize () const |
| Color const & | getOutlineColor () const |
| unsigned int | getOutlineSize () const |
| unsigned int | getPaddingBottom () const |
| unsigned int | getPaddingLeft () const |
| unsigned int | getPaddingRight () const |
| unsigned int | getPaddingTop () const |
| virtual Widget * | getParent () const |
| Color const & | getSelectionColor () const |
| SelectionMode | getSelectionMode () const |
| virtual Widget * | getTop () const |
| unsigned int | getVisibleChildrenCount () const |
| Widget * | getWidgetAt (int x, int y) |
| virtual Widget * | getWidgetAt (int x, int y, Widget *exclude) |
| std::list< Widget * > | getWidgetsIn (Rectangle const &area) |
| virtual std::list< Widget * > | getWidgetsIn (Rectangle const &area, Widget *ignore) |
| int | getWidth () const |
| int | getX () const |
| int | getY () const |
| bool | hasMouseCapture () const |
| bool | isDescendantOf (Widget const *ancestor) const noexcept |
| bool | isEnabled () const |
| bool | isFixedSize () const |
| bool | isFocusable () const |
| virtual bool | isFocused () const |
| bool | isHorizontalExpand () const |
| bool | isInsideActiveMouseModal () const noexcept |
| bool | isLastPositionSet () const |
| virtual bool | isModalFocusable () const |
| virtual bool | isModalFocused () const |
| virtual bool | isModalMouseInputFocusable () const |
| bool | isMouseInside (MouseEvent const &mouseEvent) const |
| bool | isSetVisible () const |
| bool | isTabInEnabled () const |
| bool | isTabOutEnabled () const |
| virtual bool | isUnderMouseModal () const |
| bool | isVerticalExpand () const |
| bool | isVisible () const |
| virtual void | logic () |
| virtual void | moveToBottom (Widget *widget) |
| virtual void | moveToTop (Widget *widget) |
| virtual void | onFocusChanged () |
| virtual void | onFocusGained () |
| virtual void | onFocusLost () |
| Widget & | operator= (Widget &&)=delete |
| Widget & | operator= (Widget const &)=delete |
| void | releaseMouse () |
| void | removeActionListener (ActionListener *actionListener) |
| void | removeDeathListener (DeathListener *deathListener) |
| void | removeDropTargetListener (DropTargetListener *listener) |
| void | removeFocusListener (FocusListener *focusListener) |
| void | removeKeyListener (KeyListener *keyListener) |
| void | removeMouseListener (MouseListener *mouseListener) |
| void | removeWidgetListener (WidgetListener *widgetListener) |
| virtual void | requestFocus () |
| virtual void | requestMoveToBottom () |
| virtual void | requestMoveToTop () |
| void | setActionEventId (std::string const &actionEventId) |
| virtual void | setBackgroundColor (Color const &color) |
| virtual void | setBaseColor (Color const &color) |
| void | setBorderBottom (unsigned int size, unsigned int style) |
| virtual void | setBorderColor (Color const &color) |
| void | setBorderSides (unsigned int sides) |
| void | setBorderSize (unsigned int size) |
| void | setBorderStyle (unsigned int style) |
| void | setBorderTop (unsigned int size, unsigned int style) |
| virtual void | setDimension (Rectangle const &dimension) |
| void | setEnabled (bool enabled) |
| void | setFixedSize (Size const &size) |
| void | setFocusable (bool focusable) |
| virtual void | setFocused (bool focused) |
| virtual void | setFont (Font *font) |
| virtual void | setForegroundColor (Color const &color) |
| virtual void | setHeight (int height) |
| void | setHorizontalExpand (bool expand) |
| void | setId (std::string const &id) |
| void | setInternalFocusHandler (FocusHandler *internalFocusHandler) |
| void | setLastPosition (int x, int y) |
| void | setMargin (int margin) |
| void | setMarginBottom (int margin) |
| void | setMarginLeft (int margin) |
| void | setMarginRight (int margin) |
| void | setMarginTop (int margin) |
| void | setMaxSize (Size const &size) |
| void | setMinSize (Size const &size) |
| virtual void | setOutlineColor (Color const &color) |
| void | setOutlineSize (unsigned int size) |
| void | setPadding (unsigned int padding) |
| void | setPaddingBottom (unsigned int padding) |
| void | setPaddingLeft (unsigned int padding) |
| void | setPaddingRight (unsigned int padding) |
| void | setPaddingTop (unsigned int padding) |
| void | setPosition (int x, int y) |
| virtual void | setSelectionColor (Color const &color) |
| virtual void | setSelectionMode (SelectionMode mode) |
| virtual void | setSize (int width, int height) |
| void | setTabInEnabled (bool enabled) |
| void | setTabOutEnabled (bool enabled) |
| void | setVerticalExpand (bool expand) |
| void | setVisible (bool visible) |
| virtual void | setWidth (int width) |
| void | setX (int x) |
| void | setY (int y) |
| virtual void | showPart (Rectangle rectangle) |
| virtual void | showWidgetPart (Widget *widget, Rectangle area) |
| Widget () | |
| Widget (Widget &&)=delete | |
| Widget (Widget const &)=delete | |
Protected Attributes | |
| bool | mClipping {true} |
| bool | mExpandChildren {false} |
| unsigned int | mFixedHeight {0} |
| unsigned int | mPadding {4} |
| unsigned int | mSpacing {4} |
| Protected Attributes inherited from fcn::Container | |
| Widget * | mBackgroundWidget {nullptr} |
| ContainerListenerList | mContainerListeners |
| unsigned int | mHorizontalSpacing {2} |
| LayoutPolicy | mLayout {LayoutPolicy::Absolute} |
| float | mOpacity {1.0F} |
| bool | mOpaque {true} |
| bool | mUniform {false} |
| unsigned int | mVerticalSpacing {2} |
| Protected Attributes inherited from fcn::Widget | |
| std::string | mActionEventId |
| std::list< ActionListener * > | mActionListeners |
| Color | mBackgroundColor {0xf9fafb} |
| Color | mBaseColor {0xe5e7eb} |
| Color | mBorderColor {0xd1d5db} |
| unsigned int | mBorderSides {BORDER_ALL} |
| unsigned int | mBorderSize {0} |
| unsigned int | mBorderStyle {BORDER_STYLE_FLAT} |
| std::list< Widget * > | mChildren |
| Font * | mCurrentFont {nullptr} |
| std::list< DeathListener * > | mDeathListeners |
| Rectangle | mDimension |
| std::list< DropTargetListener * > | mDropTargetListeners |
| bool | mEnabled {true} |
| Size | mFixedSize {-1, -1} |
| bool | mFixedSizeUsed {false} |
| bool | mFocusable {false} |
| bool | mFocused {false} |
| FocusHandler * | mFocusHandler {nullptr} |
| std::list< FocusListener * > | mFocusListeners |
| Color | mForegroundColor {0x1f2933} |
| bool | mHExpand {false} |
| std::string | mId |
| FocusHandler * | mInternalFocusHandler {nullptr} |
| std::list< KeyListener * > | mKeyListeners |
| int | mLastX {0} |
| int | mLastY {0} |
| int | mMarginBottom {0} |
| int | mMarginLeft {0} |
| int | mMarginRight {0} |
| int | mMarginTop {0} |
| Size | mMaxSize {std::numeric_limits<int>::max(), std::numeric_limits<int>::max()} |
| Size | mMinSize {0, 0} |
| std::list< MouseListener * > | mMouseListeners |
| Rectangle | mOffsetRect |
| Color | mOutlineColor {0x9ca3af} |
| unsigned int | mOutlineSize {0} |
| unsigned int | mPaddingBottom {0} |
| unsigned int | mPaddingLeft {0} |
| unsigned int | mPaddingRight {0} |
| unsigned int | mPaddingTop {0} |
| Widget * | mParent {nullptr} |
| Color | mSelectionColor {0x3b82f6} |
| SelectionMode | mSelectionMode {SelectionMode::None} |
| bool | mTabIn {true} |
| bool | mTabOut {true} |
| bool | mVExpand {false} |
| bool | mVisible {true} |
| std::list< WidgetListener * > | mWidgetListeners |
A horizontal bar container that arranges children from left to right.
This is a base class for StatusBar and MenuBar. It enforces horizontal layout policy and provides methods for controlling spacing and padding.
Definition at line 23 of file horizontalbar.hpp.
|
strong |
Alignment options for children within the bar.
Start: Left-aligned (default) Center: Center-aligned End: Right-aligned
Definition at line 33 of file horizontalbar.hpp.
| fcn::HorizontalBar::HorizontalBar | ( | ) |
Constructor.
Sets up the container with horizontal layout policy.
Definition at line 12 of file horizontalbar.cpp.
References fcn::Container::setLayout(), and fcn::Container::setOpaque().
|
overridevirtual |
Adjust the size of the container after layout computations.
Reimplemented from fcn::Container.
Definition at line 106 of file horizontalbar.cpp.
References fcn::Container::adjustSize(), fcn::Widget::getChildren(), fcn::Widget::getPaddingLeft(), fcn::Widget::getPaddingRight(), fcn::Widget::getWidth(), fcn::Widget::isHorizontalExpand(), fcn::Container::isUniformSize(), mExpandChildren, mFixedHeight, fcn::Widget::setHeight(), fcn::Widget::setHorizontalExpand(), fcn::Container::setUniformSize(), and fcn::Widget::setWidth().
|
overridevirtual |
Draws the widget.
The call to draw is initiated by the widget's parent. The graphics object is set up so that all drawing is relative to the widget, i.e coordinate (0,0) is the top left corner of the widget. It is not possible to draw outside of a widget's dimension. If a widget has children, the parent's draw function will always be called before the children's draw functions are called.
| graphics | A graphics object to draw with. |
Reimplemented from fcn::Container.
Reimplemented in fcn::MenuBar, and fcn::StatusBar.
Definition at line 142 of file horizontalbar.cpp.
References fcn::Container::draw(), fcn::Graphics::drawLine(), fcn::Graphics::fillRectangle(), fcn::Widget::getBackgroundColor(), fcn::Widget::getForegroundColor(), fcn::Widget::getHeight(), fcn::Widget::getWidth(), fcn::Container::isOpaque(), and fcn::Graphics::setColor().
| unsigned int fcn::HorizontalBar::getFixedHeight | ( | ) | const |
Gets the fixed height of the bar.
Definition at line 45 of file horizontalbar.cpp.
References mFixedHeight.
| unsigned int fcn::HorizontalBar::getPadding | ( | ) | const |
Gets the padding around the bar content.
Definition at line 35 of file horizontalbar.cpp.
References mPadding.
| unsigned int fcn::HorizontalBar::getSpacing | ( | ) | const |
Gets the spacing between children.
Definition at line 24 of file horizontalbar.cpp.
References mSpacing.
| bool fcn::HorizontalBar::isClipping | ( | ) | const |
Checks if overflowing children are clipped.
Definition at line 55 of file horizontalbar.cpp.
References mClipping.
| bool fcn::HorizontalBar::isExpandChildren | ( | ) | const |
Checks if children expand to fill available width.
Definition at line 65 of file horizontalbar.cpp.
References mExpandChildren.
|
overridevirtual |
Resize this container to fit its children.
| recursion | If true, resize children recursively. |
Reimplemented from fcn::Container.
Definition at line 70 of file horizontalbar.cpp.
References fcn::Widget::getChildren(), fcn::Widget::getPaddingLeft(), fcn::Widget::getPaddingRight(), fcn::Widget::getWidth(), fcn::Widget::isHorizontalExpand(), fcn::Container::isUniformSize(), mExpandChildren, mFixedHeight, fcn::Container::resizeToContent(), fcn::Widget::setHeight(), fcn::Widget::setHorizontalExpand(), fcn::Container::setUniformSize(), and fcn::Widget::setWidth().
| void fcn::HorizontalBar::setClipping | ( | bool | clip | ) |
Sets the overflow policy.
| clip | True to clip overflowing children, false to expand. |
Definition at line 50 of file horizontalbar.cpp.
References mClipping.
| void fcn::HorizontalBar::setExpandChildren | ( | bool | expand | ) |
Sets whether children should expand to fill available width.
When true, children are sized to fill the container width equally. When false (default), children keep their own size.
| expand | True to expand children. |
Definition at line 60 of file horizontalbar.cpp.
References mExpandChildren.
Referenced by fcn::StatusBar::StatusBar().
| void fcn::HorizontalBar::setFixedHeight | ( | unsigned int | height | ) |
Sets the default height of the bar.
| height | The height in pixels, or 0 for content-driven. |
Definition at line 40 of file horizontalbar.cpp.
References mFixedHeight.
Referenced by fcn::MenuBar::MenuBar().
| void fcn::HorizontalBar::setPadding | ( | unsigned int | padding | ) |
Sets the padding around the bar content.
| padding | The padding in pixels. |
Definition at line 30 of file horizontalbar.cpp.
References mPadding.
| void fcn::HorizontalBar::setSpacing | ( | unsigned int | spacing | ) |
Sets the spacing between children.
| spacing | The spacing in pixels. |
Definition at line 18 of file horizontalbar.cpp.
References mSpacing, and fcn::Container::setHorizontalSpacing().
|
protected |
Whether to clip overflowing content.
Definition at line 163 of file horizontalbar.hpp.
Referenced by isClipping(), and setClipping().
|
protected |
Whether children should expand to fill width.
Definition at line 168 of file horizontalbar.hpp.
Referenced by adjustSize(), isExpandChildren(), resizeToContent(), and setExpandChildren().
|
protected |
Fixed height (0 = content-driven).
Definition at line 158 of file horizontalbar.hpp.
Referenced by adjustSize(), getFixedHeight(), resizeToContent(), and setFixedHeight().
|
protected |
Padding around the bar content.
Definition at line 153 of file horizontalbar.hpp.
Referenced by getPadding(), and setPadding().
|
protected |
Spacing between children.
Definition at line 148 of file horizontalbar.hpp.
Referenced by getSpacing(), and setSpacing().