/* Copyright (c) 2023 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 __UIContinuousSlider_H__ #define __UIContinuousSlider_H__ typedef struct UIContinuousSlider UIContinuousSlider; #define UIContinuousSlider_superclass UIElement #include "uitoolkit/UIElement.h" typedef enum UIContinuousSlider_axis { UIContinuousSlider_X = 0x1, UIContinuousSlider_Y = 0x2, UIContinuousSlider_XY = 0x3 } UIContinuousSlider_axis; typedef void (* UIContinuousSliderCallback)(UIContinuousSlider * slider, Vector2f value, Vector2f offset, Vector2f totalOffset, double referenceTime, void * context); #define UIContinuousSlider_ivars \ UIElement_ivars \ \ Vector2f value; \ UIContinuousSlider_axis axis; \ Vector2f size; \ UIContinuousSliderCallback changeCallback; \ UIContinuousSliderCallback changeCompleteCallback; \ void * callbackContext; \ float dragRatio; \ float preciseDragMultiplier; \ float scrollWheelMultiplier; \ float gridSpacing; \ Vector2f totalOffset; \ bool changed; #define UIContinuousSlider_vtable(self_type) \ UIElement_vtable(self_type) stemobject_declare(UIContinuousSlider) UIContinuousSlider * UIContinuousSlider_create(Vector2f value, Vector2f position, Vector2f relativeOrigin, Vector2f size, UIContinuousSlider_axis axis, UIContinuousSliderCallback changeCallback, UIContinuousSliderCallback changeCompleteCallback, void * callbackContext, UIAppearance appearance); bool UIContinuousSlider_init(UIContinuousSlider * self, Vector2f value, Vector2f position, Vector2f relativeOrigin, Vector2f size, UIContinuousSlider_axis axis, UIContinuousSliderCallback changeCallback, UIContinuousSliderCallback changeCompleteCallback, void * callbackContext, UIAppearance appearance); void UIContinuousSlider_dispose(UIContinuousSlider * self); bool UIContinuousSlider_hitTest(UIContinuousSlider * self, float x, float y, UIHitTestType type, int * outPriority, bool * outForwardNext); UIEventResponse UIContinuousSlider_mouseDown(UIContinuousSlider * self, unsigned int buttonNumber, unsigned int buttonMask, float x, float y, unsigned int modifiers, bool isFinalTarget, double referenceTime); bool UIContinuousSlider_mouseUp(UIContinuousSlider * self, unsigned int buttonNumber, unsigned int buttonMask, float x, float y, unsigned int modifiers, double referenceTime); bool UIContinuousSlider_mouseDragged(UIContinuousSlider * self, unsigned int buttonMask, float x, float y, float deltaX, float deltaY, unsigned int modifiers, double referenceTime); UIEventResponse UIContinuousSlider_scrollWheel(UIContinuousSlider * self, float x, float y, int deltaX, int deltaY, unsigned int modifiers, bool isFinalTarget, double referenceTime); Rect4f UIContinuousSlider_getBounds(UIContinuousSlider * self); void UIContinuousSlider_draw(UIContinuousSlider * self, Vector2f offset, UIDrawingInterface * drawingInterface, VertexIO * vertexIO); #endif