#include <tristate_button.hpp>
Classes | |
struct | error |
Public Types | |
enum | PRESSED_STATE { LEFT , RIGHT , BOTH , NONE } |
Public Member Functions | |
tristate_button (editor::tristate_palette *palette, std::string button_image="", const bool auto_join=true) | |
virtual | ~tristate_button () |
Default implementation, but defined out-of-line for efficiency reasons. More... | |
void | set_pressed (PRESSED_STATE new_pressed_state) |
bool | pressed () |
PRESSED_STATE | pressed_state () const |
bool | hit (int x, int y) const |
virtual void | enable (bool new_val=true) override |
void | release () |
void | set_item_image (const texture &base, const texture &over=texture()) |
void | set_item_id (const std::string &id) |
Public Member Functions inherited from gui::widget | |
const 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 | queue_redraw () |
Indicate that the widget should be redrawn. More... | |
void | queue_redraw (const rect &) |
Indicate that a specific region of the screen should be redrawn. More... | |
void | set_dirty (bool dirty=true) |
bool | dirty () const |
const std::string & | id () const |
void | set_id (const std::string &id) |
void | set_tooltip_string (const std::string &str) |
virtual void | process_tooltip_string (int mousex, int mousey) override |
virtual void | layout () override |
Called by draw_manager to validate layout. More... | |
virtual bool | expose (const rect ®ion) override |
Called by draw_manager when it believes a redraw is necessary. More... | |
virtual rect | screen_location () override |
The current draw location of the display, on the screen. More... | |
Public Member Functions inherited from events::sdl_handler | |
virtual void | handle_window_event (const SDL_Event &) |
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 | |
Public Member Functions inherited from gui2::top_level_drawable | |
virtual void | update () |
Update state and any parameters that may effect layout, or any of the later stages. More... | |
virtual void | render () |
Perform any internal rendering necessary to prepare the drawable. More... | |
Protected Member Functions | |
virtual void | handle_event (const SDL_Event &event) override |
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 () override |
Protected Member Functions inherited from gui::widget | |
widget (const bool auto_join=true) | |
virtual | ~widget () |
virtual void | update_location (const SDL_Rect &) |
bool | mouse_locked () const |
void | aquire_mouse_lock () |
void | free_mouse_lock () |
Protected Member Functions inherited from events::sdl_handler | |
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 Member Functions inherited from gui2::top_level_drawable | |
top_level_drawable () | |
virtual | ~top_level_drawable () |
top_level_drawable (const top_level_drawable &) | |
top_level_drawable & | operator= (const top_level_drawable &) |
top_level_drawable (top_level_drawable &&) | |
top_level_drawable & | operator= (top_level_drawable &&) |
Private Types | |
enum | STATE { UNINIT , NORMAL , ACTIVE , PRESSED_ACTIVE_LEFT , PRESSED_ACTIVE_RIGHT , PRESSED_ACTIVE_BOTH , TOUCHED_RIGHT , TOUCHED_BOTH_RIGHT , TOUCHED_BOTH_LEFT , TOUCHED_LEFT , PRESSED_LEFT , PRESSED_RIGHT , PRESSED_BOTH } |
Private Member Functions | |
void | calculate_size () |
Additional Inherited Members | |
Protected Attributes inherited from gui::widget | |
bool | focus_ |
Definition at line 27 of file tristate_button.hpp.
Enumerator | |
---|---|
LEFT | |
RIGHT | |
BOTH | |
NONE |
Definition at line 38 of file tristate_button.hpp.
|
private |
Enumerator | |
---|---|
UNINIT | |
NORMAL | |
ACTIVE | |
PRESSED_ACTIVE_LEFT | |
PRESSED_ACTIVE_RIGHT | |
PRESSED_ACTIVE_BOTH | |
TOUCHED_RIGHT | |
TOUCHED_BOTH_RIGHT | |
TOUCHED_BOTH_LEFT | |
TOUCHED_LEFT | |
PRESSED_LEFT | |
PRESSED_RIGHT | |
PRESSED_BOTH |
Definition at line 92 of file tristate_button.hpp.
gui::tristate_button::tristate_button | ( | editor::tristate_palette * | palette, |
std::string | button_image = "" , |
||
const bool | auto_join = true |
||
) |
Definition at line 32 of file tristate_button.cpp.
References activeBaseImage_, base_height_, base_width_, baseImage_, image::get_texture(), texture::h(), pressedBothActiveImage_, pressedBothImage_, pressedDownActiveImage_, pressedDownImage_, pressedUpActiveImage_, pressedUpImage_, touchedBaseImage_, touchedBothImage_, touchedDownImage_, touchedUpImage_, and texture::w().
|
virtual |
Default implementation, but defined out-of-line for efficiency reasons.
Definition at line 105 of file tristate_button.cpp.
|
private |
|
overrideprotectedvirtual |
Reimplemented from gui::widget.
Definition at line 171 of file tristate_button.cpp.
References ACTIVE, activeBaseImage_, baseImage_, draw::blit(), itemBaseImage_, itemOverlayImage_, gui::widget::location(), NORMAL, PRESSED_ACTIVE_BOTH, PRESSED_ACTIVE_LEFT, PRESSED_ACTIVE_RIGHT, PRESSED_BOTH, PRESSED_LEFT, PRESSED_RIGHT, pressedBothActiveImage_, pressedBothImage_, pressedDownActiveImage_, pressedDownImage_, pressedUpActiveImage_, pressedUpImage_, state_, TOUCHED_BOTH_LEFT, TOUCHED_BOTH_RIGHT, TOUCHED_LEFT, TOUCHED_RIGHT, touchedBaseImage_, touchedBothImage_, touchedDownImage_, touchedUpImage_, and UNINIT.
Referenced by release().
|
overridevirtual |
Reimplemented from gui::widget.
Definition at line 161 of file tristate_button.cpp.
References gui::widget::enable(), gui::widget::enabled(), NORMAL, pressed_, and state_.
|
overrideprotectedvirtual |
Reimplemented from gui::widget.
Definition at line 380 of file tristate_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_.
bool gui::tristate_button::hit | ( | int | x, |
int | y | ||
) | const |
Definition at line 246 of file tristate_button.cpp.
References rect::contains(), and gui::widget::location().
Referenced by mouse_down(), mouse_motion(), and mouse_up().
|
protectedvirtual |
Definition at line 305 of file tristate_button.cpp.
References ACTIVE, hit(), NORMAL, PRESSED_ACTIVE_LEFT, PRESSED_ACTIVE_RIGHT, PRESSED_LEFT, PRESSED_RIGHT, state_, TOUCHED_BOTH_LEFT, TOUCHED_BOTH_RIGHT, TOUCHED_LEFT, and TOUCHED_RIGHT.
Referenced by handle_event().
|
protectedvirtual |
Definition at line 250 of file tristate_button.cpp.
References ACTIVE, hit(), NORMAL, PRESSED_ACTIVE_BOTH, PRESSED_ACTIVE_LEFT, PRESSED_ACTIVE_RIGHT, PRESSED_BOTH, PRESSED_LEFT, PRESSED_RIGHT, state_, TOUCHED_BOTH_LEFT, TOUCHED_BOTH_RIGHT, TOUCHED_LEFT, TOUCHED_RIGHT, and UNINIT.
Referenced by handle_event().
|
protectedvirtual |
Definition at line 332 of file tristate_button.cpp.
References game_config::sounds::checkbox_release, hit(), item_id_, palette_, sound::play_UI_sound(), pressed_, PRESSED_ACTIVE_BOTH, PRESSED_ACTIVE_LEFT, PRESSED_ACTIVE_RIGHT, editor::tristate_palette::select_bg_item(), editor::tristate_palette::select_fg_item(), state_, TOUCHED_BOTH_LEFT, TOUCHED_BOTH_RIGHT, TOUCHED_LEFT, and TOUCHED_RIGHT.
Referenced by handle_event().
bool gui::tristate_button::pressed | ( | ) |
Definition at line 409 of file tristate_button.cpp.
References pressed_.
tristate_button::PRESSED_STATE gui::tristate_button::pressed_state | ( | ) | const |
Definition at line 142 of file tristate_button.cpp.
References BOTH, LEFT, NONE, PRESSED_ACTIVE_BOTH, PRESSED_ACTIVE_LEFT, PRESSED_ACTIVE_RIGHT, PRESSED_BOTH, PRESSED_LEFT, PRESSED_RIGHT, RIGHT, state_, TOUCHED_BOTH_LEFT, and TOUCHED_BOTH_RIGHT.
void gui::tristate_button::release | ( | ) |
Definition at line 327 of file tristate_button.cpp.
References draw_contents(), NORMAL, and state_.
|
inline |
Definition at line 65 of file tristate_button.hpp.
References gui::widget::id(), and item_id_.
Referenced by editor::editor_palette< Item >::layout().
|
inline |
Definition at line 59 of file tristate_button.hpp.
References itemBaseImage_, and itemOverlayImage_.
Referenced by editor::editor_palette< Item >::layout().
void gui::tristate_button::set_pressed | ( | PRESSED_STATE | new_pressed_state | ) |
Definition at line 107 of file tristate_button.cpp.
References BOTH, LEFT, NONE, NORMAL, PRESSED_ACTIVE_BOTH, PRESSED_ACTIVE_LEFT, PRESSED_ACTIVE_RIGHT, PRESSED_BOTH, PRESSED_LEFT, PRESSED_RIGHT, RIGHT, gui::widget::set_dirty(), and state_.
Referenced by editor::editor_palette< Item >::layout().
|
private |
Definition at line 82 of file tristate_button.hpp.
Referenced by draw_contents(), and tristate_button().
|
private |
Definition at line 104 of file tristate_button.hpp.
Referenced by tristate_button().
|
private |
Definition at line 104 of file tristate_button.hpp.
Referenced by tristate_button().
|
private |
Definition at line 82 of file tristate_button.hpp.
Referenced by draw_contents(), and tristate_button().
|
private |
Definition at line 108 of file tristate_button.hpp.
Referenced by mouse_up(), and set_item_id().
|
private |
Definition at line 83 of file tristate_button.hpp.
Referenced by draw_contents(), and set_item_image().
|
private |
Definition at line 83 of file tristate_button.hpp.
Referenced by draw_contents(), and set_item_image().
|
private |
Definition at line 106 of file tristate_button.hpp.
Referenced by mouse_up().
|
private |
Definition at line 102 of file tristate_button.hpp.
Referenced by enable(), mouse_up(), and pressed().
|
private |
Definition at line 86 of file tristate_button.hpp.
Referenced by draw_contents(), and tristate_button().
|
private |
Definition at line 85 of file tristate_button.hpp.
Referenced by draw_contents(), and tristate_button().
|
private |
Definition at line 86 of file tristate_button.hpp.
Referenced by draw_contents(), and tristate_button().
|
private |
Definition at line 85 of file tristate_button.hpp.
Referenced by draw_contents(), and tristate_button().
|
private |
Definition at line 86 of file tristate_button.hpp.
Referenced by draw_contents(), and tristate_button().
|
private |
Definition at line 85 of file tristate_button.hpp.
Referenced by draw_contents(), and tristate_button().
|
private |
Definition at line 100 of file tristate_button.hpp.
Referenced by draw_contents(), enable(), handle_event(), mouse_down(), mouse_motion(), mouse_up(), pressed_state(), release(), and set_pressed().
|
private |
Definition at line 90 of file tristate_button.hpp.
|
private |
Definition at line 82 of file tristate_button.hpp.
Referenced by draw_contents(), and tristate_button().
|
private |
Definition at line 87 of file tristate_button.hpp.
Referenced by draw_contents(), and tristate_button().
|
private |
Definition at line 87 of file tristate_button.hpp.
Referenced by draw_contents(), and tristate_button().
|
private |
Definition at line 87 of file tristate_button.hpp.
Referenced by draw_contents(), and tristate_button().