/* 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 __UIPopUpMenu_H__ #define __UIPopUpMenu_H__ #ifdef __cplusplus extern "C" { #endif typedef struct UIPopUpMenu UIPopUpMenu; #define UIPopUpMenu_superclass UIElement #include "shell/Shell.h" #include "uitoolkit/UIElement.h" #include "uitoolkit/UITextListView.h" #include typedef void (* UIPopUpMenuActionCallback)(UIPopUpMenu * popUpMenu, int itemIdentifier, double referenceTime, void * context); #define POP_UP_MENU_OPEN_HIT_TEST_PRIORITY 1000 #define UIPopUpMenu_ivars \ UIElement_ivars \ \ UIPopUpMenuActionCallback actionCallback; \ void * actionCallbackContext; \ unsigned int itemCount; \ UITextListView_item * items; \ float width; \ float itemMaxWidth; \ float rowHeight; \ bool enabled; \ UIOverflowMode overflowMode; \ unsigned int selectedItemIndex; \ unsigned int highlightedItemIndex; \ UIElement * lastFocusedElement; \ bool rollover; \ bool open; \ double openTime; \ unsigned int openCenterIndex; \ unsigned int openItemCountMaxAbove; \ unsigned int openItemCountMaxBelow; \ ShellTimer scrollTimer; \ bool scrollingFast; #define UIPopUpMenu_vtable(self_type) \ UIElement_vtable(self_type) stemobject_declare(UIPopUpMenu) // Does not take ownership of items UIPopUpMenu * UIPopUpMenu_create(unsigned itemCount, struct UITextListView_item * items, Vector2f position, Vector2f relativeOrigin, float width, UIOverflowMode overflowMode, UIPopUpMenuActionCallback actionCallback, void * actionCallbackContext, UIAppearance appearance); bool UIPopUpMenu_init(UIPopUpMenu * self, unsigned int itemCount, UITextListView_item * items, Vector2f position, Vector2f relativeOrigin, float width, UIOverflowMode overflowMode, UIPopUpMenuActionCallback actionCallback, void * actionCallbackContext, UIAppearance appearance); void UIPopUpMenu_dispose(UIPopUpMenu * self); bool UIPopUpMenu_hitTest(UIPopUpMenu * self, float x, float y, UIHitTestType type, int * outPriority, bool * outForwardNext); UIEventResponse UIPopUpMenu_mouseDown(UIPopUpMenu * self, unsigned int buttonNumber, unsigned int buttonMask, float x, float y, unsigned int modifiers, bool isFinalTarget, double referenceTime); bool UIPopUpMenu_mouseUp(UIPopUpMenu * self, unsigned int buttonNumber, unsigned int buttonMask, float x, float y, unsigned int modifiers, double referenceTime); bool UIPopUpMenu_mouseMoved(UIPopUpMenu * self, float x, float y, float deltaX, float deltaY, unsigned int modifiers, double referenceTime); bool UIPopUpMenu_mouseDragged(UIPopUpMenu * self, unsigned int buttonMask, float x, float y, float deltaX, float deltaY, unsigned int modifiers, double referenceTime); UIEventResponse UIPopUpMenu_scrollWheel(UIPopUpMenu * self, float x, float y, int deltaX, int deltaY, unsigned int modifiers, bool isFinalTarget, double referenceTime); UIEventResponse UIPopUpMenu_keyDown(UIPopUpMenu * self, unsigned int charCode, unsigned int keyCode, unsigned int modifiers, bool isRepeat, bool isFinalTarget, double referenceTime); bool UIPopUpMenu_menuActionDown(UIPopUpMenu * self, unsigned int actionNumber, bool isRepeat, double referenceTime); bool UIPopUpMenu_menuActionUp(UIPopUpMenu * self, unsigned int actionNumber, double referenceTime); bool UIPopUpMenu_menuDirectionDown(UIPopUpMenu * self, UINavigationDirection direction, bool isRepeat, double referenceTime); bool UIPopUpMenu_acceptsFocus(UIPopUpMenu * self); bool UIPopUpMenu_ignoreClipForHitTest(UIPopUpMenu * self, UIHitTestType type); Rect4f UIPopUpMenu_getBounds(UIPopUpMenu * self); void UIPopUpMenu_draw(UIPopUpMenu * self, Vector2f offset, UIDrawingInterface * drawingInterface, VertexIO * vertexIO); void UIPopUpMenu_listRenderables(UIPopUpMenu * self, RenderableIO * renderableIO, int drawOrderOffset, Rect4i clipBounds); void UIPopUpMenu_setItems(UIPopUpMenu * self, unsigned int itemCount, UITextListView_item * items); bool UIPopUpMenu_setSelectedItemIdentifier(UIPopUpMenu * self, int identifier); int UIPopUpMenu_getSelectedItemIdentifier(UIPopUpMenu * self); #ifdef __cplusplus } #endif #endif