Inviwo 0.9.12-pre
Inviwo documentation
Loading...
Searching...
No Matches
inviwo::glui::Element Class Referenceabstract

graphical UI element for use in combination with Layout More...

#include <modules/userinterfacegl/glui/element.h>

Inheritance diagram for inviwo::glui::Element:

Public Types

enum class  UIState { Normal , Pressed , Checked }

Public Member Functions

 Element (const std::string &label, Processor &processor, Renderer &uiRenderer, UIOrientation orientation=UIOrientation::Horizontal)
virtual std::string_view getClassIdentifier () const =0
const ivec2 & getExtent ()
 return extent of the element, including both widget and label, and considering scaling
int getFontSize () const
const std::string & getLabel () const
UIOrientation getOrientation () const
double getScalingFactor () const
const ivec2 & getWidgetExtent () const
ivec2 getWidgetExtentScaled () const
 returns the true widget extent including scaling
bool isChecked () const
bool isDirty () const
bool isEnabled () const
bool isHovered () const
bool isLabelBold () const
bool isLabelVisible () const
bool isPushed () const
bool isVisible () const
void render (const ivec2 &origin, const size2_t &canvasDim)
 render the widget and its label at the given position
void setAction (const std::function< void()> &action)
 sets the callback action when the user releases the mouse button
void setChecked (bool checked)
void setEnabled (bool enable=true)
void setFontSize (int size)
void setHoverState (bool enable)
void setLabel (const std::string &str)
void setLabelBold (bool bold)
void setLabelVisible (bool visible=true)
void setOrientation (UIOrientation orientation)
void setPickingEventAction (std::function< void(PickingEvent *e)> pickingAction)
void setPushedState (bool pushed)
void setScalingFactor (double factor)
void setVisible (bool visible=true)
void setWidgetExtent (const ivec2 &extent)
 sets the extent of the widget
void setWidgetExtentScaled (const ivec2 &extent)
 sets the extent of the widget

Protected Member Functions

virtual ivec2 computeLabelPos (int descent) const =0
TextRenderergetCurrentTextRenderer () const
 set up text renderer for rendering the label using current settings, i.e. font size, widget scaling, and whether it should be rendered bold
void handlePickingEvent (PickingEvent *e)
virtual vec2 marginScale () const
bool moveAction (const dvec2 &delta)
 gets called on mouse move events
virtual void pushStateChanged ()
 It is called by setPushState after the internal push state has been updated.
void renderLabel (const ivec2 &origin, const size2_t &canvasDim)
virtual void renderWidget (const ivec2 &origin, const size2_t &canvasDim)=0
void setMouseMoveAction (const std::function< bool(const dvec2 &)> &action)
 set callback function for handling mouse movements based on a delta position. This callback gets called on mouse move events.
void triggerAction ()
 updates the UI state and triggers the callback action set by setAction(). This function is called when the user releases the mouse button.
virtual UIState uiState () const
void updateExtent ()
void updateLabel ()
void updateLabelPos ()
virtual void updateState ()
 is called before the action is triggered to update the internal UI state

Static Protected Member Functions

static vec4 adjustColor (const vec4 &color)

Protected Attributes

std::function< void()> action_
bool boldLabel_
bool checked_
size_t currentPickingID_
bool enabled_
ivec2 extent_ = ivec2(0)
bool hovered_
bool labelDirty_
ivec2 labelExtent_ = ivec2(0)
int labelFontSize_
ivec2 labelPos_ = ivec2(0)
std::string labelStr_
std::shared_ptr< Texture2DlabelTexture_
bool labelVisible_
std::function< bool(const dvec2 &)> moveAction_
 is called by mouseMoved()
UIOrientation orientation_
std::function< void(PickingEvent *e)> pickingAction_
PickingMapper pickingMapper_
Processorprocessor_
bool pushed_
double scalingFactor_
RendereruiRenderer_
bool visible_
ivec2 widgetExtent_ = ivec2(0)
ivec2 widgetPos_ = ivec2(0)

Detailed Description

graphical UI element for use in combination with Layout

Layout of a UI element: extent +-------------------------------------------------—+ | | | widgetExtent | | +-------—+ labelExtent | | | rendered | +--------------—+ | | | textures | | label | | | | + | +--------------—+ | | | picking | labelPos | | +-------—+ | | widgetPos | | | +-------------------------------------------------—+ (0,0)

See also
Layout, Renderer

Member Function Documentation

◆ getCurrentTextRenderer()

TextRenderer & inviwo::glui::Element::getCurrentTextRenderer ( ) const
protected

set up text renderer for rendering the label using current settings, i.e. font size, widget scaling, and whether it should be rendered bold

Returns
reference to the set-up text renderer

◆ getExtent()

const ivec2 & inviwo::glui::Element::getExtent ( )

return extent of the element, including both widget and label, and considering scaling

Returns
total element extent

◆ getWidgetExtentScaled()

ivec2 inviwo::glui::Element::getWidgetExtentScaled ( ) const

returns the true widget extent including scaling

Returns
widget extent

◆ moveAction()

bool inviwo::glui::Element::moveAction ( const dvec2 & delta)
protected

gets called on mouse move events

Parameters
deltadelta mouse position in screen coord, i.e. pixels, relative to pressed position
Returns
true if the movement triggers an update of the element

◆ render()

void inviwo::glui::Element::render ( const ivec2 & origin,
const size2_t & canvasDim )

render the widget and its label at the given position

Parameters
origindefines the lower left corner where the widget is positioned
canvasDimdimensions of the output canvas

◆ setMouseMoveAction()

void inviwo::glui::Element::setMouseMoveAction ( const std::function< bool(const dvec2 &)> & action)
protected

set callback function for handling mouse movements based on a delta position. This callback gets called on mouse move events.

Parameters
actionfunction taking one argument (2D delta position in screen coords) returning true if the movement triggers an update of the element

◆ setPickingEventAction()

void inviwo::glui::Element::setPickingEventAction ( std::function< void(PickingEvent *e)> pickingAction)

Sets a callback function for picking events to enable custom behaviors This function is called (if set) in the picking event handling after the internal event handling is done.

◆ setWidgetExtent()

void inviwo::glui::Element::setWidgetExtent ( const ivec2 & extent)

sets the extent of the widget

Parameters
extentnew extent of the widget

◆ setWidgetExtentScaled()

void inviwo::glui::Element::setWidgetExtentScaled ( const ivec2 & extent)

sets the extent of the widget

Parameters
extentnew extent of the widget (including scaling)

◆ triggerAction()

void inviwo::glui::Element::triggerAction ( )
protected

updates the UI state and triggers the callback action set by setAction(). This function is called when the user releases the mouse button.

See also
setAction

◆ updateState()

virtual void inviwo::glui::Element::updateState ( )
inlineprotectedvirtual

is called before the action is triggered to update the internal UI state

See also
triggerAction, setAction

The documentation for this class was generated from the following file:
  • modules/userinterfacegl/include/modules/userinterfacegl/glui/element.h