summaryrefslogtreecommitdiff
path: root/src/uiLibrary.h
blob: f6faf01c73c8861b9c81f1f7d6092045f541c542 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#pragma once

#include <ui.h>

#include "constants.h"

#include <font.h>

#ifndef NDEBUG
#include <stdio.h>
#define UI_LOG(...) printf("[ui] " __VA_ARGS__ "\n")
#else
#define UI_LOG
#endif

/// Input handling of scrollbars.
typedef struct uiScrollState {
  int scrollbar_handle_y_start; // y-coordinate of the scrollbar handle at the
                                // start of the scroll.
  int  table_offset_start; // Row offset of a table at the start of the scroll.
  bool scrolling;          // Whether a scrollbar is being dragged.
} uiScrollState;

/// Input handling of mouse-down events.
typedef struct uiMouseDownState {
  uiPtr   widget;      // The widget currently processing a mouse down event.
  uiPoint start_point; // Mouse position when the mouse went down.
} uiMouseDownState;

typedef struct uiLibrary {
  FontAtlas*         font;
  uiScrollState      scroll;
  uiMouseDownState   mouse_down;
  uiMouseButtonState mouse_button_state[uiMouseButtonMax];
  uiWidgetEvent      widget_events[MaxWidgetEvents];
  int                num_widget_events;
} uiLibrary;

extern uiLibrary g_ui;