/* Copyright (c) 2021 Alex Diener This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Alex Diener alex@ludobloom.com */ #ifndef __UIStepper_H__ #define __UIStepper_H__ #ifdef __cplusplus extern "C" { #endif typedef struct UIStepper UIStepper; #define UIStepper_superclass UIElement #include "uitoolkit/UIElement.h" typedef void (* UIStepperLiveUpdateCallback)(UIStepper * stepper, int change, unsigned int modifiers, double referenceTime, void * context); typedef void (* UIStepperUpdateCompleteCallback)(UIStepper * stepper, double referenceTime, void * context); enum UIStepper_cellState { UIStepper_none, UIStepper_top, UIStepper_bottom }; // When horizontal, right is the equivalent of up/top, and left is the equivalent of down/bottom typedef enum UIStepper_orientation { STEPPER_HORIZONTAL, STEPPER_VERTICAL } UIStepper_orientation; #define UIStepper_ivars \ UIElement_ivars \ \ UIStepper_orientation orientation; \ UIStepperLiveUpdateCallback liveUpdateCallback; \ UIStepperUpdateCompleteCallback updateCompleteCallback; \ void * callbackContext; \ enum UIStepper_cellState focusedCell; \ enum UIStepper_cellState rollover; \ enum UIStepper_cellState clickInProgress; \ enum UIStepper_cellState down; \ bool upEnabled; \ bool downEnabled; \ bool repeat; \ ShellTimer repeatTimerID; \ bool allowScrollWheelInput; #define UIStepper_vtable(self_type) \ UIElement_vtable(self_type) stemobject_declare(UIStepper) UIStepper * UIStepper_create(Vector2f position, Vector2f relativeOrigin, UIStepper_orientation orientation, bool repeat, UIStepperLiveUpdateCallback liveUpdateCallback, UIStepperUpdateCompleteCallback updateCompleteCallback, void * callbackContext, UIAppearance appearance); bool UIStepper_init(UIStepper * self, Vector2f position, Vector2f relativeOrigin, UIStepper_orientation orientation, bool repeat, UIStepperLiveUpdateCallback liveUpdateCallback, UIStepperUpdateCompleteCallback updateCompleteCallback, void * callbackContext, UIAppearance appearance); void UIStepper_dispose(UIStepper * self); bool UIStepper_hitTest(UIStepper * self, float x, float y, UIHitTestType type, int * outPriority, bool * outForwardNext); UIEventResponse UIStepper_mouseDown(UIStepper * self, unsigned int buttonNumber, unsigned int buttonMask, float x, float y, unsigned int modifiers, bool isFinalTarget, double referenceTime); bool UIStepper_mouseUp(UIStepper * self, unsigned int buttonNumber, unsigned int buttonMask, float x, float y, unsigned int modifiers, double referenceTime); bool UIStepper_mouseMoved(UIStepper * self, float x, float y, float deltaX, float deltaY, unsigned int modifiers, double referenceTime); bool UIStepper_mouseDragged(UIStepper * self, unsigned int buttonMask, float x, float y, float deltaX, float deltaY, unsigned int modifiers, double referenceTime); UIEventResponse UIStepper_scrollWheel(UIStepper * self, float x, float y, int deltaX, int deltaY, unsigned int modifiers, bool isFinalTarget, double referenceTime); bool UIStepper_menuActionDown(UIStepper * self, unsigned int actionNumber, bool isRepeat, double referenceTime); bool UIStepper_menuActionUp(UIStepper * self, unsigned int actionNumber, double referenceTime); bool UIStepper_menuDirectionDown(UIStepper * self, UINavigationDirection direction, bool isRepeat, double referenceTime); bool UIStepper_setFocusedElement(UIStepper * self, compat_type(UIElement *) element, compat_type(UIElement *) fromElement, UINavigationDirection directionFromElement); bool UIStepper_acceptsFocus(UIStepper * self); Rect4f UIStepper_getBounds(UIStepper * self); Rect4f UIStepper_getFocusBounds(UIStepper * self); void UIStepper_draw(UIStepper * self, Vector2f offset, UIDrawingInterface * drawingInterface, VertexIO * vertexIO); #ifdef __cplusplus } #endif #endif