Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-sdl2/gui_main.h Source File

Freeciv-3.1

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/* SDL2 */
26#ifdef SDL2_PLAIN_INCLUDE
27#include <SDL.h>
28#else /* SDL2_PLAIN_INCLUDE */
29#include <SDL2/SDL.h>
30#endif /* SDL2_PLAIN_INCLUDE */
31
32/* client/include */
33#include "gui_main_g.h"
34
35struct theme;
36
37/* Enable this to adjust sizes for 320x240 resolution */
38/* #define SMALL_SCREEN */
39
40/* SDL2 client Flags */
41#define CF_NONE 0
42#define CF_ORDERS_WIDGETS_CREATED (1<<0)
43#define CF_MAP_UNIT_W_CREATED (1<<1)
44#define CF_UNITINFO_SHOWN (1<<2)
45#define CF_OVERVIEW_SHOWN (1<<3)
46#define CF_GAME_JUST_STARTED (1<<6)
47
48#define CF_FOCUS_ANIMATION (1<<9)
49#define CF_CHANGED_PROD (1<<10)
50#define CF_CHANGED_CITY_NAME (1<<11)
51#define CF_CITY_STATUS_SPECIAL (1<<12)
52#define CF_CHANGE_TAXRATE_LUX_BLOCK (1<<13)
53#define CF_CHANGE_TAXRATE_SCI_BLOCK (1<<14)
54#define CF_DRAW_CITY_GRID (1<<17)
55#define CF_DRAW_CITY_WORKER_GRID (1<<18)
56#define CF_DRAW_PLAYERS_WAR_STATUS (1<<19)
57#define CF_DRAW_PLAYERS_CEASEFIRE_STATUS (1<<20)
58#define CF_DRAW_PLAYERS_PEACE_STATUS (1<<21)
59#define CF_DRAW_PLAYERS_ALLIANCE_STATUS (1<<22)
60#define CF_DRAW_PLAYERS_NEUTRAL_STATUS (1<<23)
61#define CF_SWRENDERER (1<<24)
62
63/* Mouse button behavior */
64#define MB_MEDIUM_HOLD_DELAY 500 /* Medium hold: 500ms */
65#define MB_LONG_HOLD_DELAY 2000 /* Long hold: 2000ms */
66
67/* Predicate for detecting basic widget activation events. */
68#define PRESSED_EVENT(event) ( \
69 (event).type == SDL_KEYDOWN \
70 || (event).type == SDL_FINGERDOWN \
71 || ((event).type == SDL_MOUSEBUTTONDOWN \
72 && (event).button.button == SDL_BUTTON_LEFT))
73
74 enum mouse_button_hold_state {
75 MB_HOLD_SHORT,
76 MB_HOLD_MEDIUM,
77 MB_HOLD_LONG
78};
79
80 struct finger_behavior {
81 bool counting;
82 Uint32 finger_down_ticks;
83 enum mouse_button_hold_state hold_state;
84 SDL_TouchFingerEvent event;
85 struct tile *ptile;
86};
87
88 struct mouse_button_behavior {
89 bool counting;
90 Uint32 button_down_ticks;
91 enum mouse_button_hold_state hold_state;
92 SDL_MouseButtonEvent *event;
93 struct tile *ptile;
94};
95
96extern struct widget *selected_widget;
97extern Uint32 sdl2_client_flags;
98extern bool LSHIFT;
99extern bool RSHIFT;
100extern bool LCTRL;
101extern bool RCTRL;
102extern bool LALT;
103extern int *client_font_sizes[]; /* indexed by enum client_font */
104
105void force_exit_from_event_loop(void);
106void enable_focus_animation(void);
107void disable_focus_animation(void);
108
109
110#define DEFAULT_MOVE_STEP 5
111 extern int MOVE_STEP_X, MOVE_STEP_Y;
112int FilterMouseMotionEvents(void *data, SDL_Event *event);
113
114 Uint16 gui_event_loop(void *data, void (*loop_action)(void *data),
115 Uint16 (*key_down_handler)(SDL_Keysym key, void *data),
116 Uint16 (*key_up_handler)(SDL_Keysym key, void *data),
117 Uint16 (*textinput_handler)(char *text, void *data),
118 Uint16 (*finger_down_handler)(SDL_TouchFingerEvent *touch_event, void *data),
119 Uint16 (*finger_up_handler)(SDL_TouchFingerEvent *touch_event, void *data),
120 Uint16 (*finger_motion_handler)(SDL_TouchFingerEvent *touch_event,
121 void *data),
122 Uint16 (*mouse_button_down_handler)(SDL_MouseButtonEvent *button_event,
123 void *data),
124 Uint16 (*mouse_button_up_handler)(SDL_MouseButtonEvent *button_event,
125 void *data),
126 Uint16 (*mouse_motion_handler)(SDL_MouseMotionEvent *motion_event,
127 void *data));
128
129unsigned default_font_size(struct theme *act_theme);
130void update_font_from_theme(int theme_font_size);
131
132bool flush_event(void);
133
134/* Shrink sizes for 320x240 screen */
135#ifdef SMALL_SCREEN
136 #define adj_size(size) ((size) / 2)
137#else
138 #define adj_size(size) (size)
139#endif
140
141#endif /* FC__GUI_MAIN_H */
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:572
enable_focus_animation
void enable_focus_animation(void)
Definition gui_main.c:1177
flush_event
bool flush_event(void)
Definition gui_main.c:1321
mouse_button_hold_state
mouse_button_hold_state
Definition gui_main.h:74
MB_HOLD_LONG
@ MB_HOLD_LONG
Definition gui_main.h:77
MB_HOLD_MEDIUM
@ MB_HOLD_MEDIUM
Definition gui_main.h:76
MB_HOLD_SHORT
@ MB_HOLD_SHORT
Definition gui_main.h:75
RSHIFT
bool RSHIFT
Definition gui_main.c:105
MOVE_STEP_Y
int MOVE_STEP_Y
Definition gui_main.h:111
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:593
update_font_from_theme
void update_font_from_theme(int theme_font_size)
Definition gui_main.c:1304
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:1295
force_exit_from_event_loop
void force_exit_from_event_loop(void)
Definition gui_main.c:556
disable_focus_animation
void disable_focus_animation(void)
Definition gui_main.c:1186
client_font_sizes
int * client_font_sizes[]
Definition gui_main.c:111
sdl2_client_flags
Uint32 sdl2_client_flags
Definition gui_main.c:97
MOVE_STEP_X
int MOVE_STEP_X
Definition gui_main.c:100
RCTRL
bool RCTRL
Definition gui_main.c:107
gui_main_g.h
finger_behavior
Definition gui_main.h:80
finger_behavior::finger_down_ticks
Uint32 finger_down_ticks
Definition gui_main.h:82
finger_behavior::counting
bool counting
Definition gui_main.h:81
finger_behavior::ptile
struct tile * ptile
Definition gui_main.h:85
finger_behavior::event
SDL_TouchFingerEvent event
Definition gui_main.h:84
finger_behavior::hold_state
enum mouse_button_hold_state hold_state
Definition gui_main.h:83
mouse_button_behavior
Definition gui_main.h:88
mouse_button_behavior::hold_state
enum mouse_button_hold_state hold_state
Definition gui_main.h:91
mouse_button_behavior::counting
bool counting
Definition gui_main.h:89
mouse_button_behavior::button_down_ticks
Uint32 button_down_ticks
Definition gui_main.h:90
mouse_button_behavior::event
SDL_MouseButtonEvent * event
Definition gui_main.h:92
mouse_button_behavior::ptile
struct tile * ptile
Definition gui_main.h:93
theme
Definition themespec.c:133
tile
Definition tile.h:49
widget
Definition widget.h:112
widget::key
SDL_Keycode key
Definition widget.h:153
widget::data
union widget::@214 data
widget::cont
struct container * cont
Definition widget.h:127