5#ifndef INCLUDE_FIFECHAN_GUI_HPP_
6#define INCLUDE_FIFECHAN_GUI_HPP_
16#include "fifechan/keyevent.hpp"
17#include "fifechan/mouseevent.hpp"
18#include "fifechan/mouseinput.hpp"
19#include "fifechan/platform.hpp"
100 class FIFEGUI_API Gui
107 Gui(Gui
const &) =
delete;
108 Gui& operator=(Gui
const &) =
delete;
110 Gui& operator=(Gui&&) =
delete;
127 virtual void setTop(std::unique_ptr<Widget> top);
141 virtual void setRoot(std::unique_ptr<Widget> top);
164 virtual void setGraphics(std::unique_ptr<Graphics> graphics);
188 virtual void setInput(std::unique_ptr<Input> input);
208 std::unique_ptr<Graphics> graphics, std::unique_ptr<Input> input,
int width,
int height);
223 virtual void setGlobalFont(std::string
const & filename,
int size);
232 virtual void logic();
459 virtual void distributeMouseEvent(
474 virtual void distributeKeyEvent(
KeyEvent& keyEvent);
482 virtual void distributeKeyEventToGlobalKeyListeners(
KeyEvent& keyEvent);
501 virtual Widget* getWidgetAt(
int x,
int y,
Widget* exclude);
508 virtual Widget* getMouseEventSource(
int x,
int y);
515 virtual Widget* getKeyEventSource();
524 virtual std::set<Widget*> getWidgetsAt(
int x,
int y);
Manages focus navigation and assignment among widgets within a Gui instance.
Abstract interface for font rendering.
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
Internal listener that forwards death notifications from widgets to the owning Gui so it can clean up...
Graphics * mGraphics
Holds the graphics implementation used.
Widget * mTop
Holds the top widget.
Input * mInput
Holds the input implementation used.
virtual Graphics * getGraphics() const
Gets the graphics object used for drawing.
virtual Input * getInput() const
Gets the input object being used for input handling.
virtual void handleModalMouseInputFocus()
Handles modal mouse input focus.
virtual void focusNone()
Focuses none of the widgets in the Gui.
Widget * getWidgetAt(int x, int y)
Gets the widget at a certain position.
FocusHandler * mFocusHandler
Holds the focus handler for the Gui.
virtual void setRoot(Widget *top)
Alias for setTop.
KeyListenerList mKeyListeners
Holds the global key listeners of the Gui.
bool mTabbing
True if tabbing is enabled, false otherwise.
virtual void draw()
Draws the GUI.
std::queue< Widget * > mShownWidgets
Holds shown widgets.
int mLastMouseDragButton
Holds the last button used when a drag of a widget was initiated.
virtual void handleModalFocus()
Handles modal focus.
virtual FocusHandler * getFocusHandler() const
Returns the focus handler used by this GUI.
void distributeMouseEvent(Widget *source, MouseEvent::Type type, MouseEvent::Button button, int x, int y)
Convenience overload: distribute a mouse event forwarding to the full overload with force and toSourc...
int mLastMousePressTimeStamp
Holds the last mouse press time stamp.
unsigned int mLastMousePressButton
Holds the last mouse button pressed.
virtual void handleMouseInput()
Handles all mouse input.
virtual void setGraphics(Graphics *graphics)
Sets the graphics object to use for drawing.
virtual void handleModalFocusReleased()
Handles modal focus released.
bool mControlPressed
True if control is pressed, false otherwise.
bool mMetaPressed
True if meta is pressed, false otherwise.
virtual void initialize(std::unique_ptr< Graphics > graphics, std::unique_ptr< Input > input, int width, int height)
Initializes GUI backends in one call.
std::unique_ptr< Widget > mOwnedTop
Optional owned top widget (when Gui takes ownership).
std::unique_ptr< Graphics > mOwnedGraphics
Optional owned graphics backend instance.
int mLastMouseX
Holds the last mouse x coordinate.
virtual void handleMouseWheelMovedRight(MouseInput const &mouseInput)
Handles mouse wheel moved right input.
virtual void setInput(Input *input)
Sets the input object to use for input handling.
void enqueueShownWidget(Widget *widget)
Inform gui that a widget was shown.
void distributeMouseEvent(Widget *source, MouseEvent::Type type, MouseEvent::Button button, int x, int y, bool force)
Convenience overload: forward and allow specifying force while toSourceOnly remains false.
virtual void setTabbingEnabled(bool tabbing)
Sets tabbing enabled, or not.
virtual void handleModalMouseInputFocusReleased()
Handles modal mouse input focus released.
virtual Widget * getTop() const
Gets the top widget.
virtual void handleKeyInput()
Handles key input.
virtual void handleHiddenWidgets()
Handles hidden widgets.
std::queue< Widget * > mHiddenWidgets
Holds hidden widgets.
bool mAltPressed
True if alt is pressed, false otherwise.
int mLastMouseY
Holds the last mouse y coordinate.
KeyListenerList::iterator KeyListenerListIterator
Typedef.
virtual void handleShownWidgets()
Handles shown widgets.
GuiDeathListener * mDeathListener
Listener notified when the GUI or top widget is destroyed.
virtual void handleMouseWheelMovedDown(MouseInput const &mouseInput)
Handles mouse wheel moved down input.
virtual bool isTabbingEnabled()
Checks if tabbing is enabled.
std::unique_ptr< Input > mOwnedInput
Optional owned input backend instance.
virtual void removeGlobalKeyListener(KeyListener *keyListener)
Removes global key listener from the Gui.
std::shared_ptr< Font > mGlobalFont
Shared global font used by widgets when not overridden.
virtual void handleModalMouseInputFocusGained()
Handles modal mouse input focus gained.
virtual void handleMouseMoved(MouseInput const &mouseInput)
Handles mouse moved input.
virtual void handleMouseWheelMovedUp(MouseInput const &mouseInput)
Handles mouse wheel moved up input.
virtual void addGlobalKeyListener(KeyListener *keyListener)
Adds a global key listener to the Gui.
virtual void setTop(Widget *top)
Sets the top widget.
bool mShiftPressed
True if shift is pressed, false otherwise.
void enqueueHiddenWidget(Widget *widget)
Inform gui that a widget was hidden.
virtual void setGlobalFont(std::string const &filename, int size)
Loads a font using the active graphics backend and sets it as global widget font.
virtual void handleModalFocusGained()
Handles modal focus gained.
virtual void handleMouseWheelMovedLeft(MouseInput const &mouseInput)
Handles mouse wheel moved left input.
virtual void handleMousePressed(MouseInput const &mouseInput)
Handles mouse pressed input.
void widgetDied(Widget const *widget)
Inform gui that a widget was deleted.
std::list< KeyListener * > KeyListenerList
Typedef.
virtual void logic()
Performs logic of the GUI.
int mClickCount
Holds the current click count.
VisibilityEventHandler * mVisibilityEventHandler
Holds the visibility event handler for the Gui.
virtual void handleMouseReleased(MouseInput const &mouseInput)
Handles mouse released input.
Interface for listening to keyboard events.
Button
Mouse button types.
Handles changes in widget visibility states.