Class: UINumberModifier
The UINumberModifier class provides a UI component for modifying numerical values interactively. Each segment of the component corresponds to a modifier that adjusts the value by a specified amount, with visual feedback based on a gradient.
The source file for this class is located in os/ui/UIComponents/UINumberModifier.h.
Constructorβ
UINumberModifierβ
UINumberModifier(Color color, uint8_t length, int32_t* value, int32_t* modifiers, uint8_t* control_gradient,
                 int32_t lower_limit = INT_MIN, int32_t upper_limit = INT_MAX);
Creates a new number modifier UI component.
Parameters:
colorColor: The color for the component.length(uint8_t): The number of segments in the modifier.value(int32_t*): Pointer to the integer value being modified.modifiers(int32_t*): Array of modifier values for each segment.control_gradient(uint8_t*): Array of gradient values (0β255) to scale the brightness of each segment.lower_limit(int32_t, optional): The minimum value allowed. Defaults toINT_MIN.upper_limit(int32_t, optional): The maximum value allowed. Defaults toINT_MAX.
Methodsβ
GetSizeβ
virtual Dimension GetSize();
Calculates the dimensions of the component.
Returns:
Dimension: The dimensions (widthandheight) of the component, wherewidthequalslengthandheightis1.
GetColorβ
virtual Color GetColor();
Retrieves the color of the component.
Returns:
Color: The color of the component.
Renderβ
virtual bool Render(Point origin);
Renders the component at the specified origin.
Parameters:
origin(Point): The top-left corner of the rendering area.
Returns:
bool:trueif rendering was successful.
Behavior:
- Each segment's brightness is scaled based on its corresponding gradient value.
 
KeyEventβ
virtual bool KeyEvent(Point xy, KeyInfo* keyInfo);
Handles key events to adjust the value based on the selected modifier.
Parameters:
xy(Point): The position of the event relative to the component.keyInfo(KeyInfo*): Information about the key event.
Behavior:
- Pressed: Adjusts the value by the modifier at the selected position. Clamps the result within 
lower_limitandupper_limit. 
Returns:
bool:trueto indicate the event was handled.
Comments