#include <button.hpp>
Classes | |
struct | error |
Public Types | |
enum | TYPE { TYPE_PRESS, TYPE_CHECK, TYPE_TURBO, TYPE_IMAGE, TYPE_RADIO } |
enum | SPACE_CONSUMPTION { DEFAULT_SPACE, MINIMUM_SPACE } |
Public Member Functions | |
TYPE | get_type () const |
button (CVideo &video, const std::string &label, TYPE type=TYPE_PRESS, std::string button_image="", SPACE_CONSUMPTION spacing=DEFAULT_SPACE, const bool auto_join=true, std::string overlay_image="") | |
virtual | ~button () |
Default implementation, but defined out-of-line for efficiency reasons. More... | |
void | set_check (bool check) |
void | set_active (bool active) |
bool | checked () const |
void | set_label (const std::string &val) |
void | set_image (const std::string &image_file_base) |
void | set_overlay (const std::string &image_file_base) |
void | set_image_path_suffix (const std::string &suffix) |
bool | pressed () |
bool | hit (int x, int y) const |
virtual void | enable (bool new_val=true) |
void | release () |
![]() | |
const SDL_Rect & | location () const |
virtual void | set_location (const SDL_Rect &rect) |
void | set_location (int x, int y) |
void | set_width (int w) |
void | set_height (int h) |
void | set_measurements (int w, int h) |
int | width () const |
int | height () const |
bool | focus (const SDL_Event *event) |
void | set_focus (bool focus) |
virtual void | hide (bool value=true) |
bool | hidden () const |
bool | enabled () const |
void | set_clip_rect (const SDL_Rect &rect) |
void | set_volatile (bool val=true) |
void | set_dirty (bool dirty=true) |
bool | dirty () const |
const std::string & | id () const |
void | set_id (const std::string &id) |
void | set_help_string (const std::string &str) |
void | set_tooltip_string (const std::string &str) |
virtual void | process_help_string (int mousex, int mousey) |
virtual void | process_tooltip_string (int mousex, int mousey) |
virtual void | draw () |
![]() | |
virtual void | process_event () |
virtual bool | requires_event_focus (const SDL_Event *=nullptr) const |
virtual void | join () |
virtual void | join (context &c) |
virtual void | join_same (sdl_handler *parent) |
virtual void | leave () |
virtual void | join_global () |
virtual void | leave_global () |
virtual bool | has_joined () |
virtual bool | has_joined_global () |
sdl_handler & | operator= (sdl_handler &&)=delete |
Moving would require two instances' context membership to be handled, it's simpler to delete these and require the two instances to be separately constructed / destructed. More... | |
sdl_handler (sdl_handler &&)=delete | |
Protected Member Functions | |
virtual void | handle_event (const SDL_Event &event) |
virtual void | mouse_motion (const SDL_MouseMotionEvent &event) |
virtual void | mouse_down (const SDL_MouseButtonEvent &event) |
virtual void | mouse_up (const SDL_MouseButtonEvent &event) |
virtual void | draw_contents () |
![]() | |
widget (CVideo &video, const bool auto_join=true) | |
virtual | ~widget () |
void | bg_register (const SDL_Rect &rect) |
void | bg_restore () const |
void | bg_restore (const SDL_Rect &rect) const |
void | bg_update () |
void | bg_cancel () |
CVideo & | video () const |
virtual void | update_location (const SDL_Rect &rect) |
const SDL_Rect * | clip_rect () const |
virtual sdl_handler_vector | member_handlers () |
virtual void | handle_window_event (const SDL_Event &event) |
bool | mouse_locked () const |
void | aquire_mouse_lock () |
void | free_mouse_lock () |
![]() | |
sdl_handler (const bool auto_join=true) | |
sdl_handler (const sdl_handler &) | |
sdl_handler & | operator= (const sdl_handler &) |
virtual | ~sdl_handler () |
virtual std::vector< sdl_handler * > | handler_members () |
Protected Attributes | |
TYPE | type_ |
![]() | |
bool | focus_ |
Private Types | |
enum | STATE { UNINIT, NORMAL, ACTIVE, PRESSED, PRESSED_ACTIVE, TOUCHED_NORMAL, TOUCHED_PRESSED } |
Private Member Functions | |
void | load_images () |
void | calculate_size () |
Private Attributes | |
std::string | label_text_ |
surface | image_ |
surface | pressedImage_ |
surface | activeImage_ |
surface | pressedActiveImage_ |
surface | touchedImage_ |
surface | disabledImage_ |
surface | pressedDisabledImage_ |
surface | overlayImage_ |
surface | overlayPressedImage_ |
surface | overlayPressedDisabledImage_ |
surface | overlayDisabledImage_ |
surface | overlayActiveImage_ |
SDL_Rect | textRect_ |
STATE | state_ |
bool | pressed_ |
SPACE_CONSUMPTION | spacing_ |
int | base_height_ |
int | base_width_ |
std::string | button_image_name_ |
std::string | button_overlay_image_name_ |
std::string | button_image_path_suffix_ |
Definition at line 24 of file button.hpp.
Enumerator | |
---|---|
DEFAULT_SPACE | |
MINIMUM_SPACE |
Definition at line 36 of file button.hpp.
|
private |
Enumerator | |
---|---|
UNINIT | |
NORMAL | |
ACTIVE | |
PRESSED | |
PRESSED_ACTIVE | |
TOUCHED_NORMAL | |
TOUCHED_PRESSED |
Definition at line 82 of file button.hpp.
enum gui::button::TYPE |
Enumerator | |
---|---|
TYPE_PRESS | |
TYPE_CHECK | |
TYPE_TURBO | |
TYPE_IMAGE | |
TYPE_RADIO |
Definition at line 33 of file button.hpp.
gui::button::button | ( | CVideo & | video, |
const std::string & | label, | ||
button::TYPE | type = TYPE_PRESS , |
||
std::string | button_image = "" , |
||
SPACE_CONSUMPTION | spacing = DEFAULT_SPACE , |
||
const bool | auto_join = true , |
||
std::string | overlay_image = "" |
||
) |
Definition at line 45 of file button.cpp.
References button_image_name_, load_images(), type_, TYPE_CHECK, TYPE_PRESS, TYPE_RADIO, and TYPE_TURBO.
|
virtual |
Default implementation, but defined out-of-line for efficiency reasons.
Definition at line 197 of file button.cpp.
|
private |
Definition at line 201 of file button.cpp.
References base_height_, base_width_, font::BUTTON_COLOR, font::draw_text(), gui::font_size, gui::horizontal_padding, i, image_, label_text_, gui::widget::location(), font::make_text_ellipsis(), MINIMUM_SPACE, font::parse_markup(), gui::widget::set_height(), gui::widget::set_location(), gui::widget::set_width(), spacing_, textRect_, type_, TYPE_IMAGE, TYPE_PRESS, TYPE_TURBO, gui::widget::video(), and w.
Referenced by load_images(), and set_label().
bool gui::button::checked | ( | ) | const |
Definition at line 286 of file button.cpp.
References PRESSED, PRESSED_ACTIVE, state_, and TOUCHED_PRESSED.
|
protectedvirtual |
Reimplemented from gui::widget.
Definition at line 304 of file button.cpp.
References ACTIVE, activeImage_, CVideo::blit_surface(), font::BUTTON_COLOR, gui::checkbox_horizontal_padding, surface::clone(), disabledImage_, font::draw_text(), gui::widget::enabled(), font::GRAY_COLOR, image_, label_text_, gui::widget::location(), overlayActiveImage_, overlayDisabledImage_, overlayImage_, overlayPressedDisabledImage_, overlayPressedImage_, PRESSED, PRESSED_ACTIVE, pressedActiveImage_, pressedDisabledImage_, pressedImage_, sdl_blit(), state_, textRect_, TOUCHED_NORMAL, TOUCHED_PRESSED, touchedImage_, type_, TYPE_CHECK, TYPE_IMAGE, TYPE_PRESS, TYPE_RADIO, and gui::widget::video().
Referenced by release(), and set_image_path_suffix().
|
virtual |
Reimplemented from gui::widget.
Definition at line 291 of file button.cpp.
References gui::widget::enable(), gui::widget::enabled(), NORMAL, pressed_, state_, type_, and TYPE_CHECK.
Referenced by gui::scrollbar::scrollbar(), gui::scrollbar::set_full_size(), set_image_path_suffix(), and gui::scrollbar::set_position().
|
inline |
Definition at line 34 of file button.hpp.
References type_.
|
protectedvirtual |
Reimplemented from gui::widget.
Definition at line 550 of file button.cpp.
References gui::widget::enabled(), gui::widget::handle_event(), gui::widget::hidden(), mouse_down(), gui::widget::mouse_locked(), mouse_motion(), mouse_up(), gui::widget::set_dirty(), and state_.
Referenced by set_image_path_suffix().
bool gui::button::hit | ( | int | x, |
int | y | ||
) | const |
Definition at line 389 of file button.cpp.
References gui::widget::location(), and sdl::point_in_rect().
Referenced by mouse_down(), mouse_motion(), mouse_up(), and set_image_path_suffix().
|
private |
Definition at line 83 of file button.cpp.
References activeImage_, base_height_, base_width_, button_image_name_, button_image_path_suffix_, button_overlay_image_name_, calculate_size(), disabledImage_, filesystem::ends_with(), ERR_DP, error(), filesystem::file_exists(), image::get_image(), h, image_, label_text_, gui::widget::location(), overlayActiveImage_, overlayDisabledImage_, overlayImage_, overlayPressedDisabledImage_, overlayPressedImage_, game_config::path, pressedActiveImage_, pressedDisabledImage_, pressedImage_, scale_surface(), set_label(), touchedImage_, type_, TYPE_CHECK, TYPE_IMAGE, TYPE_PRESS, TYPE_RADIO, TYPE_TURBO, and w.
Referenced by button(), set_image(), set_image_path_suffix(), and set_overlay().
|
protectedvirtual |
Definition at line 471 of file button.cpp.
References ACTIVE, game_config::sounds::button_press, hit(), sound::play_UI_sound(), PRESSED, PRESSED_ACTIVE, state_, TOUCHED_NORMAL, TOUCHED_PRESSED, type_, TYPE_CHECK, TYPE_RADIO, and TYPE_TURBO.
Referenced by handle_event(), and set_image_path_suffix().
|
protectedvirtual |
Definition at line 437 of file button.cpp.
References ACTIVE, hit(), NORMAL, PRESSED, PRESSED_ACTIVE, state_, TOUCHED_NORMAL, TOUCHED_PRESSED, type_, TYPE_CHECK, TYPE_IMAGE, and TYPE_RADIO.
Referenced by handle_event(), and set_image_path_suffix().
|
protectedvirtual |
Reimplemented in location_palette_button.
Definition at line 499 of file button.cpp.
References ACTIVE, game_config::sounds::button_press, game_config::sounds::checkbox_release, hit(), sound::play_UI_sound(), PRESSED, pressed_, PRESSED_ACTIVE, state_, TOUCHED_NORMAL, TOUCHED_PRESSED, type_, TYPE_CHECK, TYPE_IMAGE, TYPE_PRESS, TYPE_RADIO, and TYPE_TURBO.
Referenced by handle_event(), location_palette_button::mouse_up(), and set_image_path_suffix().
bool gui::button::pressed | ( | ) |
Definition at line 580 of file button.cpp.
References PRESSED, pressed_, PRESSED_ACTIVE, state_, TOUCHED_PRESSED, type_, and TYPE_TURBO.
Referenced by help::help_browser::process_event(), gui::scrollbar::process_event(), and set_image_path_suffix().
void gui::button::release | ( | ) |
Definition at line 494 of file button.cpp.
References draw_contents(), NORMAL, and state_.
Referenced by set_image_path_suffix().
void gui::button::set_active | ( | bool | active | ) |
Definition at line 275 of file button.cpp.
References ACTIVE, NORMAL, gui::widget::set_dirty(), and state_.
void gui::button::set_check | ( | bool | check | ) |
Definition at line 257 of file button.cpp.
References ACTIVE, NORMAL, PRESSED, PRESSED_ACTIVE, gui::widget::set_dirty(), state_, type_, TYPE_CHECK, TYPE_IMAGE, and TYPE_RADIO.
void gui::button::set_image | ( | const std::string & | image_file_base | ) |
Definition at line 396 of file button.cpp.
References button_image_name_, gui::is_valid_image(), load_images(), and gui::widget::set_dirty().
|
inline |
Definition at line 52 of file button.hpp.
References button_image_path_suffix_, draw_contents(), enable(), handle_event(), hit(), load_images(), mouse_down(), mouse_motion(), mouse_up(), pressed(), and release().
void gui::button::set_label | ( | const std::string & | val | ) |
Definition at line 419 of file button.cpp.
References calculate_size(), COLUMN_SEPARATOR, gui2::event::find(), i, gui::is_valid_image(), mp_ui_alerts::items, label_text_, gui::widget::set_dirty(), and utils::split().
Referenced by load_images().
void gui::button::set_overlay | ( | const std::string & | image_file_base | ) |
Definition at line 407 of file button.cpp.
References button_overlay_image_name_, IMAGE_PREFIX, load_images(), and gui::widget::set_dirty().
|
private |
Definition at line 76 of file button.hpp.
Referenced by draw_contents(), and load_images().
|
private |
Definition at line 89 of file button.hpp.
Referenced by calculate_size(), and load_images().
|
private |
Definition at line 89 of file button.hpp.
Referenced by calculate_size(), and load_images().
|
private |
Definition at line 91 of file button.hpp.
Referenced by button(), load_images(), and set_image().
|
private |
Definition at line 93 of file button.hpp.
Referenced by load_images(), and set_image_path_suffix().
|
private |
Definition at line 92 of file button.hpp.
Referenced by load_images(), and set_overlay().
|
private |
Definition at line 76 of file button.hpp.
Referenced by draw_contents(), and load_images().
|
private |
Definition at line 76 of file button.hpp.
Referenced by calculate_size(), draw_contents(), and load_images().
|
private |
Definition at line 74 of file button.hpp.
Referenced by calculate_size(), draw_contents(), load_images(), and set_label().
|
private |
Definition at line 76 of file button.hpp.
Referenced by draw_contents(), and load_images().
|
private |
Definition at line 76 of file button.hpp.
Referenced by draw_contents(), and load_images().
|
private |
Definition at line 76 of file button.hpp.
Referenced by draw_contents(), and load_images().
|
private |
Definition at line 76 of file button.hpp.
Referenced by draw_contents(), and load_images().
|
private |
Definition at line 76 of file button.hpp.
Referenced by draw_contents(), and load_images().
|
private |
Definition at line 85 of file button.hpp.
Referenced by enable(), mouse_up(), and pressed().
|
private |
Definition at line 76 of file button.hpp.
Referenced by draw_contents(), and load_images().
|
private |
Definition at line 76 of file button.hpp.
Referenced by draw_contents(), and load_images().
|
private |
Definition at line 76 of file button.hpp.
Referenced by draw_contents(), and load_images().
|
private |
Definition at line 87 of file button.hpp.
Referenced by calculate_size().
|
private |
Definition at line 83 of file button.hpp.
Referenced by checked(), draw_contents(), enable(), handle_event(), mouse_down(), mouse_motion(), mouse_up(), pressed(), release(), set_active(), and set_check().
|
private |
Definition at line 80 of file button.hpp.
Referenced by calculate_size(), and draw_contents().
|
private |
Definition at line 76 of file button.hpp.
Referenced by draw_contents(), and load_images().
|
protected |
Definition at line 66 of file button.hpp.
Referenced by button(), calculate_size(), draw_contents(), enable(), get_type(), load_images(), mouse_down(), mouse_motion(), mouse_up(), pressed(), and set_check().