Freeciv-3.2: /fast/freeciv/nightly/S3_2/client/gui-sdl3/gui_main.h Source File

Freeciv-3.2

Loading...
Searching...
No Matches
gui_main.h
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14/***********************************************************************
15 gui_main.h - description
16 -------------------
17 begin : Sep 6 2002
18 copyright : (C) 2002 by Rafał Bursig
19 email : Rafał Bursig <bursig@poczta.fm>
20***********************************************************************/
21
22#ifndef FC__GUI_MAIN_H
23#define FC__GUI_MAIN_H
24
25/* SDL3 */
26#include <SDL3/SDL.h>
27
28/* client/include */
29#include "gui_main_g.h"
30
31struct theme;
32
33#define GUI_SDL_OPTION(optname) gui_options.gui_sdl3_##optname
34#define GUI_SDL_OPTION_STR(optname) "gui_sdl3_" #optname
35
36/* Enable this to adjust sizes for 320x240 resolution */
37/* #define SMALL_SCREEN */
38
39/* SDL3 client Flags */
40#define CF_NONE 0
41#define CF_ORDERS_WIDGETS_CREATED (1<<0)
42#define CF_MAP_UNIT_W_CREATED (1<<1)
43#define CF_UNITINFO_SHOWN (1<<2)
44#define CF_OVERVIEW_SHOWN (1<<3)
45#define CF_GAME_JUST_STARTED (1<<6)
46
47#define CF_FOCUS_ANIMATION (1<<9)
48#define CF_CHANGED_PROD (1<<10)
49#define CF_CHANGED_CITY_NAME (1<<11)
50#define CF_CITY_STATUS_SPECIAL (1<<12)
51#define CF_CHANGE_TAXRATE_LUX_BLOCK (1<<13)
52#define CF_CHANGE_TAXRATE_SCI_BLOCK (1<<14)
53#define CF_DRAW_CITY_GRID (1<<17)
54#define CF_DRAW_CITY_WORKER_GRID (1<<18)
55#define CF_DRAW_PLAYERS_WAR_STATUS (1<<19)
56#define CF_DRAW_PLAYERS_CEASEFIRE_STATUS (1<<20)
57#define CF_DRAW_PLAYERS_PEACE_STATUS (1<<21)
58#define CF_DRAW_PLAYERS_ALLIANCE_STATUS (1<<22)
59#define CF_DRAW_PLAYERS_NEUTRAL_STATUS (1<<23)
60#define CF_SWRENDERER (1<<24)
61
62/* Mouse button behavior */
63#define MB_MEDIUM_HOLD_DELAY 500 /* Medium hold: 500ms */
64#define MB_LONG_HOLD_DELAY 2000 /* Long hold: 2000ms */
65
66/* Predicate for detecting basic widget activation events. */
67#define PRESSED_EVENT(event) ( \
68 (event).type == SDL_EVENT_KEY_DOWN \
69 || (event).type == SDL_EVENT_FINGER_DOWN \
70 || ((event).type == SDL_EVENT_MOUSE_BUTTON_DOWN \
71 && (event).button.button == SDL_BUTTON_LEFT))
72
73 enum mouse_button_hold_state {
74 MB_HOLD_SHORT,
75 MB_HOLD_MEDIUM,
76 MB_HOLD_LONG
77};
78
79struct finger_behavior {
80 bool counting;
81 Uint32 finger_down_ticks;
82 enum mouse_button_hold_state hold_state;
83 SDL_TouchFingerEvent event;
84 struct tile *ptile;
85};
86
87struct mouse_button_behavior {
88 bool counting;
89 Uint32 button_down_ticks;
90 enum mouse_button_hold_state hold_state;
91 SDL_MouseButtonEvent *event;
92 struct tile *ptile;
93};
94
95extern struct widget *selected_widget;
96extern Uint32 sdl3_client_flags;
97extern bool LSHIFT;
98extern bool RSHIFT;
99extern bool LCTRL;
100extern bool RCTRL;
101extern bool LALT;
102extern int *client_font_sizes[]; /* indexed by enum client_font */
103
104void force_exit_from_event_loop(void);
105void enable_focus_animation(void);
106void disable_focus_animation(void);
107
108
109#define DEFAULT_MOVE_STEP 5
110 extern int MOVE_STEP_X, MOVE_STEP_Y;
111int FilterMouseMotionEvents(void *data, SDL_Event *event);
112
113 Uint16 gui_event_loop(void *data, void (*loop_action)(void *data),
114 Uint16 (*key_down_handler)(SDL_Keysym key, void *data),
115 Uint16 (*key_up_handler)(SDL_Keysym key, void *data),
116 Uint16 (*textinput_handler)(char *text, void *data),
117 Uint16 (*finger_down_handler)(SDL_TouchFingerEvent *touch_event, void *data),
118 Uint16 (*finger_up_handler)(SDL_TouchFingerEvent *touch_event, void *data),
119 Uint16 (*finger_motion_handler)(SDL_TouchFingerEvent *touch_event,
120 void *data),
121 Uint16 (*mouse_button_down_handler)(SDL_MouseButtonEvent *button_event,
122 void *data),
123 Uint16 (*mouse_button_up_handler)(SDL_MouseButtonEvent *button_event,
124 void *data),
125 Uint16 (*mouse_motion_handler)(SDL_MouseMotionEvent *motion_event,
126 void *data));
127
128unsigned default_font_size(struct theme *act_theme);
129void update_font_from_theme(int theme_font_size);
130
131bool flush_event(void);
132
133/* Shrink sizes for 320x240 screen */
134#ifdef SMALL_SCREEN
135 #define adj_size(size) ((size) / 2)
136#else
137 #define adj_size(size) (size)
138#endif
139
140#endif /* FC__GUI_MAIN_H */
incite_cost
char * incite_cost
Definition comments.c:74
event
enum event_type event
Definition events.c:81
LSHIFT
bool LSHIFT
Definition gui_main.c:104
FilterMouseMotionEvents
int FilterMouseMotionEvents(void *data, SDL_Event *event)
Definition gui_main.c:577
enable_focus_animation
void enable_focus_animation(void)
Definition gui_main.c:1187
flush_event
bool flush_event(void)
Definition gui_main.c:1332
mouse_button_hold_state
mouse_button_hold_state
Definition gui_main.h:77
MB_HOLD_LONG
@ MB_HOLD_LONG
Definition gui_main.h:80
MB_HOLD_MEDIUM
@ MB_HOLD_MEDIUM
Definition gui_main.h:79
MB_HOLD_SHORT
@ MB_HOLD_SHORT
Definition gui_main.h:78
RSHIFT
bool RSHIFT
Definition gui_main.c:105
MOVE_STEP_Y
int MOVE_STEP_Y
Definition gui_main.h:114
selected_widget
struct widget * selected_widget
Definition widget.c:48
gui_event_loop
Uint16 gui_event_loop(void *data, void(*loop_action)(void *data), Uint16(*key_down_handler)(SDL_Keysym key, void *data), Uint16(*key_up_handler)(SDL_Keysym key, void *data), Uint16(*textinput_handler)(char *text, void *data), Uint16(*finger_down_handler)(SDL_TouchFingerEvent *touch_event, void *data), Uint16(*finger_up_handler)(SDL_TouchFingerEvent *touch_event, void *data), Uint16(*finger_motion_handler)(SDL_TouchFingerEvent *touch_event, void *data), Uint16(*mouse_button_down_handler)(SDL_MouseButtonEvent *button_event, void *data), Uint16(*mouse_button_up_handler)(SDL_MouseButtonEvent *button_event, void *data), Uint16(*mouse_motion_handler)(SDL_MouseMotionEvent *motion_event, void *data))
Definition gui_main.c:598
update_font_from_theme
void update_font_from_theme(int theme_font_size)
Definition gui_main.c:1315
LALT
bool LALT
Definition gui_main.c:108
LCTRL
bool LCTRL
Definition gui_main.c:106
default_font_size
unsigned default_font_size(struct theme *act_theme)
Definition gui_main.c:1305
force_exit_from_event_loop
void force_exit_from_event_loop(void)
Definition gui_main.c:561
disable_focus_animation
void disable_focus_animation(void)
Definition gui_main.c:1196
client_font_sizes
int * client_font_sizes[]
Definition gui_main.c:111
MOVE_STEP_X
int MOVE_STEP_X
Definition gui_main.c:100
RCTRL
bool RCTRL
Definition gui_main.c:107
sdl3_client_flags
Uint32 sdl3_client_flags
Definition gui_main.c:93
gui_main_g.h
finger_behavior
Definition gui_main.h:83
finger_behavior::finger_down_ticks
Uint32 finger_down_ticks
Definition gui_main.h:85
finger_behavior::ptile
struct tile * ptile
Definition gui_main.h:88
finger_behavior::counting
bool counting
Definition gui_main.h:84
finger_behavior::event
SDL_TouchFingerEvent event
Definition gui_main.h:87
finger_behavior::hold_state
enum mouse_button_hold_state hold_state
Definition gui_main.h:86
mouse_button_behavior
Definition gui_main.h:91
mouse_button_behavior::hold_state
enum mouse_button_hold_state hold_state
Definition gui_main.h:94
mouse_button_behavior::event
SDL_MouseButtonEvent * event
Definition gui_main.h:95
mouse_button_behavior::counting
bool counting
Definition gui_main.h:92
mouse_button_behavior::ptile
struct tile * ptile
Definition gui_main.h:96
mouse_button_behavior::button_down_ticks
Uint32 button_down_ticks
Definition gui_main.h:93
theme
Definition themespec.c:133
tile
Definition tile.h:50
widget
Definition widget.h:112
widget::key
SDL_Keycode key
Definition widget.h:153
widget::data
union widget::@192 data