Freeciv-3.2: /fast/freeciv/nightly/S3_2/client/gui-sdl3/widget_scrollbar.c File Reference

Freeciv-3.2

Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
widget_scrollbar.c File Reference
`#include <SDL3/SDL.h>`
`#include "log.h"`
`#include "colors.h"`
`#include "graphics.h"`
`#include "gui_id.h"`
`#include "gui_tilespec.h"`
`#include "mapview.h"`
`#include "themespec.h"`
`#include "widget.h"`
`#include "widget_p.h"`

Go to the source code of this file.

## Data Structures

struct | up_down

## Macros

#define | widget_add_next(new_widget, add_dock)

## Functions

static SDL_Surface * | create_vertical_surface (SDL_Surface *vert_theme, enum widget_state state, Uint16 height)
static int | redraw_vert (struct widget *vert)
struct widget * | create_vertical (SDL_Surface *vert_theme, struct gui_layer *pdest, Uint16 height, Uint32 flags)
int | draw_vert (struct widget *vert, Sint16 x, Sint16 y)
static SDL_Surface * | create_horizontal_surface (SDL_Surface *horiz_theme, enum widget_state state, Uint16 width)
static int | redraw_horiz (struct widget *horiz)
struct widget * | create_horizontal (SDL_Surface *horiz_theme, struct gui_layer *pdest, Uint16 width, Uint32 flags)
int | draw_horiz (struct widget *horiz, Sint16 x, Sint16 y)
static int | get_step (struct scroll_bar *scroll)
static int | get_position (struct advanced_dialog *dlg)
static struct widget * | up_scroll_widget_list (struct scroll_bar *vscroll, struct widget *begin_active_widget_list, struct widget *begin_widget_list, struct widget *end_widget_list)
static struct widget * | down_scroll_widget_list (struct scroll_bar *vscroll, struct widget *begin_active_widget_list, struct widget *begin_widget_list, struct widget *end_widget_list)
static struct widget * | vertic_scroll_widget_list (struct scroll_bar *vscroll, struct widget *begin_active_widget_list, struct widget *begin_widget_list, struct widget *end_widget_list)
static int | std_up_advanced_dlg_callback (struct widget *pwidget)
static int | std_down_advanced_dlg_callback (struct widget *pwidget)
static int | std_vscroll_advanced_dlg_callback (struct widget *pscroll_bar)
Uint32 | create_vertical_scrollbar (struct advanced_dialog *dlg, Uint8 step, Uint8 active, bool create_scrollbar, bool create_buttons)
void | setup_vertical_scrollbar_area (struct scroll_bar *scroll, Sint16 start_x, Sint16 start_y, Uint16 height, bool swap_start_x)
static struct widget * | vertical_scroll_widget_list (struct widget *active_widget_list, struct widget *begin_widget_list, struct widget *end_widget_list, int active, int step, int dir)
static void | inside_scroll_down_loop (void *data)
static void | inside_scroll_up_loop (void *data)
static Uint16 | scroll_mouse_motion_handler (SDL_MouseMotionEvent *motion_event, void *data)
static Uint16 | scroll_mouse_button_up (SDL_MouseButtonEvent *button_event, void *data)
bool | add_widget_to_vertical_scroll_widget_list (struct advanced_dialog *dlg, struct widget *new_widget, struct widget *add_dock, bool dir, Sint16 start_x, Sint16 start_y)
bool | del_widget_from_vertical_scroll_widget_list (struct advanced_dialog *dlg, struct widget *pwidget)
void | setup_vertical_scrollbar_default_callbacks (struct scroll_bar *scroll)
Uint32 | create_horizontal_scrollbar (struct advanced_dialog *dlg, Sint16 start_x, Sint16 start_y, Uint16 width, Uint16 active, bool create_scrollbar, bool create_buttons, bool swap_start_y)

## Variables

static int(* | baseclass_redraw )(struct widget *pwidget)

## Macro Definition Documentation

## ◆ widget_add_next

#define widget_add_next | ( |  | new_widget,
|  |  | add_dock
| ) |  |

Value:
do { \
new_widget->prev = add_dock; \
new_widget->next = add_dock->next; \
if (add_dock->next) { \
add_dock->next->prev = new_widget; \
} \
add_dock->next = new_widget; \
} while (FALSE)
incite_cost
char * incite_cost
Definition comments.c:74
FALSE
#define FALSE
Definition support.h:47

Definition at line 48 of file widget_scrollbar.c.

## Function Documentation

## ◆ add_widget_to_vertical_scroll_widget_list()

bool add_widget_to_vertical_scroll_widget_list | ( | struct advanced_dialog * | dlg,
|  | struct widget * | new_widget,
|  | struct widget * | add_dock,
|  | bool | dir,
|  | Sint16 | start_x,
|  | Sint16 | start_y
| ) |  |

Add new widget to scrolled list and set draw position of all changed widgets. dir : TRUE - upper add => add_dock->next = new_widget. FALSE - down add => add_dock->prev = new_widget. start_x, start_y - positions of first seen widget (active_widget_list). dlg->scroll ( scrollbar ) must exist. It isn't full secure to multi widget list.

Definition at line 1142 of file widget_scrollbar.c.

Referenced by add_global_worklist(), add_new_worklist_callback(), add_target_to_worklist(), add_to_chat_list(), popup_load_game_dialog(), real_conn_list_dialog_update(), real_meswin_dialog_update(), set_global_worklist(), and update_clauses_list().

## ◆ create_horizontal()

struct widget * create_horizontal | ( | SDL_Surface * | horiz_theme,
|  | struct gui_layer * | pdest,
|  | Uint16 | width,
|  | Uint32 | flags
| ) |  |

Create ( malloc ) horizontal scroll_bar widget structure.

Theme graphic is taken from horiz_theme surface;

This function determinate future size of horizontal scroll_bar ( width = 'width', height = 'horiz_theme->h' ) and save this in: pwidget->size rectangle ( SDL_Rect )

Return pointer to created widget.

Definition at line 292 of file widget_scrollbar.c.

## ◆ create_horizontal_scrollbar()

Uint32 create_horizontal_scrollbar | ( | struct advanced_dialog * | dlg,
|  | Sint16 | start_x,
|  | Sint16 | start_y,
|  | Uint16 | width,
|  | Uint16 | active,
|  | bool | create_scrollbar,
|  | bool | create_buttons,
|  | bool | swap_start_y
| ) |  |

Create a new horizontal scrollbar to active widgets list.

Definition at line 1541 of file widget_scrollbar.c.

## ◆ create_horizontal_surface()

static SDL_Surface * create_horizontal_surface | ( | SDL_Surface * | horiz_theme,
|  | enum widget_state | state,
|  | Uint16 | width
| ) |  |

static

Create background image for hscrollbars then return pointer to this image.

Graphic is taken from horiz_theme surface and blit to new created image.

Definition at line 202 of file widget_scrollbar.c.

## ◆ create_vertical()

struct widget * create_vertical | ( | SDL_Surface * | vert_theme,
|  | struct gui_layer * | pdest,
|  | Uint16 | height,
|  | Uint32 | flags
| ) |  |

Create ( malloc ) vertical scroll_bar widget structure.

Theme graphic is taken from vert_theme surface;

This function determinate future size of vertical scroll_bar ( width = 'vert_theme->w', height = 'height' ) and save this in: pwidget->size rectangle ( SDL_Rect )

Return pointer to created widget.

Definition at line 160 of file widget_scrollbar.c.

## ◆ create_vertical_scrollbar()

Uint32 create_vertical_scrollbar | ( | struct advanced_dialog * | dlg,
|  | Uint8 | step,
|  | Uint8 | active,
|  | bool | create_scrollbar,
|  | bool | create_buttons
| ) |  |

Create a new vertical scrollbar to active widgets list.

Definition at line 482 of file widget_scrollbar.c.

## ◆ create_vertical_surface()

static SDL_Surface * create_vertical_surface | ( | SDL_Surface * | vert_theme,
|  | enum widget_state | state,
|  | Uint16 | height
| ) |  |

static

Create background image for vscrollbars, then return pointer to that image.

Graphic is taken from vert_theme surface and blit to new created image.

Definition at line 70 of file widget_scrollbar.c.

## ◆ del_widget_from_vertical_scroll_widget_list()

bool del_widget_from_vertical_scroll_widget_list | ( | struct advanced_dialog * | dlg,
|  | struct widget * | pwidget
| ) |  |

Delete widget from scrolled list and set draw position of all changed widgets. Don't free dlg and dlg->scroll (if exist) It is full secure for multi widget list case.

Definition at line 1340 of file widget_scrollbar.c.

Referenced by edit_worklist_callback(), ok_sell_impr_callback(), real_units_report_dialog_update(), remove_clause_widget_from_list(), remove_item_from_worklist(), sell_imprvm_dlg_ok_callback(), and set_global_worklist().

## ◆ down_scroll_widget_list()

static struct widget * down_scroll_widget_list | ( | struct scroll_bar * | vscroll,
|  | struct widget * | begin_active_widget_list,
|  | struct widget * | begin_widget_list,
|  | struct widget * | end_widget_list
| ) |  |

static

Scroll widgets down.

Definition at line 1050 of file widget_scrollbar.c.

## ◆ draw_horiz()

int draw_horiz | ( | struct widget * | horiz,
|  | Sint16 | x,
|  | Sint16 | y
| ) |  |

Draw horizontal scrollbar.

Definition at line 316 of file widget_scrollbar.c.

## ◆ draw_vert()

int draw_vert | ( | struct widget * | vert,
|  | Sint16 | x,
|  | Sint16 | y
| ) |  |

Draw vertical scrollbar.

Definition at line 183 of file widget_scrollbar.c.

## ◆ get_position()

static int get_position | ( | struct advanced_dialog * | dlg | ) |

static

Get current active position of the scrollbar.

Definition at line 348 of file widget_scrollbar.c.

## ◆ get_step()

static int get_step | ( | struct scroll_bar * | scroll | ) |

static

Get step of the scrollbar.

Definition at line 332 of file widget_scrollbar.c.

## ◆ inside_scroll_down_loop()

static void inside_scroll_down_loop | ( | void * | data | ) |

static

Callback for the scroll-down event loop.

Definition at line 864 of file widget_scrollbar.c.

## ◆ inside_scroll_up_loop()

static void inside_scroll_up_loop | ( | void * | data | ) |

static

Callback for the scroll-up event loop.

Definition at line 911 of file widget_scrollbar.c.

## ◆ redraw_horiz()

static int redraw_horiz | ( | struct widget * | horiz | ) |

static

Blit horizontal scrollbar gfx to surface its on.

Definition at line 260 of file widget_scrollbar.c.

## ◆ redraw_vert()

static int redraw_vert | ( | struct widget * | vert | ) |

static

Blit vertical scrollbar gfx to surface its on.

Definition at line 128 of file widget_scrollbar.c.

## ◆ scroll_mouse_button_up()

static Uint16 scroll_mouse_button_up | ( | SDL_MouseButtonEvent * | button_event,
|  | void * | data
| ) |  |

static

Callback for scrollbar event loops' mouse up events.

Definition at line 1041 of file widget_scrollbar.c.

## ◆ scroll_mouse_motion_handler()

static Uint16 scroll_mouse_motion_handler | ( | SDL_MouseMotionEvent * | motion_event,
|  | void * | data
| ) |  |

static

Handle mouse motion events of the vertical scrollbar event loop.

Definition at line 953 of file widget_scrollbar.c.

## ◆ setup_vertical_scrollbar_area()

void setup_vertical_scrollbar_area | ( | struct scroll_bar * | scroll,
|  | Sint16 | start_x,
|  | Sint16 | start_y,
|  | Uint16 | height,
|  | bool | swap_start_x
| ) |  |

Setup area for the vertical scrollbar.

Definition at line 563 of file widget_scrollbar.c.

## ◆ setup_vertical_scrollbar_default_callbacks()

void setup_vertical_scrollbar_default_callbacks | ( | struct scroll_bar * | scroll | ) |

Set default vertical scrollbar handling for scrollbar.

Definition at line 1518 of file widget_scrollbar.c.

## ◆ std_down_advanced_dlg_callback()

static int std_down_advanced_dlg_callback | ( | struct widget * | pwidget | ) |

static

User interacted with down button of advanced dialog.

Definition at line 428 of file widget_scrollbar.c.

## ◆ std_up_advanced_dlg_callback()

static int std_up_advanced_dlg_callback | ( | struct widget * | pwidget | ) |

static

User interacted with up button of advanced dialog.

Definition at line 401 of file widget_scrollbar.c.

## ◆ std_vscroll_advanced_dlg_callback()

static int std_vscroll_advanced_dlg_callback | ( | struct widget * | pscroll_bar | ) |

static

FIXME : fix main funct : vertic_scroll_widget_list(...)

Definition at line 455 of file widget_scrollbar.c.

## ◆ up_scroll_widget_list()

static struct widget * up_scroll_widget_list | ( | struct scroll_bar * | vscroll,
|  | struct widget * | begin_active_widget_list,
|  | struct widget * | begin_widget_list,
|  | struct widget * | end_widget_list
| ) |  |

static

Scroll widgets up.

Definition at line 1079 of file widget_scrollbar.c.

## ◆ vertic_scroll_widget_list()

static struct widget * vertic_scroll_widget_list | ( | struct scroll_bar * | vscroll,
|  | struct widget * | begin_active_widget_list,
|  | struct widget * | begin_widget_list,
|  | struct widget * | end_widget_list
| ) |  |

static

Scroll vertical widget list with the mouse movement.

Definition at line 1101 of file widget_scrollbar.c.

## ◆ vertical_scroll_widget_list()

static struct widget * vertical_scroll_widget_list | ( | struct widget * | active_widget_list,
|  | struct widget * | begin_widget_list,
|  | struct widget * | end_widget_list,
|  | int | active,
|  | int | step,
|  | int | dir
| ) |  |

static

Scroll pointers on list. dir == directions: up == -1, down == 1.

Definition at line 629 of file widget_scrollbar.c.

## Variable Documentation

## ◆ baseclass_redraw

int(* baseclass_redraw) (struct widget *pwidget) | ( | struct widget * | pwidget | ) |

static

Definition at line 58 of file widget_scrollbar.c.