JMgui
Loading...
Searching...
No Matches
DropDown Class Reference

An expandable dropdown list of buttons. More...

#include <JMgui.h>

Inheritance diagram for DropDown:
GuiElement

Public Member Functions

 DropDown (float PosX, float PosY, float Length, std::string Title)
void render ()
 draw the element to the buffer. Override this to make the element custom.
std::string addItem (std::string name)
 Add an item to the dropdown menu. Returns the name that was assigned, as duplicate names are not allowed.
bool addItemEventListener (std::string itemName, std::function< void(JMeventDispatcher::Event *)> func)
 Add an event listener for when a specific item is clicked. Returns true if successful.
Public Member Functions inherited from GuiElement
 GuiElement (float PosX, float PosY, float SizeX, float SizeY)
 GuiElement (GuiElement &)=delete
GuiElementoperator= (const GuiElement &)=delete
 GuiElement (GuiElement &&)=default
GuiElementoperator= (GuiElement &&)=default
virtual void setup (GuiElementHandler *Handler)
virtual void setup (JMwindow *Window)
float width () const
float height () const
float xPos () const
float yPos () const
void setPosition (float x, float y)
void setSize (float x, float y)
void setSizeX (float x)
void setSizeY (float y)
bool mouseOver () const
 returns true if the mouse is over the element.
float localMouseX () const
 Returns the mouse position relative to the bottom left corner of the element.
float localMouseY () const
 Returns the mouse position relative to the bottom left corner of the element.
bool clicked () const
 returns true if the mouse is over the element and the left button is pressed and released.
bool rightClicked () const
 returns true if the mouse is over the element and the right button is pressed and released.
bool pressed () const
 returns true if the mouse is over the element and the left button is pressed.
virtual void display ()
 is called by the element handler to display the element on the screen.
int renderLayer ()

Additional Inherited Members

Public Attributes inherited from GuiElement
float dispTitleX = 0.0f
float dispTitleY = 0.0f
bool allowInput = true
 used to prevent user input to this element if needed.
bool forceAllowInput = false
 if true, when the element handlers allowInput is set to false, this element will be exempt.
bool hide = false
 the element is not updated or displayed if true
bool constantUpdate = false
 Set this to true to re-render the element every frame. By default, the element is only re-rendered when animating (mouse over animation and pressed animation).
bool staticElement = false
 if true, the element will only be rendered for the startup animation or if the window is resized, then displayed staticly. User input will not work.
bool reRender = false
 If set to true, the element is re-rendered once, then this is set to false.
std::string helpMessage = ""
 The help message that displays when the mouse is hovered over the object.
JMwindowwindow = nullptr
 the window that this element is drawn to.
ClickEventevent_clicked = nullptr
RightClickEventevent_rightClicked = nullptr
std::string displayTitle = ""
Protected Member Functions inherited from GuiElement
void registerEvent (JMeventDispatcher::Event *event)
 adds an event to the window's event handler.
Protected Attributes inherited from GuiElement
int RenderLayer = 0
GuiElementHandlerhandler = nullptr
 the handler object that this element is drawn by.
JMGraphics * gr = nullptr
 the graphics object of the parent window. use this objects graphics functions to draw the ui element.
JMGraphics::Buffer * graphicsBuffer = nullptr
 the element is drawn to a graphics buffer so that the graphics only have to be generated when nescecary, and still displayed on the screen every frame.
JMGraphics::Font * dispTitleFont = nullptr
 The font used to render the title.
float posX = 0.0f
float posY = 0.0f
float sizeX = 0.0f
float sizeY = 0.0f
glm::vec2 dispTitleSize = glm::vec2(0.0f, 0.0f)
 stores the physical size of the displayed title
float dispTitleScale = 1.0f
 sets the physical size of the title
float anim_start = 0.0f
 use to create a startup animation. Increases from 0.0f to 1.0f over time when the element is first displayed.
float anim_mouseOver = 0.0f
 use to create a mouse over animation. Increases from 0.0f to 1.0f over time when the mouse is over the element.
float anim_pressed = 0.0f
 use to create a pressed animation. Increases from 0.0f to 1.0f over time when the element is pressed with the mouse.
float anim_clicked = 0.0f
 use to create a clicked animation. When the element is clicked, it will be set to 1.0f, then decrease to 0.0f over time.
bool fixedX = false
 If true, the element cannot be resized on the x axis.
bool fixedY = false
 If true, the element cannot be resized on the y axis.

Detailed Description

An expandable dropdown list of buttons.

Member Function Documentation

◆ render()

void DropDown::render ( )
virtual

draw the element to the buffer. Override this to make the element custom.

Reimplemented from GuiElement.


The documentation for this class was generated from the following file: