/* 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 __UIScrollContainer_H__ #define __UIScrollContainer_H__ #ifdef __cplusplus extern "C" { #endif typedef struct UIScrollContainer UIScrollContainer; #define UIScrollContainer_superclass UIContainer #include "uitoolkit/UIContainer.h" enum UIScrollContainer_dragState { DRAG_STATE_NONE, DRAG_STATE_VERTICAL, DRAG_STATE_HORIZONTAL, DRAG_STATE_PAN }; enum UIScrollContainer_scrollbar { SCROLLBAR_NONE, SCROLLBAR_VERTICAL, SCROLLBAR_HORIZONTAL }; #define UIScrollContainer_ivars \ UIContainer_ivars \ \ Vector2f innerRelativeOrigin; \ Vector2f innerSize; \ float scrollUnitSize; \ bool drawBorder; \ bool useRoundedScrollbar; \ bool useMiniScrollbar; \ bool allowChildScrollEvents; \ bool panWithLeftMouseButton; \ Vector2f scrollPosition; \ enum UIScrollContainer_dragState dragState; \ enum UIScrollContainer_scrollbar mouseoverScrollbar; \ Vector2f dragStartPosition; \ Vector2f dragStartScrollPosition; #define UIScrollContainer_vtable(self_type) \ UIContainer_vtable(self_type) \ \ void (* scrollToInnerRect)(self_type * self, Rect4f rect); stemobject_declare(UIScrollContainer) // outerRelativeOrigin determines which direction the visible portion of this UIScrollContainer extends from its position. // innerRelativeOrigin determines which corner of the partially-hidden portion of this UIScrollContainer contents are // anchored to. For example, if innerRelativeOrigin is set to VECTOR2f(1, 1), contained element x and y coordinates will // start at {0, 0} in the upper right corner of the scroll area, and negative x and y values run left and down respectively. // UICONTAINER_NO_CENTER must not be used for either outerRelativeOrigin or innerRelativeOrigin. UIScrollContainer * UIScrollContainer_create(Vector2f position, Vector2f outerRelativeOrigin, Vector2f innerRelativeOrigin, Vector2f outerSize, Vector2f innerSize, UIAppearance appearance); bool UIScrollContainer_init(UIScrollContainer * self, Vector2f position, Vector2f outerRelativeOrigin, Vector2f innerRelativeOrigin, Vector2f outerSize, Vector2f innerSize, UIAppearance appearance); void UIScrollContainer_dispose(UIScrollContainer * self); bool UIScrollContainer_hitTest(UIScrollContainer * self, float x, float y, UIHitTestType type, int * outPriority, bool * outForwardNext); void UIScrollContainer_hitTestList(UIScrollContainer * self, float x, float y, UIHitTestType type, int priorityOffset, UIHitTestResultIO * resultIO); UIEventResponse UIScrollContainer_mouseDown(UIScrollContainer * self, unsigned int buttonNumber, unsigned int buttonMask, float x, float y, unsigned int modifiers, bool isFinalTarget, double referenceTime); bool UIScrollContainer_mouseUp(UIScrollContainer * self, unsigned int buttonNumber, unsigned int buttonMask, float x, float y, unsigned int modifiers, double referenceTime); bool UIScrollContainer_mouseMoved(UIScrollContainer * self, float x, float y, float deltaX, float deltaY, unsigned int modifiers, double referenceTime); bool UIScrollContainer_mouseDragged(UIScrollContainer * self, unsigned int buttonMask, float x, float y, float deltaX, float deltaY, unsigned int modifiers, double referenceTime); UIEventResponse UIScrollContainer_scrollWheel(UIScrollContainer * self, float x, float y, int deltaX, int deltaY, unsigned int modifiers, bool isFinalTarget, double referenceTime); Rect4f UIScrollContainer_getBounds(UIScrollContainer * self); Rect4f UIScrollContainer_getClipBounds(UIScrollContainer * self); Vector2f UIScrollContainer_getRelativeOffset(UIScrollContainer * self); void UIScrollContainer_listRenderables(UIScrollContainer * self, RenderableIO * renderableIO, int drawOrderOffset, Rect4i clipBounds); void UIScrollContainer_draw(UIScrollContainer * self, Vector2f offset, UIDrawingInterface * drawingInterface, VertexIO * vertexIO); void UIScrollContainer_scrollToInnerRect(UIScrollContainer * self, Rect4f rect); #ifdef __cplusplus } #endif #endif