/* 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__ 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 \ \ Rect4f innerBounds; \ 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) UIScrollContainer * UIScrollContainer_create(Vector2f position, Vector2f relativeOrigin, Vector2f outerSize, Rect4f innerBounds, UIAppearance appearance); bool UIScrollContainer_init(UIScrollContainer * self, Vector2f position, Vector2f relativeOrigin, Vector2f outerSize, Rect4f innerBounds, 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); bool UIScrollContainer_mouseLeave(UIScrollContainer * self, unsigned int modifiers, double referenceTime); UIEventResponse UIScrollContainer_scrollWheel(UIScrollContainer * self, float x, float y, int scrollDeltaX, int scrollDeltaY, unsigned int buttonMask, 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); #endif