15 #define GETTEXT_DOMAIN "wesnoth-lib"
29 #define LOG_SCOPE_HEADER "tpane [" + id() + "] " + __func__
30 #define LOG_HEADER LOG_SCOPE_HEADER + ':'
60 if(pane->twidget::find_at(coordinate, must_be_active) != pane) {
65 for(thack item : pane->items_)
76 const SDL_Rect rect = item.grid->get_rectangle();
77 if(coordinate.
x >= rect.x && coordinate.
y >= rect.y
78 && coordinate.
x < rect.x + rect.w
79 && coordinate.
y < rect.y + rect.h) {
81 return item.grid->find_at(coordinate, must_be_active);
96 grid(W pane,
const unsigned id)
99 for(thack item : pane->items_)
114 , item_builder_(item_builder)
115 , item_id_generator_(0)
118 connect_signal<event::REQUEST_PLACEMENT>(
127 , item_builder_(builder.item_definition)
128 , item_id_generator_(0)
129 , placer_(
tplacer_::
build(builder.grow_direction, builder.parallel_items))
131 connect_signal<event::REQUEST_PLACEMENT>(
139 return new tpane(builder);
143 const std::map<std::string, std::string>& tags)
149 for(
const auto &
data : item_data)
152 = find_widget<tcontrol>(item.
grid,
data.first,
false,
false);
172 assert(origin.
x == 0);
173 assert(origin.
y == 0);
187 item.grid->layout_initialise(full_initialisation);
200 item.grid->draw_children(frame_buffer, x_offset, y_offset);
206 const std::vector<twidget*>& call_stack)
210 std::vector<twidget*> child_call_stack = call_stack;
211 item.grid->populate_dirty_list(caller, child_call_stack);
217 items_.sort(compare_functor);
226 item.grid->set_visible(filter_functor(item)
244 const bool must_be_active)
const
289 item.grid->place(origin, item.grid->get_best_size());
305 item.grid->set_origin(origin);
321 if(item.grid->get_size() != item.grid->get_best_size()) {
322 item.grid->place(origin, item.grid->get_best_size());
324 item.grid->set_origin(origin);
335 for(
const auto & item :
items_)
341 placer_->add_item(item.grid->get_best_size());
355 if(item.grid->has_widget(*widget)) {
372 item.grid->place(
tpoint(0, 0), item.grid->get_best_size());
375 DBG_GUI_E << LOG_HEADER <<
' ' <<
event <<
" handled.\n";
382 DBG_GUI_E << LOG_HEADER <<
' ' <<
event <<
" failed to handle.\n";
430 , parallel_items(cfg[
"parallel_items"])
431 , item_definition(new
tbuilder_grid(cfg.child(
"item_definition",
"[pane]")))
Define the common log macros for the gui toolkit.
void filter(const tfilter_functor &filter_functor)
Filters the contents of the pane.
static tpane * build(const implementation::tbuilder_pane &builder)
virtual void place(const tpoint &origin, const tpoint &size) override
See twidget::place.
virtual void impl_draw_children(surface &frame_buffer, int x_offset, int y_offset) override
See twidget::impl_draw_children.
twindow * build(CVideo &video, const twindow_builder::tresolution *definition)
Builds a window.
Helper to implement private functions without modifying the header.
void prepare_placement() const
Updates the placement for the child items.
Base class for the placement helper.
std::function< bool(const titem &, const titem &)> tcompare_functor
virtual iterator::twalker_ * create_walker() override
See twidget::create_walker.
virtual tpoint calculate_best_size() const override
See twidget::calculate_best_size.
void signal_handler_request_placement(tdispatcher &dispatcher, const event::tevent event, bool &handled)
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
To lexical_cast(From value)
Lexical cast converts one type to another.
unsigned create_item(const std::map< std::string, string_map > &item_data, const std::map< std::string, std::string > &tags)
Creates a new item.
tgrid * grid(const unsigned id)
Returns a grid in the pane.
base class of top level items, the only item which needs to store the final canvases to draw on ...
A class inherited from ttext_box that displays its input as stars.
tpane(const tbuilder_grid_ptr item_builder)
tbuilder_grid_ptr item_builder_
The builer for the items in the list.
static UNUSEDNOWARN std::string _(const char *str)
#define VALIDATE(cond, message)
The macro to use for the validation of WML.
virtual twidget * find_at(const tpoint &coordinate, const bool must_be_active) override
See twidget::find_at.
bool fire(const tevent event, twidget &target)
Fires an event which has no extra parameters.
std::list< titem > items_
The items in the pane.
virtual void child_populate_dirty_list(twindow &caller, const std::vector< twidget * > &call_stack) override
See twidget::child_populate_dirty_list.
This file contains the defintions for the gui2::event::tmessage class.
Request for somebody to place the widget.
tevent
The event send to the dispatcher.
std::function< bool(const titem &)> tfilter_functor
static utils::tconst_clone< twidget, W >::pointer find_at(W pane, tpoint coordinate, const bool must_be_active)
Implementation for the wrappers for [const] twidget* tpane::find_at(const tpoint&, const bool) [const].
void set_origin_children()
Moves the children on the pane.
D * pointer
A pointer to the destination type, possibly const qualified.
tbuilder_pane(const config &cfg)
Base class for all visible items.
virtual void set_members(const string_map &data)
Sets the members of the control.
GLsizei GLenum GLuint GLuint GLsizei char * message
std::unique_ptr< tplacer_ > placer_
Helper to do the placement.
void place_or_set_origin_children()
Places or moves the children on the pane.
void layout_linked_widgets()
Layouts the linked widgets.
The walker abstract base class.
virtual void request_reduce_width(const unsigned maximum_width) override
See twidget::request_reduce_width.
A config object defines a single node in a WML file, with access to child nodes.
static utils::tconst_clone< tgrid, W >::pointer grid(W pane, const unsigned id)
Implementation for the wrappers for [const] tgrid* tpane::grid(const unsigned id) [const]...
void place_children()
Places the children on the pane.
bool disable_click_dismiss() const override
See twidget::disable_click_dismiss.
Contains the implementation details for lexical_cast and shouldn't be used directly.
void sort(const tcompare_functor &compare_functor)
Sorts the contents of the pane.
virtual void layout_initialise(const bool full_initialisation) override
See twidget::layout_initialise.
unsigned item_id_generator_
The id generator for the items.