Base class for all widgets. More...
#include <widget.hpp>
Classes | |
class | tredraw_action |
Visibility set by the engine. More... | |
class | tvisible |
Visibility settings done by the user. More... | |
Public Member Functions | |
twidget () | |
twidget (const tbuilder_widget &builder) | |
Constructor. More... | |
virtual | ~twidget () override |
void | set_id (const std::string &id) |
const std::string & | id () const |
twindow * | get_window () |
Get the parent window. More... | |
const twindow * | get_window () const |
The constant version of get_window. More... | |
tdialog * | dialog () |
Returns the top-level dialogue. More... | |
void | set_parent (twidget *parent) |
twidget * | parent () |
virtual void | layout_initialise (const bool full_initialisation) |
How the layout engine works. More... | |
virtual void | request_reduce_width (const unsigned maximum_width)=0 |
Tries to reduce the width of a widget. More... | |
virtual void | demand_reduce_width (const unsigned maximum_width) |
Tries to reduce the width of a widget. More... | |
virtual void | request_reduce_height (const unsigned maximum_height) |
Tries to reduce the height of a widget. More... | |
virtual void | demand_reduce_height (const unsigned maximum_height) |
Tries to reduce the height of a widget. More... | |
tpoint | get_best_size () const |
Gets the best size for the widget. More... | |
virtual bool | can_mouse_focus () const |
Whether the mouse move/click event go 'through' this widget. More... | |
virtual bool | can_wrap () const |
Can the widget wrap. More... | |
virtual void | set_origin (const tpoint &origin) |
Sets the origin of the widget. More... | |
virtual void | set_size (const tpoint &size) |
Sets the size of the widget. More... | |
virtual void | place (const tpoint &origin, const tpoint &size) |
Places the widget. More... | |
virtual void | move (const int x_offset, const int y_offset) |
Moves a widget. More... | |
virtual void | layout_children () |
Allows a widget to update its children. More... | |
tpoint | get_origin () const |
Returns the screen origin of the widget. More... | |
tpoint | get_size () const |
Returns the size of the widget. More... | |
SDL_Rect | get_rectangle () const |
Gets the bounding rectangle of the widget on the screen. More... | |
int | get_x () const |
int | get_y () const |
unsigned | get_width () const |
unsigned | get_height () const |
void | set_linked_group (const std::string &linked_group) |
SDL_Rect | calculate_blitting_rectangle (const int x_offset, const int y_offset) |
Calculates the blitting rectangle of the widget. More... | |
SDL_Rect | calculate_clipping_rectangle (const int x_offset, const int y_offset) |
Calculates the clipping rectangle of the widget. More... | |
void | draw_background (surface &frame_buffer, int x_offset, int y_offset) |
Draws the background of a widget. More... | |
void | draw_children (surface &frame_buffer, int x_offset, int y_offset) |
Draws the children of a widget. More... | |
void | draw_foreground (surface &frame_buffer, int x_offset, int y_offset) |
Draws the foreground of the widget. More... | |
void | populate_dirty_list (twindow &caller, std::vector< twidget * > &call_stack) |
Adds a widget to the dirty list if it is dirty. More... | |
SDL_Rect | get_dirty_rectangle () const |
Gets the dirty rectangle of the widget. More... | |
virtual void | set_visible_rectangle (const SDL_Rect &rectangle) |
Sets the visible rectangle for a widget. More... | |
void | set_is_dirty (const bool is_dirty) |
bool | get_is_dirty () const |
void | set_visible (const tvisible::scoped_enum visible) |
tvisible::scoped_enum | get_visible () const |
tredraw_action::scoped_enum | get_drawing_action () const |
void | set_debug_border_mode (const unsigned debug_border_mode) |
void | set_debug_border_colour (const unsigned debug_border_colour) |
virtual twidget * | find_at (const tpoint &coordinate, const bool must_be_active) |
Returns the widget at the wanted coordinates. More... | |
virtual const twidget * | find_at (const tpoint &coordinate, const bool must_be_active) const |
The constant version of find_at. More... | |
virtual twidget * | find (const std::string &id, const bool must_be_active) |
Returns a widget with the wanted id. More... | |
virtual const twidget * | find (const std::string &id, const bool must_be_active) const |
The constant version of find. More... | |
virtual bool | has_widget (const twidget &widget) const |
Does the widget contain the widget. More... | |
virtual bool | disable_click_dismiss () const =0 |
Does the widget disable easy close? More... | |
virtual iterator::twalker_ * | create_walker ()=0 |
Creates a new walker object on the heap. More... | |
![]() | |
tevent_executor () | |
virtual | ~tevent_executor () |
void | set_wants_mouse_hover (const bool hover=true) |
bool | wants_mouse_hover () const |
void | set_wants_mouse_left_double_click (const bool click=true) |
bool | wants_mouse_left_double_click () const |
void | set_wants_mouse_middle_double_click (const bool click=true) |
bool | wants_mouse_middle_double_click () const |
tevent_executor & | set_wants_mouse_right_double_click (const bool click=true) |
bool | wants_mouse_right_double_click () const |
![]() | |
tdispatcher () | |
virtual | ~tdispatcher () |
void | connect () |
Connects the dispatcher to the event handler. More... | |
bool | has_event (const tevent event, const tevent_type event_type) |
bool | fire (const tevent event, twidget &target) |
Fires an event which has no extra parameters. More... | |
bool | fire (const tevent event, twidget &target, const tpoint &coordinate) |
Fires an event which takes a coordinate parameter. More... | |
bool | fire (const tevent event, twidget &target, const SDLKey key, const SDLMod modifier, const utf8::string &unicode) |
Fires an event which takes keyboard parameters. More... | |
bool | fire (const tevent event, twidget &target, void *) |
Fires an event which takes notification parameters. More... | |
bool | fire (const tevent event, twidget &target, tmessage &message) |
Fires an event which takes message parameters. More... | |
template<tevent E> | |
boost::enable_if < boost::mpl::has_key < tset_event, boost::mpl::int_ < E > > >::type | connect_signal (const tsignal_function &signal, const tposition position=back_child) |
Connect a signal for callback in tset_event. More... | |
template<tevent E> | |
boost::enable_if < boost::mpl::has_key < tset_event, boost::mpl::int_ < E > > >::type | disconnect_signal (const tsignal_function &signal, const tposition position=back_child) |
Disconnect a signal for callback in tset_event. More... | |
template<tevent E> | |
boost::enable_if < boost::mpl::has_key < tset_event_mouse, boost::mpl::int_< E > > >::type | connect_signal (const tsignal_mouse_function &signal, const tposition position=back_child) |
Connect a signal for callback in tset_event_mouse. More... | |
template<tevent E> | |
boost::enable_if < boost::mpl::has_key < tset_event_mouse, boost::mpl::int_< E > > >::type | disconnect_signal (const tsignal_mouse_function &signal, const tposition position=back_child) |
Disconnect a signal for callback in tset_event_mouse. More... | |
template<tevent E> | |
boost::enable_if < boost::mpl::has_key < tset_event_keyboard, boost::mpl::int_< E > > >::type | connect_signal (const tsignal_keyboard_function &signal, const tposition position=back_child) |
Connect a signal for callback in tset_event_keyboard. More... | |
template<tevent E> | |
boost::enable_if < boost::mpl::has_key < tset_event_keyboard, boost::mpl::int_< E > > >::type | disconnect_signal (const tsignal_keyboard_function &signal, const tposition position=back_child) |
Disconnect a signal for callback in tset_event_keyboard. More... | |
template<tevent E> | |
boost::enable_if < boost::mpl::has_key < tset_event_notification, boost::mpl::int_< E > > >::type | connect_signal (const tsignal_notification_function &signal, const tposition position=back_child) |
Connect a signal for callback in tset_event_notification. More... | |
template<tevent E> | |
boost::enable_if < boost::mpl::has_key < tset_event_notification, boost::mpl::int_< E > > >::type | disconnect_signal (const tsignal_notification_function &signal, const tposition position=back_child) |
Disconnect a signal for callback in tset_event_notification. More... | |
template<tevent E> | |
boost::enable_if < boost::mpl::has_key < tset_event_message, boost::mpl::int_< E > > >::type | connect_signal (const tsignal_message_function &signal, const tposition position=back_child) |
Connect a signal for callback in tset_event_message. More... | |
template<tevent E> | |
boost::enable_if < boost::mpl::has_key < tset_event_message, boost::mpl::int_< E > > >::type | disconnect_signal (const tsignal_message_function &signal, const tposition position=back_child) |
Disconnect a signal for callback in tset_event_message. More... | |
void | capture_mouse () |
Captures the mouse. More... | |
void | release_mouse () |
Releases the mouse capture. More... | |
void | set_mouse_behavior (const tmouse_behavior mouse_behavior) |
tmouse_behavior | get_mouse_behavior () const |
void | set_want_keyboard_input (const bool want_keyboard_input) |
bool | get_want_keyboard_input () const |
void | register_hotkey (const hotkey::HOTKEY_COMMAND id, const thotkey_function &function) |
Registers a hotkey. More... | |
bool | execute_hotkey (const hotkey::HOTKEY_COMMAND id) |
Executes a hotkey. More... | |
Protected Member Functions | |
void | set_layout_size (const tpoint &size) |
const tpoint & | layout_size () const |
Private Member Functions | |
virtual tpoint | calculate_best_size () const =0 |
Calculates the best size. More... | |
virtual void | impl_draw_background (surface &) |
See draw_background. More... | |
virtual void | impl_draw_background (surface &, int, int) |
virtual void | impl_draw_children (surface &, int, int) |
See draw_children. More... | |
virtual void | impl_draw_foreground (surface &, int, int) |
See draw_foreground. More... | |
virtual void | child_populate_dirty_list (twindow &caller, const std::vector< twidget * > &call_stack) |
Tries to add all children of a container to the dirty list. More... | |
void | draw_debug_border (surface &frame_buffer) |
void | draw_debug_border (surface &frame_buffer, int x_offset, int y_offset) |
virtual bool | is_at (const tpoint &coordinate) const override |
See event::tdispatcher::is_at. More... | |
bool | is_at (const tpoint &coordinate, const bool must_be_active) const |
Is the coordinate inside our area. More... | |
bool | recursive_is_visible (const twidget *widget, const bool must_be_active) const |
Is the widget and every single one of its parents visible? More... | |
Private Attributes | |
std::string | id_ |
The id is the unique name of the widget in a certain context. More... | |
twidget * | parent_ |
The parent widget. More... | |
int | x_ |
The x-coordinate of the widget on the screen. More... | |
int | y_ |
The y-coordinate of the widget on the screen. More... | |
unsigned | width_ |
The width of the widget. More... | |
unsigned | height_ |
The height of the widget. More... | |
tpoint | layout_size_ |
The best size for the widget. More... | |
std::string | linked_group_ |
The linked group the widget belongs to. More... | |
bool | is_dirty_ |
Is the widget dirty? More... | |
tvisible::scoped_enum | visible_ |
Field for the status of the visibility. More... | |
tredraw_action::scoped_enum | redraw_action_ |
Field for the action to do on a drawing request. More... | |
SDL_Rect | clipping_rectangle_ |
The clipping rectangle if a widget is partly visible. More... | |
unsigned | debug_border_mode_ |
Mode for drawing the debug border. More... | |
unsigned | debug_border_colour_ |
The colour for the debug border. More... | |
Friends | |
class | tdebug_layout_graph |
class | twindow |
Additional Inherited Members | |
![]() | |
enum | tevent_type { pre = 1, child = 2, post = 4 } |
enum | tposition { front_pre_child, back_pre_child, front_child, back_child, front_post_child, back_post_child } |
The position where to add a new callback in the signal handler. More... | |
enum | tmouse_behavior { all, hit, none } |
The behavior of the mouse events. More... | |
Base class for all widgets.
From this abstract all other widgets should derive. It contains the minimal info needed for a real widget and some pure abstract functions which need to be implemented by classes deriving from this class.
Definition at line 49 of file widget.hpp.
gui2::twidget::twidget | ( | ) |
Definition at line 28 of file widget.cpp.
References DBG_GUI_LF.
Referenced by set_id().
|
explicit |
Constructor.
builder | The builder object with the settings for the object. |
Definition at line 52 of file widget.cpp.
References DBG_GUI_LF.
|
overridevirtual |
Definition at line 76 of file widget.cpp.
References DBG_GUI_LF, gui2::event::tdispatcher::fire(), get_window(), id_, linked_group_, gui2::event::NOTIFY_REMOVAL, and parent().
|
privatepure virtual |
Calculates the best size.
This function calculates the best size and ignores the current values in the layout phase. Note containers can call the get_best_size() of their children since it is meant to update itself.
0,0 | The best size is 0,0. |
Implemented in gui2::policy::placement::tindependent, gui2::policy::placement::tmatrix, gui2::policy::placement::tvertical_list, gui2::ttree_view_node, gui2::tgenerator_, gui2::tgrid, gui2::policy::placement::thorizontal_list, gui2::tmatrix, gui2::tcontrol, gui2::tpane, gui2::tscrollbar_container, gui2::tcontainer_, gui2::tviewport, gui2::timage, gui2::tspacer, gui2::tdrawing, and gui2::tslider.
Referenced by get_best_size().
Calculates the blitting rectangle of the widget.
The blitting rectangle is the entire widget rectangle, but offsetted for drawing position.
x_offset | The offset in the x-direction when drawn. |
y_offset | The offset in the y-direction when drawn. |
Definition at line 321 of file widget.cpp.
References get_rectangle().
Referenced by draw_debug_border(), gui2::tpanel::impl_draw_background(), gui2::tminimap::impl_draw_background(), gui2::tcontrol::impl_draw_background(), and gui2::tpanel::impl_draw_foreground().
Calculates the clipping rectangle of the widget.
The clipping rectangle is used then the redraw_action_ is tredraw_action::partly. Since the drawing can be offsetted it also needs offset paramters.
x_offset | The offset in the x-direction when drawn. |
y_offset | The offset in the y-direction when drawn. |
Definition at line 330 of file widget.cpp.
References clipping_rectangle_.
Referenced by draw_background(), draw_children(), draw_debug_border(), and draw_foreground().
|
inlinevirtual |
Whether the mouse move/click event go 'through' this widget.
Reimplemented in gui2::tgrid, gui2::tlabel, and gui2::timage.
Definition at line 349 of file widget.hpp.
Referenced by gui2::event::tmouse_motion::signal_handler_sdl_mouse_motion().
|
virtual |
Can the widget wrap.
When a widget can wrap it can reduce its width by increasing its height. When a layout is too wide it should first try to wrap and if that fails it should check the vertical scrollbar status. After wrapping the height might (probably will) change so the layout engine needs to recalculate the height after wrapping.
Reimplemented in gui2::tgrid, gui2::tscrollbar_container, gui2::tcontainer_, gui2::tscroll_label, and gui2::tlabel.
Definition at line 211 of file widget.cpp.
Referenced by gui2::tcontainer_::can_wrap(), gui2::tgrid::can_wrap(), gui2::tgrid::tchild::can_wrap(), gui2::tcontrol::get_best_text_size(), gui2::tcontrol::request_reduce_width(), gui2::ttext_box::update_canvas(), and gui2::tcontrol::update_canvas().
|
privatevirtual |
Tries to add all children of a container to the dirty list.
caller | The parent window, if dirty it should register itself to this window. |
call_stack | The call-stack of widgets traversed to reach this function. |
Reimplemented in gui2::tscrollbar_container, gui2::tgenerator_, gui2::tgrid, gui2::tlistbox, gui2::tmatrix, gui2::tcontainer_, gui2::tpane, gui2::ttree_view, and gui2::tviewport.
Definition at line 409 of file widget.cpp.
Referenced by populate_dirty_list().
|
pure virtual |
Creates a new walker object on the heap.
Implemented in gui2::tgrid, gui2::tmatrix, gui2::tcontainer_, gui2::ttree_view_node, gui2::tpane, gui2::tcontrol, and gui2::tviewport.
|
virtual |
Tries to reduce the height of a widget.
This function does it more aggressively and should only be used when using scrollbars failed.
See Layout algorithm for more information.
maximum_height | The wanted maximum height. |
Reimplemented in gui2::tgrid, and gui2::tcontainer_.
Definition at line 183 of file widget.cpp.
|
virtual |
Tries to reduce the width of a widget.
This function does it more aggressively and should only be used when using scrollbars and wrapping failed.
See Layout algorithm for more information.
maximum_width | The wanted maximum width. |
Reimplemented in gui2::tgrid, and gui2::tcontainer_.
Definition at line 173 of file widget.cpp.
tdialog * gui2::twidget::dialog | ( | ) |
Returns the top-level dialogue.
A window is most of the time created by a dialogue, this function returns that dialogue.
nullptr | No top-level window or the top-level window is not owned by a dialogue. |
Definition at line 144 of file widget.cpp.
References gui2::twindow::dialog(), and get_window().
Referenced by gui2::dialog_callback(), and gui2::dialog_view_callback().
|
pure virtual |
Does the widget disable easy close?
Implemented in gui2::ttree_view_node, gui2::tgrid, gui2::tmatrix, gui2::tcontainer_, gui2::tscrollbar_container, gui2::tpane, gui2::tcontrol, gui2::tviewport, gui2::timage, gui2::tspacer, gui2::tdrawing, gui2::tlabel, gui2::tminimap, and gui2::tprogress_bar.
Referenced by gui2::tgrid::disable_click_dismiss().
Draws the background of a widget.
Derived should override impl_draw_background instead of changing this function.
frame_buffer | The surface to draw upon. |
x_offset | The offset in the x-direction in the frame_buffer to draw. |
y_offset | The offset in the y-direction in the frame_buffer to draw. |
Definition at line 339 of file widget.cpp.
References calculate_clipping_rectangle(), draw_debug_border(), impl_draw_background(), gui2::twidget::tredraw_action::partly, redraw_action_, gui2::twidget::tvisible::visible, and visible_.
Referenced by gui2::tviewport::impl_draw_children(), and gui2::tgrid::impl_draw_children().
Draws the children of a widget.
Containers should draw their children when they get this request.
Derived should override impl_draw_children instead of changing this function.
frame_buffer | The surface to draw upon. |
x_offset | The offset in the x-direction in the frame_buffer to draw. |
y_offset | The offset in the y-direction in the frame_buffer to draw. |
Definition at line 356 of file widget.cpp.
References calculate_clipping_rectangle(), impl_draw_children(), gui2::twidget::tredraw_action::partly, redraw_action_, gui2::twidget::tvisible::visible, and visible_.
Referenced by gui2::tviewport::impl_draw_children(), gui2::tcontainer_::impl_draw_children(), gui2::tmatrix::impl_draw_children(), gui2::ttree_view_node::impl_draw_children(), gui2::tgrid::impl_draw_children(), gui2::tscrollbar_container::impl_draw_children(), and gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::impl_draw_children().
Definition at line 494 of file widget.cpp.
References clipping_rectangle_, debug_border_colour_, debug_border_mode_, sdl::draw_rectangle(), sdl::fill_rect(), get_rectangle(), gui2::twidget::tredraw_action::partly, and redraw_action_.
Referenced by draw_background().
|
private |
Definition at line 518 of file widget.cpp.
References calculate_blitting_rectangle(), calculate_clipping_rectangle(), debug_border_colour_, debug_border_mode_, sdl::draw_rectangle(), sdl::fill_rect(), gui2::twidget::tredraw_action::partly, and redraw_action_.
Draws the foreground of the widget.
Some widgets e.g. panel and window have a back and foreground layer this function requests the drawing of the foreground.
Derived should override impl_draw_foreground instead of changing this function.
frame_buffer | The surface to draw upon. |
x_offset | The offset in the x-direction in the frame_buffer to draw. |
y_offset | The offset in the y-direction in the frame_buffer to draw. |
Definition at line 371 of file widget.cpp.
References calculate_clipping_rectangle(), impl_draw_foreground(), gui2::twidget::tredraw_action::partly, redraw_action_, gui2::twidget::tvisible::visible, and visible_.
Referenced by gui2::tviewport::impl_draw_children(), and gui2::tgrid::impl_draw_children().
|
virtual |
Returns a widget with the wanted id.
id | The id of the widget to find. |
must_be_active | The widget should be active, not all widgets have an active flag, those who don't ignore flag. |
nullptr | No widget with the id found (or not active if must_be_active was set). |
Reimplemented in gui2::policy::placement::tindependent, gui2::twindow, gui2::tgrid, gui2::tcontrol, gui2::ttree_view_node, gui2::tmatrix, gui2::tscrollbar_container, gui2::tcontainer_, and gui2::tviewport.
Definition at line 558 of file widget.cpp.
References id_.
Referenced by gui2::tmatrix::find(), gui2::ttree_view_node::find(), gui2::tcontrol::find(), find_widget(), and gui2::tlobby_player_info::pre_show().
|
virtual |
The constant version of find.
Reimplemented in gui2::policy::placement::tindependent, gui2::twindow, gui2::tgrid, gui2::tcontrol, gui2::ttree_view_node, gui2::tmatrix, gui2::tscrollbar_container, gui2::tcontainer_, and gui2::tviewport.
Definition at line 563 of file widget.cpp.
References id_.
Returns the widget at the wanted coordinates.
coordinate | The coordinate which should be inside the widget. |
must_be_active | The widget should be active, not all widgets have an active flag, those who don't ignore flag. |
nullptr | No widget at the wanted coordinate found (or not active if must_be_active was set). |
Reimplemented in gui2::policy::placement::tindependent, gui2::policy::placement::tmatrix, gui2::policy::placement::tvertical_list, gui2::tgenerator_, gui2::twindow, gui2::tgrid, gui2::policy::placement::thorizontal_list, gui2::tcontrol, gui2::ttree_view_node, gui2::tmatrix, gui2::tscrollbar_container, gui2::tcontainer_, gui2::tpane, gui2::tviewport, and gui2::ttoggle_panel.
Definition at line 547 of file widget.cpp.
References is_at().
Referenced by gui2::tcontrol::find_at(), gui2::event::tmouse_button< sdl_button_down, sdl_button_up, button_down, button_up, button_click, button_double_click >::signal_handler_sdl_button_down(), gui2::event::tmouse_button< sdl_button_down, sdl_button_up, button_down, button_up, button_click, button_double_click >::signal_handler_sdl_button_up(), gui2::event::tmouse_motion::signal_handler_sdl_mouse_motion(), gui2::event::tmouse_motion::signal_handler_sdl_wheel(), and gui2::event::tmouse_motion::signal_handler_show_helptip().
|
virtual |
The constant version of find_at.
Reimplemented in gui2::policy::placement::tindependent, gui2::policy::placement::tmatrix, gui2::policy::placement::tvertical_list, gui2::tgenerator_, gui2::twindow, gui2::tgrid, gui2::policy::placement::thorizontal_list, gui2::tcontrol, gui2::ttree_view_node, gui2::tmatrix, gui2::tscrollbar_container, gui2::tcontainer_, gui2::tpane, gui2::tviewport, and gui2::ttoggle_panel.
Definition at line 552 of file widget.cpp.
References is_at().
tpoint gui2::twidget::get_best_size | ( | ) | const |
Gets the best size for the widget.
During the layout phase a best size will be determined, several stages might change the best size. This function will return the currently best size as determined during the layout phase.
0,0 | The best size is 0,0. |
Definition at line 188 of file widget.cpp.
References calculate_best_size(), gui2::twindow::get_linked_size(), get_window(), gui2::twidget::tvisible::invisible, layout_size_, linked_group_, visible_, gui2::tpoint::x, and gui2::tpoint::y.
Referenced by gui2::tviewport::calculate_best_size(), gui2::tcontainer_::calculate_best_size(), gui2::tscrollbar_container::calculate_best_size(), gui2::tmatrix::calculate_best_size(), gui2::policy::placement::thorizontal_list::calculate_best_size(), gui2::ttree_view_node::calculate_best_size(), gui2::policy::placement::tvertical_list::calculate_best_size(), gui2::policy::placement::tindependent::calculate_best_size(), gui2::tgrid::tchild::get_best_size(), gui2::ttree_view_node::get_folded_size(), gui2::ttree_view_node::get_unfolded_size(), gui2::twindow_implementation::layout(), gui2::twindow::layout(), gui2::tviewport::place(), gui2::tscrollbar_container::place(), gui2::policy::placement::thorizontal_list::place(), gui2::policy::placement::tvertical_list::place(), gui2::ttree_view_node::place(), gui2::tgrid::tchild::place(), gui2::tgrid::reduce_height(), gui2::tgrid::reduce_width(), gui2::tscrollbar_container::request_reduce_height(), gui2::tgrid::request_reduce_height(), gui2::tscrollbar_container::request_reduce_width(), gui2::tgrid::request_reduce_width(), gui2::tlistbox::resize_content(), and gui2::tlistbox::set_content_size().
SDL_Rect gui2::twidget::get_dirty_rectangle | ( | ) | const |
Gets the dirty rectangle of the widget.
Depending on the redraw_action_ it returns the rectangle this widget dirties while redrawing.
Definition at line 416 of file widget.cpp.
References clipping_rectangle_, gui2::twidget::tredraw_action::full, get_rectangle(), and redraw_action_.
twidget::tredraw_action::scoped_enum gui2::twidget::get_drawing_action | ( | ) | const |
Definition at line 476 of file widget.cpp.
References height_, gui2::twidget::tredraw_action::none, redraw_action_, and width_.
Referenced by gui2::tgrid::impl_draw_children(), and populate_dirty_list().
unsigned gui2::twidget::get_height | ( | ) | const |
Definition at line 299 of file widget.cpp.
References height_.
Referenced by gui2::tscrollbar_container::content_resize_height(), gui2::tvertical_scrollbar::get_length(), gui2::tcontrol::get_text_maximum_height(), gui2::tvertical_scrollbar::in_orthogonal_range(), gui2::tvertical_scrollbar::on_bar(), gui2::thorizontal_scrollbar::on_bar(), gui2::tslider::on_bar(), gui2::thorizontal_scrollbar::on_positioner(), gui2::tslider::on_positioner(), gui2::tscrollbar_container::place(), gui2::tlistbox::remove_row(), gui2::policy::placement::tvertical_list::set_origin(), gui2::tscrollbar_container::show_content_rect(), and gui2::ttext_box::update_offsets().
bool gui2::twidget::get_is_dirty | ( | ) | const |
Definition at line 440 of file widget.cpp.
References is_dirty_.
tpoint gui2::twidget::get_origin | ( | ) | const |
Returns the screen origin of the widget.
Definition at line 269 of file widget.cpp.
Referenced by gui2::tscrollbar_container::content_resize_request(), get_rectangle(), gui2::ttree_view::layout_children(), gui2::tlistbox::layout_children(), gui2::tscrollbar_container::place(), gui2::tscrollbar_container::set_origin(), and gui2::tlistbox::set_row_shown().
SDL_Rect gui2::twidget::get_rectangle | ( | ) | const |
Gets the bounding rectangle of the widget on the screen.
Definition at line 279 of file widget.cpp.
References gui2::create_rect(), get_origin(), and get_size().
Referenced by calculate_blitting_rectangle(), gui2::twindow::draw(), draw_debug_border(), gui2::tcontainer_::get_client_rect(), gui2::ttoggle_panel::get_client_rect(), get_dirty_rectangle(), gui2::tlistbox::handle_key_down_arrow(), gui2::tlistbox::handle_key_left_arrow(), gui2::tlistbox::handle_key_right_arrow(), gui2::tlistbox::handle_key_up_arrow(), gui2::tpanel::impl_draw_background(), gui2::tcontrol::impl_draw_background(), gui2::tscrollbar_container::place(), gui2::tlistbox::place(), place(), gui2::tscrollbar_container::set_visible_rectangle(), set_visible_rectangle(), gui2::twindow::show(), gui2::tcombobox::signal_handler_left_button_click(), and gui2::twindow::undraw().
tpoint gui2::twidget::get_size | ( | ) | const |
Returns the size of the widget.
Definition at line 274 of file widget.cpp.
References height_, and width_.
Referenced by gui2::ttree_view_node::add_child(), gui2::tscrollbar_container::content_resize_request(), get_rectangle(), gui2::ttree_view::layout_children(), gui2::tlistbox::layout_children(), gui2::ttree_view::remove_node(), gui2::ttree_view::resize_content(), gui2::tlistbox::resize_content(), gui2::ttree_view_node::set_origin(), and gui2::tlistbox::update_content_size().
twidget::tvisible::scoped_enum gui2::twidget::get_visible | ( | ) | const |
Definition at line 471 of file widget.cpp.
References visible_.
Referenced by gui2::tscrollbar_container::calculate_best_size(), gui2::policy::placement::thorizontal_list::calculate_best_size(), gui2::ttree_view_node::calculate_best_size(), gui2::policy::placement::tvertical_list::calculate_best_size(), gui2::tgrid_implementation::cell_request_reduce_height(), gui2::tgrid_implementation::cell_request_reduce_width(), gui2::tscrollbar_container::content_resize_height(), gui2::tscrollbar_container::content_resize_request(), gui2::tscrollbar_container::content_resize_width(), gui2::tcontrol::disable_click_dismiss(), gui2::tgrid::disable_click_dismiss(), gui2::policy::placement::thorizontal_list::find_at(), gui2::policy::placement::tvertical_list::find_at(), gui2::tgrid::tchild::get_best_size(), gui2::ttree_view_node::get_current_size(), gui2::ttree_view_node::get_unfolded_size(), gui2::policy::placement::tvertical_list::handle_key_down_arrow(), gui2::policy::placement::thorizontal_list::handle_key_right_arrow(), gui2::tviewport::impl_draw_children(), gui2::tcontainer_::impl_draw_children(), gui2::tgrid::impl_draw_children(), gui2::tscrollbar_container::impl_draw_children(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::impl_draw_children(), gui2::tviewport::layout_initialise(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::layout_initialise(), gui2::policy::placement::thorizontal_list::place(), gui2::policy::placement::tvertical_list::place(), gui2::tgrid::tchild::place(), gui2::tlistbox::remove_row(), gui2::tscrollbar_container::request_reduce_height(), gui2::tscrollbar_container::request_reduce_width(), gui2::tlistbox::resize_content(), gui2::policy::placement::thorizontal_list::set_origin(), gui2::policy::placement::tvertical_list::set_origin(), gui2::tscrollbar_container::signal_handler_sdl_wheel_down(), gui2::tscrollbar_container::signal_handler_sdl_wheel_left(), gui2::tscrollbar_container::signal_handler_sdl_wheel_right(), gui2::tscrollbar_container::signal_handler_sdl_wheel_up(), gui2::tgrid::swap_child(), and gui2::tlistbox::update_content_size().
unsigned gui2::twidget::get_width | ( | ) | const |
Definition at line 294 of file widget.cpp.
References width_.
Referenced by gui2::ttree_view_node::add_child(), gui2::tscrollbar_container::content_resize_width(), gui2::thorizontal_scrollbar::get_length(), gui2::tslider::get_length(), gui2::tcontrol::get_text_maximum_width(), gui2::thorizontal_scrollbar::in_orthogonal_range(), gui2::tslider::in_orthogonal_range(), gui2::tvertical_scrollbar::on_bar(), gui2::thorizontal_scrollbar::on_bar(), gui2::tslider::on_bar(), gui2::tvertical_scrollbar::on_positioner(), gui2::tscrollbar_container::place(), gui2::tlistbox::remove_row(), gui2::policy::placement::thorizontal_list::set_origin(), gui2::tscrollbar_container::show_content_rect(), and gui2::ttext_box::update_offsets().
twindow * gui2::twidget::get_window | ( | ) |
Get the parent window.
nullptr | No parent window found. |
Definition at line 116 of file widget.cpp.
References parent_.
Referenced by gui2::tpreferences::add_hotkey_callback(), gui2::tscrollbar_container::content_resize_height(), gui2::tscrollbar_container::content_resize_request(), gui2::tscrollbar_container::content_resize_width(), dialog(), gui2::dialog_callback(), gui2::tgame_load::filter_text_changed(), gui2::tunit_create::filter_text_changed(), gui2::policy::placement::thorizontal_list::find_at(), gui2::policy::placement::tvertical_list::find_at(), gui2::policy::placement::tindependent::find_at(), get_best_size(), layout_initialise(), gui2::tlistbox::list_item_clicked(), gui2::make_dialog_callback_helper(), gui2::taddon_list::on_filtertext_changed(), gui2::tunit_preview_pane::profile_button_callback(), gui2::tscrollbar_::recalculate(), gui2::tlistbox::set_row_shown(), set_visible(), gui2::tbutton::signal_handler_left_button_click(), gui2::tlabel::signal_handler_left_button_click(), gui2::tcombobox::signal_handler_left_button_click(), gui2::ttoggle_button::signal_handler_left_button_double_click(), gui2::ttoggle_panel::signal_handler_left_button_double_click(), gui2::tscroll_label::signal_handler_left_button_down(), gui2::tbutton::signal_handler_left_button_down(), gui2::trepeating_button::signal_handler_left_button_down(), gui2::tcombobox::signal_handler_left_button_down(), gui2::ttree_view::signal_handler_left_button_down(), gui2::ttext_box::signal_handler_left_button_down(), gui2::tscrollbar_::signal_handler_left_button_down(), gui2::tslider::signal_handler_left_button_up(), gui2::tscrollbar_::signal_handler_left_button_up(), gui2::tpane::signal_handler_request_placement(), gui2::tlabel::signal_handler_right_button_click(), and ~twidget().
const twindow * gui2::twidget::get_window | ( | ) | const |
int gui2::twidget::get_x | ( | ) | const |
Definition at line 284 of file widget.cpp.
References x_.
Referenced by gui2::ttext_box::handle_mouse_selection(), gui2::tviewport::impl_draw_children(), place(), gui2::tscrollbar_container::scrollbar_moved(), gui2::tgrid::set_origin(), gui2::tscrollbar_container::show_content_rect(), gui2::tlabel::signal_handler_left_button_click(), gui2::tscrollbar_::signal_handler_left_button_down(), gui2::tscrollbar_::signal_handler_left_button_up(), gui2::tscrollbar_::signal_handler_mouse_motion(), and gui2::tlabel::signal_handler_right_button_click().
int gui2::twidget::get_y | ( | ) | const |
Definition at line 289 of file widget.cpp.
References y_.
Referenced by gui2::ttext_box::handle_mouse_selection(), gui2::tviewport::impl_draw_children(), place(), gui2::tlistbox::remove_row(), gui2::tscrollbar_container::scrollbar_moved(), gui2::tgrid::set_origin(), gui2::tscrollbar_container::show_content_rect(), gui2::tlabel::signal_handler_left_button_click(), gui2::tscrollbar_::signal_handler_left_button_down(), gui2::tscrollbar_::signal_handler_left_button_up(), gui2::tscrollbar_::signal_handler_mouse_motion(), and gui2::tlabel::signal_handler_right_button_click().
|
virtual |
Does the widget contain the widget.
Widgets can be containers which have more widgets inside them, this function will traverse in those child widgets and tries to find the wanted widget.
widget | Pointer to the widget to find. |
widget
was found. Reimplemented in gui2::tgrid, and gui2::tcontainer_.
Definition at line 569 of file widget.cpp.
Referenced by gui2::tcontainer_::has_widget(), and gui2::tgrid::has_widget().
const std::string & gui2::twidget::id | ( | ) | const |
Definition at line 109 of file widget.cpp.
References id_.
Referenced by gui2::twindow::add_linked_widget(), gui2::tcampaign_selection::campaign_selected(), connect_queue(), gui2::tscrollbar_container::find(), gui2::tgrid::find(), gui2::policy::select_action::tselect::init(), gui2::ttree_view_node::init_grid(), gui2::twindow::init_linked_size_group(), gui2::iterator::policy::order::tbottom_up< visit_widget, visit_grid, visit_child >::next(), gui2::iterator::policy::order::ttop_down< visit_widget, visit_grid, visit_child >::next(), gui2::tgrid::place(), place(), gui2::tcampaign_selection::post_show(), gui2::tgrid::remove_child(), gui2::twindow::remove_linked_widget(), set_id(), gui2::ttext_box::signal_handler_mouse_motion(), gui2::ttoggle_panel::signal_handler_pre_left_button_click(), gui2::event::tmouse_motion::start_hover_timer(), gui2::event::tmouse_motion::stop_hover_timer(), gui2::tgrid::swap_child(), gui2::iterator::policy::order::tbottom_up< visit_widget, visit_grid, visit_child >::tbottom_up(), and gui2::iterator::policy::order::ttop_down< visit_widget, visit_grid, visit_child >::up().
Reimplemented in gui2::tcontrol, gui2::tmulti_page, gui2::ttoggle_panel, gui2::tminimap, gui2::tspacer, and gui2::tpanel.
Definition at line 590 of file widget.hpp.
See draw_children.
Reimplemented in gui2::tscrollbar_container, gui2::tgrid, gui2::ttree_view_node, gui2::tgenerator_, gui2::tmatrix, gui2::tcontainer_, gui2::tpane, and gui2::tviewport.
Definition at line 599 of file widget.hpp.
Referenced by draw_children().
See draw_foreground.
Reimplemented in gui2::tcontrol, gui2::ttoggle_panel, and gui2::tpanel.
Definition at line 608 of file widget.hpp.
Referenced by draw_foreground().
|
overrideprivatevirtual |
See event::tdispatcher::is_at.
Implements gui2::event::tdispatcher.
Definition at line 574 of file widget.cpp.
Referenced by find_at().
|
private |
Is the coordinate inside our area.
Helper for find_at so also looks at our visibility.
coordinate | The coordinate which should be inside the widget. |
must_be_active | The widget should be active, not all widgets have an active flag, those who don't ignore flag. |
Definition at line 593 of file widget.cpp.
References height_, recursive_is_visible(), width_, gui2::tpoint::x, x_, gui2::tpoint::y, and y_.
|
virtual |
Allows a widget to update its children.
Before the window is populating the dirty list the widgets can update their content, which allows delayed initialization. This delayed initialization is only allowed if the widget resizes itself, not when being placed.
Reimplemented in gui2::tscrollbar_container, gui2::tgrid, gui2::tlistbox, gui2::tmatrix, gui2::tcontainer_, gui2::ttree_view, and gui2::tstacked_widget.
Definition at line 264 of file widget.cpp.
Referenced by gui2::tgrid::layout_children().
|
virtual |
How the layout engine works.
Every widget has a member layout_size_ which holds the best size in the current layout phase. When the windows starts the layout phase it calls layout_initialise which resets this value.
Every widget has two function to get the best size. get_best_size tests whether layout_size_ is set and if so returns that value otherwise it calls calculate_best_size so the size can be updated.
During the layout phase some functions can modify layout_size_ so the next call to get_best_size returns the currently best size. This means that after the layout phase get_best_size still returns this value. Initialises the layout phase.
Clears the initial best size for the widgets.
See Layout algorithm for more information.
full_initialisation | For widgets with scrollbars it hides them unless the mode is tscrollbar_mode::always_visible. For other widgets this flag is a NOP. |
Reimplemented in gui2::tgenerator_, gui2::ttree_view_node, gui2::tgrid, gui2::tcontrol, gui2::tmatrix, gui2::tscrollbar_container, gui2::tpane, gui2::tcontainer_, and gui2::tviewport.
Definition at line 162 of file widget.cpp.
References gui2::twindow::add_linked_widget(), get_window(), gui2::twidget::tvisible::invisible, layout_size_, linked_group_, and visible_.
Referenced by gui2::tviewport::layout_initialise(), gui2::tpane::layout_initialise(), gui2::tcontrol::layout_initialise(), gui2::tgrid::layout_initialise(), gui2::ttree_view_node::layout_initialise(), and gui2::tpane::signal_handler_request_placement().
|
protected |
Definition at line 309 of file widget.cpp.
References layout_size_.
Moves a widget.
This function can be used to move the widget without dirtying it.
x_offset | The amount of pixels to move the widget in the x-direction. |
y_offset | The amount of pixels to move the widget in the y-direction. |
Definition at line 258 of file widget.cpp.
twidget * gui2::twidget::parent | ( | ) |
Definition at line 155 of file widget.cpp.
References parent_.
Referenced by gui2::event::implementation::build_event_chain(), gui2::event::fire_event_double_click(), gui2::ttree_view_node::get_node_below(), gui2::get_parent(), gui2::tgrid::place(), place(), set_parent(), gui2::event::tmouse_motion::signal_handler_sdl_mouse_motion(), and ~twidget().
Places the widget.
This function is normally called by a layout function to do the placement of a widget.
origin | The position of top left of the widget. |
size | The size of the widget. |
Reimplemented in gui2::policy::placement::tindependent, gui2::policy::placement::tmatrix, gui2::ttree_view_node, gui2::policy::placement::tvertical_list, gui2::tgenerator_, gui2::tgrid, gui2::policy::placement::thorizontal_list, gui2::tlistbox, gui2::tcontrol, gui2::ttext_box, gui2::tmatrix, gui2::tscrollbar_container, gui2::tscrollbar_, gui2::tcontainer_, gui2::tpane, and gui2::tviewport.
Definition at line 233 of file widget.cpp.
References get_rectangle(), get_x(), get_y(), height_, id(), parent(), set_is_dirty(), width_, gui2::tpoint::x, x_, gui2::tpoint::y, and y_.
Referenced by gui2::tviewport::place(), gui2::tpane::place(), gui2::tmatrix::place(), gui2::tcontrol::place(), gui2::tgrid::place(), gui2::ttree_view_node::place(), gui2::tgrid::tchild::place(), and gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::place().
Adds a widget to the dirty list if it is dirty.
See twindow::dirty_list_ for more information regarding the dirty list.
If the widget is not dirty and has children it should add itself to the call_stack and call child_populate_dirty_list with the new call_stack.
caller | The parent window, if dirty it should register itself to this window. |
call_stack | The call-stack of widgets traversed to reach this function. |
Definition at line 386 of file widget.cpp.
References gui2::twindow::add_to_dirty_list(), child_populate_dirty_list(), get_drawing_action(), is_dirty_, gui2::twidget::tredraw_action::none, gui2::twidget::tvisible::visible, and visible_.
Referenced by gui2::tviewport::child_populate_dirty_list(), gui2::tcontainer_::child_populate_dirty_list(), gui2::tmatrix::child_populate_dirty_list(), gui2::tlistbox::child_populate_dirty_list(), gui2::tgrid::child_populate_dirty_list(), gui2::tscrollbar_container::child_populate_dirty_list(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::child_populate_dirty_list(), gui2::twindow::draw(), and gui2::ttree_view_node::impl_populate_dirty_list().
|
private |
Is the widget and every single one of its parents visible?
widget | Widget where to start the check. |
must_be_active | The widget should be active, not all widgets have an active flag, those who don't ignore flag. |
Definition at line 579 of file widget.cpp.
References gui2::twidget::tvisible::hidden, gui2::twidget::tvisible::invisible, parent_, and visible_.
Referenced by is_at().
|
virtual |
Tries to reduce the height of a widget.
This function tries to do it 'friendly' and only use scrollbars.
See Layout algorithm for more information.
maximum_height | The wanted maximum height. |
Reimplemented in gui2::policy::placement::tindependent, gui2::policy::placement::tmatrix, gui2::policy::placement::tvertical_list, gui2::tgenerator_, gui2::tgrid, gui2::policy::placement::thorizontal_list, gui2::tscrollbar_container, and gui2::tcontainer_.
Definition at line 178 of file widget.cpp.
Referenced by gui2::tgrid_implementation::cell_request_reduce_height().
|
pure virtual |
Tries to reduce the width of a widget.
This function tries to do it 'friendly' and only use scrollbars or tries to wrap the widget.
See Layout algorithm for more information.
maximum_width | The wanted maximum width. |
Implemented in gui2::policy::placement::tindependent, gui2::policy::placement::tmatrix, gui2::policy::placement::tvertical_list, gui2::tgenerator_, gui2::ttree_view_node, gui2::tgrid, gui2::policy::placement::thorizontal_list, gui2::tcontrol, gui2::tmatrix, gui2::tscrollbar_container, gui2::tpane, gui2::tcontainer_, and gui2::tviewport.
Referenced by gui2::tgrid_implementation::cell_request_reduce_width().
void gui2::twidget::set_debug_border_colour | ( | const unsigned | debug_border_colour | ) |
Definition at line 489 of file widget.cpp.
References debug_border_colour_.
Referenced by gui2::implementation::tbuilder_control::init_control().
void gui2::twidget::set_debug_border_mode | ( | const unsigned | debug_border_mode | ) |
Definition at line 484 of file widget.cpp.
References debug_border_mode_.
Referenced by gui2::implementation::tbuilder_control::init_control().
void gui2::twidget::set_id | ( | const std::string & | id | ) |
Definition at line 97 of file widget.cpp.
References DBG_GUI_LF, gui2::tcontrol::get_control_type(), id(), id_, and twidget().
Referenced by add_widget(), BOOST_AUTO_TEST_CASE(), gui2::build(), gui2::tbuilder_grid::build(), gui2::implementation::tbuilder_listbox::build(), gui2::implementation::tbuilder_control::init_control(), gui2::tpreferences::initialize_members(), gui2::tcampaign_selection::pre_show(), and gui2::tcontrol::set_members().
void gui2::twidget::set_is_dirty | ( | const bool | is_dirty | ) |
Definition at line 435 of file widget.cpp.
References is_dirty_.
Referenced by gui2::event::thandler::disconnect(), gui2::event::thandler::draw(), gui2::ttext_box::handle_mouse_selection(), gui2::tviewport::impl_draw_children(), gui2::tgrid::impl_draw_children(), gui2::ttext_::insert_char(), lua_gui2::intf_set_dialog_canvas(), gui2::tlistbox::layout_children(), gui2::tlistbox::order_by(), gui2::ttext_::paste_selection(), place(), gui2::tpassword_box::post_function(), gui2::ttree_view::resize_content(), gui2::tlistbox::resize_content(), gui2::tscrollbar_container::scrollbar_moved(), gui2::tcontainer_::set_active(), gui2::tslider::set_best_slider_length(), gui2::tgrid::set_column_grow_factor(), gui2::ttext_::set_cursor(), gui2::tcontrol::set_label(), gui2::tlabel::set_link_aware(), gui2::tlabel::set_link_color(), gui2::tminimap::set_map_data(), gui2::ttext_::set_maximum_length(), gui2::tprogress_bar::set_percentage(), gui2::tgrid::set_row_grow_factor(), gui2::tlistbox::set_row_shown(), gui2::tcombobox::set_selected(), gui2::ttext_::set_selection_length(), gui2::ttext_::set_selection_start(), set_size(), gui2::tbutton::set_state(), gui2::tlabel::set_state(), gui2::trepeating_button::set_state(), gui2::ttoggle_button::set_state(), gui2::tcombobox::set_state(), gui2::ttoggle_panel::set_state(), gui2::tscrollbar_::set_state(), gui2::ttext_::set_state(), gui2::tcontrol::set_text_alignment(), gui2::tcontrol::set_use_markup(), gui2::ttoggle_button::set_value(), gui2::ttext_::set_value(), gui2::ttoggle_panel::set_value(), gui2::tcombobox::set_values(), gui2::twindow::set_variable(), set_visible(), gui2::ttoggle_button::update_canvas(), gui2::tscrollbar_::update_canvas(), gui2::tlistbox::update_content_size(), and gui2::tdebug_clock::update_time().
Definition at line 304 of file widget.cpp.
References layout_size_.
Referenced by gui2::tgrid::recalculate_best_size(), gui2::tscrollbar_container::request_reduce_height(), gui2::tgrid::request_reduce_height(), gui2::tscrollbar_container::request_reduce_width(), gui2::tcontrol::request_reduce_width(), gui2::tgrid::request_reduce_width(), and gui2::tcontrol::set_label().
void gui2::twidget::set_linked_group | ( | const std::string & | linked_group | ) |
Definition at line 314 of file widget.cpp.
References linked_group_.
Referenced by gui2::tbuilder_grid::build(), gui2::implementation::tbuilder_control::init_control(), and gui2::tcontrol::set_members().
Sets the origin of the widget.
This function can be used to move the widget without dirtying it. The location is an absolute position, if a relative more is required use move.
origin | The new origin. |
Reimplemented in gui2::policy::placement::tindependent, gui2::policy::placement::tmatrix, gui2::policy::placement::tvertical_list, gui2::ttree_view_node, gui2::tgenerator_, gui2::tgrid, gui2::policy::placement::thorizontal_list, gui2::tscrollbar_container, and gui2::tcontainer_.
Definition at line 216 of file widget.cpp.
References gui2::tpoint::x, x_, gui2::tpoint::y, and y_.
Referenced by gui2::tcontainer_::set_origin(), gui2::tgrid::set_origin(), gui2::ttree_view_node::set_origin(), and gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::set_origin().
Definition at line 150 of file widget.cpp.
References parent(), and parent_.
Referenced by gui2::tpane::create_item(), gui2::tscrollbar_container::finalize_setup(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::init(), gui2::tgrid::set_child(), gui2::tgrid::swap_child(), gui2::tcontainer_::tcontainer_(), gui2::tmatrix::tmatrix(), gui2::ttree_view_node::ttree_view_node(), and gui2::tviewport::tviewport().
Sets the size of the widget.
This version is meant to resize a widget, since the origin isn't modified. This can be used if a widget needs to change its size and the layout will be fixed later.
size | The size of the widget. |
Definition at line 222 of file widget.cpp.
References height_, set_is_dirty(), width_, gui2::tpoint::x, and gui2::tpoint::y.
Referenced by gui2::ttree_view_node::place(), gui2::ttree_view::resize_content(), and gui2::tlistbox::resize_content().
void gui2::twidget::set_visible | ( | const tvisible::scoped_enum | visible | ) |
Definition at line 445 of file widget.cpp.
References gui2::event::tdispatcher::fire(), get_window(), gui2::twindow::invalidate_layout(), gui2::twidget::tvisible::invisible, gui2::new_widgets, gui2::event::REQUEST_PLACEMENT, set_is_dirty(), and visible_.
Referenced by gui2::adjust_scrollbar_mode(), gui2::tmessage_implementation::init_button(), gui2::tpreferences::initialize_members(), lua_gui2::intf_set_dialog_visible(), gui2::twindow::layout(), gui2::tscrollbar_container::layout_initialise(), gui2::ttransient_message::pre_show(), gui2::tmp_alerts_options::pre_show(), gui2::tlobby_player_info::pre_show(), gui2::tcampaign_difficulty::pre_show(), gui2::taddon_list::pre_show(), gui2::tcampaign_selection::pre_show(), gui2::taddon_description::pre_show(), gui2::twml_error::pre_show(), gui2::tgame_version::pre_show(), gui2::ttitle_screen::pre_show(), gui2::tmessage::pre_show(), gui2::twml_message_::pre_show(), gui2::tscrollbar_container::request_reduce_height(), gui2::tscrollbar_container::request_reduce_width(), gui2::tlobby_main::search_create_window(), gui2::policy::select_action::tshow::select(), gui2::tstacked_widget::select_layer(), gui2::set_scrollbar_mode(), gui2::tsub_player_list::show_toggle_callback(), gui2::tgrid::swap_child(), and gui2::ttree_view_node::ttree_view_node().
|
virtual |
Sets the visible rectangle for a widget.
This function sets the redraw_action_ and the clipping_rectangle_.
rectangle | The visible rectangle in screen coordinates. |
Reimplemented in gui2::policy::placement::tindependent, gui2::policy::placement::tmatrix, gui2::ttree_view_node, gui2::policy::placement::tvertical_list, gui2::tgenerator_, gui2::tgrid, gui2::policy::placement::thorizontal_list, gui2::tscrollbar_container, and gui2::tcontainer_.
Definition at line 422 of file widget.cpp.
References clipping_rectangle_, sdl::empty_rect, gui2::twidget::tredraw_action::full, get_rectangle(), sdl::intersect_rects(), gui2::twidget::tredraw_action::none, gui2::twidget::tredraw_action::partly, and redraw_action_.
Referenced by gui2::tcontainer_::set_visible_rectangle(), and gui2::tgrid::set_visible_rectangle().
|
friend |
Definition at line 53 of file widget.hpp.
|
friend |
Definition at line 54 of file widget.hpp.
|
private |
The clipping rectangle if a widget is partly visible.
Definition at line 710 of file widget.hpp.
Referenced by calculate_clipping_rectangle(), draw_debug_border(), get_dirty_rectangle(), and set_visible_rectangle().
|
private |
The colour for the debug border.
Definition at line 728 of file widget.hpp.
Referenced by draw_debug_border(), and set_debug_border_colour().
|
private |
Mode for drawing the debug border.
The debug border is a helper border to determine where a widget is placed. It is only intended for debugging purposes.
Possible values:
Definition at line 725 of file widget.hpp.
Referenced by draw_debug_border(), and set_debug_border_mode().
|
private |
The height of the widget.
Definition at line 470 of file widget.hpp.
Referenced by get_drawing_action(), get_height(), get_size(), is_at(), place(), and set_size().
|
private |
The id is the unique name of the widget in a certain context.
This is needed for certain widgets so the engine knows which widget is which. E.g. it knows which button is pressed and thus which engine action is connected to the button. This doesn't mean that the id is unique in a window, e.g. a listbox can have the same id for every row.
Definition at line 183 of file widget.hpp.
Referenced by find(), id(), set_id(), and ~twidget().
|
private |
Is the widget dirty?
When a widget is dirty it needs to be redrawn at the next drawing cycle.
The top-level window will use populate_dirty_list and child_populate_dirty_list to find al dirty widgets, so the widget doesn't need to inform its parent regarding it being marked dirty.
Definition at line 701 of file widget.hpp.
Referenced by get_is_dirty(), populate_dirty_list(), and set_is_dirty().
|
private |
The best size for the widget.
When 0,0 the real best size is returned, but in the layout phase a wrapping or a scrollbar might change the best size for that widget. This variable holds that best value.
Definition at line 479 of file widget.hpp.
Referenced by get_best_size(), layout_initialise(), layout_size(), and set_layout_size().
|
private |
The linked group the widget belongs to.
Definition at line 503 of file widget.hpp.
Referenced by get_best_size(), layout_initialise(), set_linked_group(), and ~twidget().
|
private |
The parent widget.
If the widget has a parent it contains a pointer to the parent, else it is set to nullptr
.
Definition at line 230 of file widget.hpp.
Referenced by get_window(), parent(), recursive_is_visible(), and set_parent().
|
private |
Field for the action to do on a drawing request.
Definition at line 707 of file widget.hpp.
Referenced by draw_background(), draw_children(), draw_debug_border(), draw_foreground(), get_dirty_rectangle(), get_drawing_action(), and set_visible_rectangle().
|
private |
Field for the status of the visibility.
Definition at line 704 of file widget.hpp.
Referenced by draw_background(), draw_children(), draw_foreground(), get_best_size(), get_visible(), layout_initialise(), populate_dirty_list(), recursive_is_visible(), and set_visible().
|
private |
The width of the widget.
Definition at line 467 of file widget.hpp.
Referenced by get_drawing_action(), get_size(), get_width(), is_at(), place(), and set_size().
|
private |
The x-coordinate of the widget on the screen.
Definition at line 461 of file widget.hpp.
Referenced by get_origin(), get_x(), is_at(), move(), place(), and set_origin().
|
private |
The y-coordinate of the widget on the screen.
Definition at line 464 of file widget.hpp.
Referenced by get_origin(), get_y(), is_at(), move(), place(), and set_origin().