#include <widget.hpp>
Public Member Functions | |
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 |
virtual void | enable (bool new_val=true) |
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 | |
widget (const bool auto_join=true) | |
virtual | ~widget () |
virtual void | draw_contents () |
virtual void | update_location (const SDL_Rect &) |
virtual void | handle_event (const SDL_Event &) override |
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 &&) |
Protected Attributes | |
bool | focus_ |
Private Types | |
enum | { UNINIT , HIDDEN , DIRTY , DRAWN } |
Private Member Functions | |
void | draw () |
Private Attributes | |
rect | rect_ |
enum gui::widget:: { ... } | state_ |
bool | enabled_ |
bool | clip_ |
rect | clip_rect_ |
std::string | tooltip_text_ |
std::string | id_ |
bool | mouse_lock_local_ |
Static Private Attributes | |
static bool | mouse_lock_ = false |
Friends | |
class | dialog |
Definition at line 27 of file widget.hpp.
|
private |
Enumerator | |
---|---|
UNINIT | |
HIDDEN | |
DIRTY | |
DRAWN |
Definition at line 101 of file widget.hpp.
|
protected |
Definition at line 33 of file widget.cpp.
|
protectedvirtual |
Definition at line 40 of file widget.cpp.
References free_mouse_lock(), hidden(), and queue_redraw().
|
protected |
Definition at line 48 of file widget.cpp.
References mouse_lock_, and mouse_lock_local_.
bool gui::widget::dirty | ( | ) | const |
Definition at line 193 of file widget.cpp.
Referenced by editor::location_palette::layout(), editor::palette_manager::layout(), and set_dirty().
|
private |
Definition at line 230 of file widget.cpp.
References clip_, clip_rect_, draw_contents(), hidden(), draw::reduce_clip(), and set_dirty().
Referenced by expose().
|
inlineprotectedvirtual |
Reimplemented in gui::textbox, gui::tristate_button, editor::palette_manager, editor::location_palette, location_palette_item, editor::editor_palette< Item >, editor::editor_palette< t_translation::terrain_code >, editor::editor_palette< const unit_type & >, editor::editor_palette< overlay >, gui::scrollbar, and gui::button.
Definition at line 87 of file widget.hpp.
Referenced by draw().
|
virtual |
Reimplemented in gui::tristate_button, and gui::button.
Definition at line 167 of file widget.cpp.
References enabled_, and queue_redraw().
Referenced by gui::button::enable(), and gui::tristate_button::enable().
bool gui::widget::enabled | ( | ) | const |
Definition at line 175 of file widget.cpp.
References enabled_.
Referenced by gui::button::draw_contents(), gui::textbox::draw_contents(), gui::textbox::draw_cursor(), gui::button::enable(), gui::tristate_button::enable(), location_palette_item::handle_event(), gui::button::handle_event(), gui::tristate_button::handle_event(), gui::textbox::handle_event(), and gui::textbox::requires_event_focus().
|
overridevirtual |
Called by draw_manager when it believes a redraw is necessary.
Implements gui2::top_level_drawable.
Definition at line 220 of file widget.cpp.
References clip_, clip_rect_, draw(), hidden(), rect::overlaps(), and rect_.
bool gui::widget::focus | ( | const SDL_Event * | event | ) |
Definition at line 136 of file widget.cpp.
References focus_, and events::has_focus().
Referenced by gui::textbox::draw_contents(), editor::palette_manager::handle_event(), gui::textbox::handle_event(), and set_focus().
|
protected |
Definition at line 55 of file widget.cpp.
References mouse_lock_, and mouse_lock_local_.
Referenced by ~widget().
|
inlineoverrideprotectedvirtual |
Implements events::sdl_handler.
Reimplemented in gui::textbox, gui::tristate_button, editor::palette_manager, gui::scrollbar, gui::scrollarea, gui::button, and location_palette_item.
Definition at line 90 of file widget.hpp.
Referenced by location_palette_item::handle_event(), gui::button::handle_event(), gui::scrollarea::handle_event(), gui::scrollbar::handle_event(), editor::palette_manager::handle_event(), gui::tristate_button::handle_event(), and gui::textbox::handle_event().
int gui::widget::height | ( | ) | const |
Definition at line 118 of file widget.cpp.
References rect_.
Referenced by gui::scrollarea::handle_event().
bool gui::widget::hidden | ( | ) | const |
Definition at line 161 of file widget.cpp.
References clip_, clip_rect_, HIDDEN, rect::overlaps(), rect_, state_, and UNINIT.
Referenced by draw(), expose(), location_palette_item::handle_event(), gui::button::handle_event(), gui::scrollarea::handle_event(), gui::scrollbar::handle_event(), gui::tristate_button::handle_event(), gui::textbox::handle_event(), editor::location_palette::hide(), process_tooltip_string(), gui::textbox::requires_event_focus(), gui::scrollarea::update_location(), and ~widget().
|
virtual |
Reimplemented in editor::empty_palette, gui::scrollarea, editor::location_palette, editor::editor_palette< Item >, editor::editor_palette< t_translation::terrain_code >, editor::editor_palette< const unit_type & >, and editor::editor_palette< overlay >.
Definition at line 141 of file widget.cpp.
References DIRTY, DRAWN, HIDDEN, queue_redraw(), and state_.
Referenced by editor::location_palette::hide(), gui::scrollarea::hide(), editor::editor_palette< Item >::layout(), editor::location_palette::layout(), editor::palette_manager::layout(), location_palette_button::location_palette_button(), gui::scrollarea::scrollarea(), and gui::scrollarea::update_location().
const std::string & gui::widget::id | ( | ) | const |
Definition at line 198 of file widget.cpp.
References id_.
Referenced by editor::location_palette::add_item(), editor::location_palette::is_selected_item(), set_id(), location_palette_item::set_item_id(), and gui::tristate_button::set_item_id().
|
overridevirtual |
Called by draw_manager to validate layout.
Reimplemented from gui2::top_level_drawable.
Reimplemented in gui::textbox, editor::palette_manager, editor::location_palette, editor::editor_palette< Item >, editor::editor_palette< t_translation::terrain_code >, editor::editor_palette< const unit_type & >, and editor::editor_palette< overlay >.
Definition at line 88 of file widget.cpp.
const rect & gui::widget::location | ( | ) | const |
Definition at line 123 of file widget.cpp.
References rect_.
Referenced by gui::button::calculate_size(), gui::button::draw_contents(), gui::scrollbar::draw_contents(), location_palette_item::draw_contents(), gui::tristate_button::draw_contents(), gui::textbox::draw_cursor(), gui::scrollbar::grip_area(), gui::scrollbar::handle_event(), editor::palette_manager::handle_event(), location_palette_item::hit(), gui::tristate_button::hit(), gui::button::hit(), gui::scrollarea::inner_location(), gui::button::load_images(), location_palette_button::location_palette_button(), queue_redraw(), screen_location(), gui::scrollarea::test_scrollbar(), and gui::textbox::update_text_cache().
|
protected |
Definition at line 64 of file widget.cpp.
References mouse_lock_, and mouse_lock_local_.
Referenced by location_palette_item::handle_event(), gui::button::handle_event(), gui::scrollarea::handle_event(), gui::scrollbar::handle_event(), gui::tristate_button::handle_event(), and gui::textbox::handle_event().
|
overridevirtual |
Reimplemented from events::sdl_handler.
Definition at line 251 of file widget.cpp.
References tooltips::add_tooltip(), rect::contains(), hidden(), rect_, and tooltip_text_.
void gui::widget::queue_redraw | ( | ) |
Indicate that the widget should be redrawn.
Definition at line 215 of file widget.cpp.
References location().
Referenced by gui::textbox::append_text(), gui::textbox::clear(), enable(), gui::button::handle_event(), gui::scrollbar::handle_event(), gui::textbox::handle_event(), hide(), gui::textbox::scroll(), gui::button::set_active(), gui::button::set_check(), set_clip_rect(), gui::textbox::set_cursor_pos(), set_dirty(), set_focus(), gui::scrollbar::set_full_size(), gui::button::set_image(), gui::button::set_label(), set_location(), gui::button::set_overlay(), gui::scrollbar::set_position(), gui::textbox::set_selection(), gui::scrollbar::set_shown_size(), gui::textbox::set_text(), gui::textbox::set_wrap(), gui::textbox::update_location(), and ~widget().
void gui::widget::queue_redraw | ( | const rect & | r | ) |
Indicate that a specific region of the screen should be redrawn.
This is in absolute drawing coordinates, and is not clipped.
Definition at line 210 of file widget.cpp.
References draw_manager::invalidate_region().
|
inlineoverridevirtual |
The current draw location of the display, on the screen.
Implements gui2::top_level_drawable.
Definition at line 79 of file widget.hpp.
References location().
void gui::widget::set_clip_rect | ( | const SDL_Rect & | rect | ) |
Definition at line 154 of file widget.cpp.
References clip_, clip_rect_, queue_redraw(), and draw::rect().
void gui::widget::set_dirty | ( | bool | dirty = true | ) |
Definition at line 180 of file widget.cpp.
References dirty(), DIRTY, DRAWN, queue_redraw(), and state_.
Referenced by editor::palette_manager::adjust_size(), editor::location_palette::adjust_size(), draw(), location_palette_item::handle_event(), gui::tristate_button::handle_event(), editor::editor_palette< Item >::layout(), editor::location_palette::layout(), editor::palette_manager::layout(), editor::palette_manager::scroll_down(), editor::location_palette::scroll_down(), editor::palette_manager::scroll_top(), editor::palette_manager::scroll_up(), editor::location_palette::scroll_up(), editor::unit_palette::select_bg_item(), editor::location_palette::select_item(), and gui::tristate_button::set_pressed().
void gui::widget::set_focus | ( | bool | focus | ) |
Definition at line 128 of file widget.cpp.
References focus(), focus_, events::focus_handler(), and queue_redraw().
Referenced by editor::palette_manager::handle_event(), and gui::textbox::handle_event().
void gui::widget::set_height | ( | int | h | ) |
Definition at line 103 of file widget.cpp.
References h, rect_, and set_location().
Referenced by gui::button::calculate_size().
void gui::widget::set_id | ( | const std::string & | id | ) |
Definition at line 203 of file widget.cpp.
|
virtual |
Definition at line 69 of file widget.cpp.
References DIRTY, DRAWN, queue_redraw(), draw::rect(), rect_, state_, UNINIT, and update_location().
Referenced by editor::palette_manager::adjust_size(), editor::location_palette::adjust_size(), gui::button::calculate_size(), location_palette_button::location_palette_button(), set_height(), set_location(), set_measurements(), set_width(), and gui::scrollarea::update_location().
void gui::widget::set_location | ( | int | x, |
int | y | ||
) |
Definition at line 93 of file widget.cpp.
References rect_, and set_location().
void gui::widget::set_measurements | ( | int | w, |
int | h | ||
) |
Definition at line 108 of file widget.cpp.
References h, rect_, set_location(), and w.
Referenced by gui::textbox::textbox().
void gui::widget::set_tooltip_string | ( | const std::string & | str | ) |
Definition at line 246 of file widget.cpp.
References tooltip_text_.
Referenced by editor::editor_palette< Item >::layout(), and editor::location_palette::layout().
void gui::widget::set_width | ( | int | w | ) |
Definition at line 98 of file widget.cpp.
References rect_, set_location(), and w.
Referenced by gui::button::calculate_size(), and gui::scrollbar::scrollbar().
|
inlineprotectedvirtual |
Reimplemented in gui::textbox, and gui::scrollarea.
Definition at line 88 of file widget.hpp.
Referenced by set_location().
int gui::widget::width | ( | ) | const |
Definition at line 113 of file widget.cpp.
References rect_.
Referenced by gui::scrollarea::inner_location(), gui::scrollarea::scrollbar_width(), gui::textbox::textbox(), and gui::scrollarea::update_location().
|
friend |
Definition at line 112 of file widget.hpp.
|
private |
Definition at line 103 of file widget.hpp.
Referenced by draw(), expose(), hidden(), and set_clip_rect().
|
private |
Definition at line 104 of file widget.hpp.
Referenced by draw(), expose(), hidden(), and set_clip_rect().
|
private |
Definition at line 102 of file widget.hpp.
|
protected |
Definition at line 91 of file widget.hpp.
Referenced by focus(), gui::textbox::requires_event_focus(), and set_focus().
|
private |
Definition at line 107 of file widget.hpp.
|
staticprivate |
Definition at line 110 of file widget.hpp.
Referenced by aquire_mouse_lock(), free_mouse_lock(), and mouse_locked().
|
private |
Definition at line 109 of file widget.hpp.
Referenced by aquire_mouse_lock(), free_mouse_lock(), and mouse_locked().
|
private |
Definition at line 99 of file widget.hpp.
Referenced by expose(), height(), hidden(), location(), process_tooltip_string(), set_height(), set_location(), set_measurements(), set_width(), and width().
enum { ... } gui::widget::state_ |
Referenced by dirty(), hidden(), hide(), set_dirty(), and set_location().
|
private |
Definition at line 106 of file widget.hpp.
Referenced by process_tooltip_string(), and set_tooltip_string().