Package heronarts.glx.ui.component
Class UIButton
java.lang.Object
heronarts.glx.ui.UIEventHandler
heronarts.glx.ui.UIObject
heronarts.glx.ui.UI2dComponent
heronarts.glx.ui.component.UIParameterComponent
heronarts.glx.ui.component.UIButton
- All Implemented Interfaces:
UIContextActions
,UIControlTarget
,UIFocus
,UIKeyFocus
,UIMouseFocus
,UITabFocus
,UITriggerSource
,UITriggerTarget
,LXLoopTask
- Direct Known Subclasses:
UIButton.Action
,UIButton.Toggle
,UIButton.Tooltip
,UIButton.Trigger
,UIMappingButton
public class UIButton
extends UIParameterComponent
implements UIControlTarget, UITriggerSource, UITriggerTarget, UIFocus
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static interface
static class
static class
static class
static class
Nested classes/interfaces inherited from class heronarts.glx.ui.UI2dComponent
UI2dComponent.Scissor, UI2dComponent.Scissored, UI2dComponent.UIDragReorder
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected UIColor
protected boolean
protected UIColor
protected boolean
protected boolean
Fields inherited from class heronarts.glx.ui.component.UIParameterComponent
DEFAULT_HEIGHT, useCommandEngine
Fields inherited from class heronarts.glx.ui.UI2dComponent
debug, debugName, height, marginBottom, marginLeft, marginRight, marginTop, redraw, scissor, textAlignHorizontal, textAlignVertical, textOffsetX, textOffsetY, width, x, y
-
Constructor Summary
ConstructorDescriptionUIButton()
UIButton
(float w, float h) UIButton
(float x, float y, float w, float h) UIButton
(float x, float y, float w, float h, BooleanParameter p) UIButton
(float x, float y, float w, float h, EnumParameter<?> p) UIButton
(float w, float h, BooleanParameter p) UIButton
(float w, float h, EnumParameter<?> p) UIButton
(float w, BooleanParameter p) UIButton
(float w, EnumParameter<?> p) -
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
Objects are encouraged to override this method providing a helpful String displayed to the user explaining the function of this UI component.protected BooleanParameter
protected BooleanParameter
boolean
isActive()
protected void
onBlur()
Subclasses override when element loses focusprotected void
onClick()
Subclasses may override when a momentary button is clicked, and the click release happened within the bounds of the boxprotected void
Subclasses should override this method to perform their drawing functions.protected void
onKeyPressed
(KeyEvent keyEvent, char keyChar, int keyCode) Subclasses override to receive key eventsprotected void
onKeyReleased
(KeyEvent keyEvent, char keyChar, int keyCode) Subclasses override to receive key eventsprotected void
onMouseDragged
(MouseEvent mouseEvent, float mx, float my, float dx, float dy) Subclasses override to receive mouse eventsprotected void
onMousePressed
(MouseEvent mouseEvent, float mx, float my) Subclasses override to receive mouse eventsprotected void
onMouseReleased
(MouseEvent mouseEvent, float mx, float my) Subclasses override to receive mouse eventsprotected void
onToggle
(boolean active) Subclasses may override this to handle changes to the button's statesetActive
(boolean active) protected UIButton
setActive
(boolean active, boolean pushToParameter) setActiveColor
(int activeColor) setActiveColor
(UIColor activeColor) setActiveFontColor
(int activeFontColor) Sets the active font colorsetActiveFontColor
(UIColor activeFontColor) Sets the active font colorsetActiveIcon
(VGraphics.Image activeIcon) setActiveLabel
(String activeLabel) setControlSource
(LXNormalizedParameter controlSource) Sets an explicit control source for the button, which may or may not match its other parameter behavior.setControlTarget
(LXNormalizedParameter controlTarget) Sets an explicit control target for the button, which may or may not match its other parameter behavior.setEnabled
(boolean enabled) setEnumFormatter
(UIButton.EnumFormatter formatter) setIcon
(VGraphics.Image icon) setIconColor
(boolean iconColor) setIconColor
(int iconColor) setIconColor
(UIColor iconColor) setIconOffset
(float iconOffsetX, float iconOffsetY) setIconOffsetX
(float iconOffsetX) setIconOffsetY
(float iconOffsetY) setInactiveColor
(int inactiveColor) setInactiveColor
(UIColor inactiveColor) setInactiveIcon
(VGraphics.Image inactiveIcon) setInactiveLabel
(String inactiveLabel) setMomentary
(boolean momentary) setParameter
(BooleanParameter parameter) setParameter
(EnumParameter<? extends Object> parameter) setTriggerable
(boolean triggerable) toggle()
Methods inherited from class heronarts.glx.ui.component.UIParameterComponent
getContextActions, getOscAddress, setEnableContextActions, setModulationRangeCommand, setNormalizedCommand, setUseCommandEngine
Methods inherited from class heronarts.glx.ui.UI2dComponent
addToContainer, addToContainer, addToContainer, addToContainer, addToContainer, addToContainer, addToContainer, addToContainer, assertValidContainer, clipTextToWidth, clipTextToWidth, contains, dbch, drawBackground, drawBorder, drawFocus, drawFocusCorners, drawFocusCorners, drawParentBackground, getAbsoluteX, getAbsoluteY, getBackgroundColor, getBorderColor, getBorderWeight, getContainer, getDebugClassHierarchy, getDebugClassHierarchy, getFocusColor, getFocusSize, getFont, getFontColor, getHeight, getMappableParameter, getNextSibling, getParent, getPrevSibling, getWidth, getX, getY, hasBackground, hasBorder, hasFont, hasFontColor, isMappable, onResize, redraw, removeFromContainer, removeFromContainer, setBackground, setBackgroundColor, setBackgroundColor, setBorder, setBorderColor, setBorderColor, setBorderRounding, setBorderRounding, setBorderWeight, setBottomMargin, setContainerIndex, setContainerPosition, setDebug, setDebug, setDescription, setFocusBackground, setFocusBackgroundColor, setFocusBackgroundColor, setFocusColor, setFocusColor, setFocusCorners, setFont, setFontColor, setFontColor, setFontColor, setHeight, setLeftMargin, setMappable, setMargin, setMargin, setMargin, setPosition, setPosition, setPosition, setPosition, setRightMargin, setSize, setTextAlignment, setTextAlignment, setTextOffset, setTopMargin, setVisible, setWidth, setX, setY, vgRoundedRect, vgRoundedRect, vgRoundedRect
Methods inherited from class heronarts.glx.ui.UIObject
addListener, addListener, addLoopTask, blur, bringToFront, focus, getFocusedChild, getLX, getUI, hasDirectFocus, hasFocus, isVisible, loop, onFocus, onUIResize, removeLoopTask, requireUIThread, setConsumeMousePress, setDebugId, toggleVisible, toString
Methods inherited from class heronarts.glx.ui.UIEventHandler
onMouseMoved, onMouseOut, onMouseOver, onMouseScroll
-
Field Details
-
active
protected boolean active -
isMomentary
protected boolean isMomentary -
inactiveColor
-
activeColor
-
enabled
protected boolean enabled -
momentaryPressValid
protected boolean momentaryPressValid
-
-
Constructor Details
-
UIButton
public UIButton() -
UIButton
-
UIButton
-
UIButton
-
UIButton
-
UIButton
-
UIButton
-
UIButton
public UIButton(float w, float h) -
UIButton
public UIButton(float x, float y, float w, float h)
-
-
Method Details
-
setActiveFontColor
Sets the active font color- Parameters:
activeFontColor
- color- Returns:
- this
-
setActiveFontColor
Sets the active font color- Parameters:
activeFontColor
- color- Returns:
- this
-
setEnabled
-
setTriggerable
-
setIconColor
-
setIconColor
-
setIconColor
-
getDescription
Description copied from class:UIObject
Objects are encouraged to override this method providing a helpful String displayed to the user explaining the function of this UI component. If no help is available, return null rather than an empty String.- Overrides:
getDescription
in classUIObject
- Returns:
- Helpful contextual string explaining function of this element
-
getParameter
- Specified by:
getParameter
in classUIParameterComponent
-
removeParameter
-
setParameter
-
setEnumFormatter
-
setParameter
-
setMomentary
-
setIconOffset
-
setIconOffsetX
-
setIconOffsetY
-
onDraw
Description copied from class:UI2dComponent
Subclasses should override this method to perform their drawing functions.- Overrides:
onDraw
in classUI2dComponent
- Parameters:
ui
- UI contextvg
- Graphics context
-
onBlur
protected void onBlur()Description copied from class:UIObject
Subclasses override when element loses focus -
onMouseDragged
Description copied from class:UIEventHandler
Subclasses override to receive mouse events- Overrides:
onMouseDragged
in classUIEventHandler
- Parameters:
mouseEvent
- Mouse eventmx
- x-coordinatemy
- y-coordinatedx
- movement in xdy
- movement in y
-
onMousePressed
Description copied from class:UIEventHandler
Subclasses override to receive mouse events- Overrides:
onMousePressed
in classUIParameterComponent
- Parameters:
mouseEvent
- Mouse eventmx
- x-coordinatemy
- y-coordinate
-
onMouseReleased
Description copied from class:UIEventHandler
Subclasses override to receive mouse events- Overrides:
onMouseReleased
in classUIParameterComponent
- Parameters:
mouseEvent
- Mouse eventmx
- x-coordinatemy
- y-coordinate
-
onKeyPressed
Description copied from class:UIEventHandler
Subclasses override to receive key events- Overrides:
onKeyPressed
in classUIEventHandler
- Parameters:
keyEvent
- Key eventkeyChar
- Key characterkeyCode
- Key code value
-
onKeyReleased
Description copied from class:UIEventHandler
Subclasses override to receive key events- Overrides:
onKeyReleased
in classUIEventHandler
- Parameters:
keyEvent
- Key eventkeyChar
- Key characterkeyCode
- Key code value
-
isActive
public boolean isActive() -
setActive
-
setActive
-
toggle
-
onToggle
protected void onToggle(boolean active) Subclasses may override this to handle changes to the button's state- Parameters:
active
- Whether button is active
-
onClick
protected void onClick()Subclasses may override when a momentary button is clicked, and the click release happened within the bounds of the box -
setActiveColor
-
setActiveColor
-
setInactiveColor
-
setInactiveColor
-
setLabel
-
setActiveLabel
-
setInactiveLabel
-
setIcon
-
setActiveIcon
-
setInactiveIcon
-
setControlSource
Sets an explicit control source for the button, which may or may not match its other parameter behavior. Useful for buttons that need to perform a custom LXCommand rather than explicitly change parameter value, but still should be mappable for modulation and MIDI.- Parameters:
controlSource
- Control source- Returns:
- this
-
setControlTarget
Sets an explicit control target for the button, which may or may not match its other parameter behavior. Useful for buttons that need to perform a custom LXCommand rather than explicitly change parameter value, but still should be mappable for modulation and MIDI.- Parameters:
controlTarget
- Control target- Returns:
- this
-
getControlTarget
- Specified by:
getControlTarget
in interfaceUIControlTarget
-
getTriggerSource
- Specified by:
getTriggerSource
in interfaceUITriggerSource
-
getTriggerTarget
- Specified by:
getTriggerTarget
in interfaceUITriggerTarget
-
getTriggerSourceParameter
-
getTriggerTargetParameter
-
dispose
public void dispose()
-