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
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interfacestatic interfacestatic classstatic classstatic classstatic classNested classes/interfaces inherited from class heronarts.glx.ui.UI2dComponent
UI2dComponent.Scissor, UI2dComponent.Scissored, UI2dComponent.UIDragReorderNested classes/interfaces inherited from interface heronarts.glx.ui.UIContextActions
UIContextActions.ContextAction -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected UIColorprotected booleanprotected UIColorprotected booleanprotected booleanFields inherited from class heronarts.glx.ui.component.UIParameterComponent
DEFAULT_HEIGHT, useCommandEngineFields inherited from class heronarts.glx.ui.UI2dComponent
borderRoundingBottomLeft, borderRoundingBottomRight, borderRoundingTopLeft, borderRoundingTopRight, debug, debugName, hasBorderRounding, height, marginBottom, marginLeft, marginRight, marginTop, redraw, scissor, textAlignHorizontal, textAlignVertical, textOffsetX, textOffsetY, width, x, y -
Constructor Summary
ConstructorsConstructorDescriptionUIButton()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 TypeMethodDescriptionvoiddispose()Objects are encouraged to override this method providing a helpful String displayed to the user explaining the function of this UI component.protected BooleanParameterprotected BooleanParameterbooleanisActive()protected voidonBlur()Subclasses override when element loses focusprotected voidonClick()Subclasses may override when a momentary button is clicked, and the click release happened within the bounds of the boxprotected voidSubclasses should override this method to perform their drawing functions.protected voidonKeyPressed(KeyEvent keyEvent, char keyChar, int keyCode) Subclasses override to receive key eventsprotected voidonKeyReleased(KeyEvent keyEvent, char keyChar, int keyCode) Subclasses override to receive key eventsprotected voidonMouseDragged(MouseEvent mouseEvent, float mx, float my, float dx, float dy) Subclasses override to receive mouse eventsprotected voidonMousePressed(MouseEvent mouseEvent, float mx, float my) Subclasses override to receive mouse eventsprotected voidonMouseReleased(MouseEvent mouseEvent, float mx, float my) Subclasses override to receive mouse eventsprotected voidonToggle(boolean active) Subclasses may override this to handle changes to the button's statesetActive(boolean active) protected UIButtonsetActive(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) setEnumIcon(UIButton.EnumIcon enumIcon) setIcon(VGraphics.Image icon) setIconColor(boolean iconColor) setIconColor(int iconColor) setIconColor(UIColor iconColor) setIconLabel(String iconLabel) setIconOffset(float iconOffsetX, float iconOffsetY) setIconOffsetX(float iconOffsetX) setIconOffsetY(float iconOffsetY) setInactiveColor(int inactiveColor) setInactiveColor(UIColor inactiveColor) setInactiveFontColor(int inactiveFontColor) Sets the inactive font colorsetInactiveFontColor(UIColor inactiveFontColor) Sets the inactive font colorsetInactiveIcon(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, setUseCommandEngineMethods inherited from class heronarts.glx.ui.UI2dComponent
addAfterSibling, addBeforeSibling, addToContainer, addToContainer, addToContainer, addToContainer, addToContainer, addToContainer, addToContainer, addToContainer, assertValidContainer, clipTextToWidth, clipTextToWidth, contains, dbch, drawBackground, drawBorder, drawComponentBackground, drawFocus, drawFocusCorners, drawFocusCorners, drawParentBackground, getAbsoluteX, getAbsoluteY, getBackgroundColor, getBorderColor, getBorderWeight, getBottomMargin, getContainer, getDebugClassHierarchy, getDebugClassHierarchy, getFocusColor, getFocusSize, getFont, getFontColor, getHeight, getLeftMargin, getMappableParameter, getNextSibling, getNextSibling, getParent, getPrevSibling, getPrevSibling, getRightMargin, getTopMargin, 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, vgRoundedRectMethods inherited from class heronarts.glx.ui.UIObject
addListener, addListener, addLoopTask, addLoopTask, blur, bringToFront, focus, getFocusedChild, getLX, getUI, hasDirectFocus, hasFocus, isVisible, isVisible, loop, onFocus, onUIResize, removeLoopTask, requireUIThread, setConsumeMousePress, setDebugId, setMouseCursor, toggleVisible, toStringMethods inherited from class heronarts.glx.ui.UIEventHandler
onGamepadAxisChanged, onGamepadButtonPressed, onGamepadButtonReleased, 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
-
setInactiveFontColor
Sets the inactive font color- Parameters:
inactiveFontColor- color- Returns:
- this
-
setInactiveFontColor
Sets the inactive font color- Parameters:
inactiveFontColor- color- Returns:
- this
-
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:UIObjectObjects 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:
getDescriptionin classUIObject- Returns:
- Helpful contextual string explaining function of this element
-
getParameter
- Specified by:
getParameterin classUIParameterComponent
-
removeParameter
-
setParameter
-
setEnumIcon
-
setEnumFormatter
-
setParameter
-
setMomentary
-
setIconOffset
-
setIconOffsetX
-
setIconOffsetY
-
onDraw
Description copied from class:UI2dComponentSubclasses should override this method to perform their drawing functions.- Overrides:
onDrawin classUI2dComponent- Parameters:
ui- UI contextvg- Graphics context
-
onBlur
protected void onBlur()Description copied from class:UIObjectSubclasses override when element loses focus -
onMouseDragged
Description copied from class:UIEventHandlerSubclasses override to receive mouse events- Overrides:
onMouseDraggedin classUIEventHandler- Parameters:
mouseEvent- Mouse eventmx- x-coordinatemy- y-coordinatedx- movement in xdy- movement in y
-
onMousePressed
Description copied from class:UIEventHandlerSubclasses override to receive mouse events- Overrides:
onMousePressedin classUIParameterComponent- Parameters:
mouseEvent- Mouse eventmx- x-coordinatemy- y-coordinate
-
onMouseReleased
Description copied from class:UIEventHandlerSubclasses override to receive mouse events- Overrides:
onMouseReleasedin classUIParameterComponent- Parameters:
mouseEvent- Mouse eventmx- x-coordinatemy- y-coordinate
-
onKeyPressed
Description copied from class:UIEventHandlerSubclasses override to receive key events- Overrides:
onKeyPressedin classUIEventHandler- Parameters:
keyEvent- Key eventkeyChar- Key characterkeyCode- Key code value
-
onKeyReleased
Description copied from class:UIEventHandlerSubclasses override to receive key events- Overrides:
onKeyReleasedin 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
-
setIconLabel
-
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:
getControlTargetin interfaceUIControlTarget
-
getTriggerSource
- Specified by:
getTriggerSourcein interfaceUITriggerSource
-
getTriggerTarget
- Specified by:
getTriggerTargetin interfaceUITriggerTarget
-
getTriggerSourceParameter
-
getTriggerTargetParameter
-
dispose
public void dispose()
-