The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
tree_view_node.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2016 by Mark de Wever <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #define GETTEXT_DOMAIN "wesnoth-lib"
16 
18 
19 #include "gettext.hpp"
21 #include "gui/core/log.hpp"
25 
26 #include "utils/functional.hpp"
27 
28 #define LOG_SCOPE_HEADER \
29  get_control_type() + " [" + tree_view().id() + "] " + __func__
30 #define LOG_HEADER LOG_SCOPE_HEADER + ':'
31 
32 namespace gui2
33 {
34 
36  const std::string& id,
37  const std::vector<tnode_definition>& node_definitions,
38  ttree_view_node* parent_node,
39  ttree_view& parent_tree_view,
40  const std::map<std::string /* widget id */, string_map>& data)
41  : twidget()
42  , parent_node_(parent_node)
43  , tree_view_(parent_tree_view)
44  , grid_()
45  , children_()
46  , node_definitions_(node_definitions)
47  , toggle_(nullptr)
48  , label_(nullptr)
49  , unfolded_(false)
50  , callback_state_change_()
51  , callback_state_to_folded_()
52  , callback_state_to_unfolded_()
53 {
54  grid_.set_parent(this);
55  set_parent(&parent_tree_view);
56  if(id != "root") {
57  for(const auto & node_definition : node_definitions_)
58  {
59  if(node_definition.id == id) {
60  node_definition.builder->build(&grid_);
61  init_grid(&grid_, data);
62 
63  twidget* toggle_widget = grid_.find("tree_view_node_icon", false);
64  toggle_ = dynamic_cast<tselectable_*>(toggle_widget);
65 
66  if(toggle_) {
67  toggle_widget->set_visible(twidget::tvisible::hidden);
68  toggle_widget->connect_signal<event::LEFT_BUTTON_CLICK>(std::bind(
70  this,
71  _2));
72  toggle_widget->connect_signal<event::LEFT_BUTTON_CLICK>(std::bind(
74  this,
76 
77  if(node_definition.unfolded) {
78  toggle_->set_value(1);
79  unfolded_ = true;
80  }
81  }
82 
84  dynamic_cast<twidget&>(*parent_node_->toggle_).set_visible(
86  }
87 
88  twidget* widget = find_widget<twidget>(
89  &grid_, "tree_view_node_label", false, false);
90 
91  label_ = dynamic_cast<tselectable_*>(widget);
92  if(label_) {
94  std::bind(
97  this,
98  _2,
99  _3,
100  _4),
103  std::bind(
104  &ttree_view_node::
105  signal_handler_label_left_button_click,
106  this,
107  _2,
108  _3,
109  _4),
111 
112  if(!tree_view().selected_item_) {
113  tree_view().selected_item_ = this;
114  label_->set_value(true);
115  }
116  }
117 
118  return;
119  }
120  }
121 
122  VALIDATE(false, _("Unknown builder id for tree view node."));
123  }
124  else {
125  unfolded_ = true;
126  }
127 }
128 
130 {
131  if(/*tree_view() &&*/ tree_view().selected_item_ == this) {
132  tree_view().selected_item_ = nullptr;
133  }
134 }
135 
137  const std::string& id,
138  const std::map<std::string /* widget id */, string_map>& data,
139  const int index)
140 {
141 
143 
144  if(static_cast<size_t>(index) < children_.size()) {
145  itor = children_.begin() + index;
146  }
147 
148  itor = children_.insert(
149  itor,
150  new ttree_view_node(
151  id, node_definitions_, this, tree_view(), data));
152 
153  if(is_folded() || is_root_node()) {
154  return *itor;
155  }
156 
157  if(tree_view().get_size() == tpoint(0, 0)) {
158  return *itor;
159  }
160 
161  assert(tree_view().content_grid());
162  const int current_width = tree_view().content_grid()->get_width();
163 
164  // Calculate width modification.
165  tpoint best_size = itor->get_best_size();
167  const unsigned width_modification
168  = best_size.x > current_width ? best_size.x - current_width : 0;
169 
170  // Calculate height modification.
171  const int height_modification = best_size.y;
172  assert(height_modification > 0);
173 
174  // Request new size.
175  tree_view().resize_content(width_modification, height_modification, -1, itor->calculate_ypos());
176 
177  return *itor;
178 }
179 
181 {
182  unsigned level = 0;
183 
184  const ttree_view_node* node = this;
185  while(!node->is_root_node()) {
186  node = &node->parent_node();
187  ++level;
188  }
189 
190  return level;
191 }
192 
194 {
195  assert(!is_root_node());
196  return *parent_node_;
197 }
198 
200 {
201  assert(!is_root_node());
202  return *parent_node_;
203 }
204 
206 {
207  return tree_view_;
208 }
209 
210 void ttree_view_node::request_reduce_width(const unsigned /*maximum_width*/)
211 {
212  /* DO NOTHING */
213 }
214 
216 {
217  return tree_view_;
218 }
219 
221 {
222  return !unfolded_;
223 }
224 
225 void ttree_view_node::fold(/*const bool recursive*/)
226 {
227  if(is_folded()) {
228  fold_internal();
229  if(toggle_) {
230  toggle_->set_value(false);
231  }
232  }
233 }
234 
235 void ttree_view_node::unfold(/*const texpand_mode mode*/)
236 {
237  if(!is_folded()) {
238  unfold_internal();
239  if(toggle_) {
240  toggle_->set_value(true);
241  }
242  }
243 }
244 
246 {
247  const tpoint current_size(get_current_size().x, get_unfolded_size().y);
248  const tpoint new_size = get_folded_size();
249 
250  const int width_modification = std::max(0, new_size.x - current_size.x);
251  const int height_modification = new_size.y - current_size.y;
252  assert(height_modification <= 0);
253 
254  tree_view().resize_content(width_modification, height_modification, -1, calculate_ypos());
255  unfolded_ = false;
256 
259  }
260 }
261 
263 {
264  const tpoint current_size(get_current_size().x, get_folded_size().y);
265  const tpoint new_size = get_unfolded_size();
266 
267  const int width_modification = std::max(0, new_size.x - current_size.x);
268  const int height_modification = new_size.y - current_size.y;
269  assert(height_modification >= 0);
270 
271  tree_view().resize_content(width_modification, height_modification, -1, calculate_ypos());
272  unfolded_ = true;
273 
276  }
277 }
278 
280 {
281  /** @todo Also try to find the optimal width. */
282  int height_reduction = 0;
283 
284  if(!is_folded()) {
285  for(const auto & node : children_)
286  {
287  height_reduction += node.get_current_size().y;
288  }
289  }
290 
291  children_.clear();
292 
293  if(height_reduction == 0) {
294  return;
295  }
296 
297  tree_view().resize_content(0, -height_reduction, -1, calculate_ypos());
298 }
299 
301 {
302 private:
303  template <class W, class It>
304  static W* find_at_aux(It begin,
305  It end,
306  const tpoint& coordinate,
307  const bool must_be_active)
308  {
309  for(It it = begin; it != end; ++it) {
310  if(W* widget = it->find_at(coordinate, must_be_active)) {
311  return widget;
312  }
313  }
314  return nullptr;
315  }
316 
317 public:
318  template <class W>
320  W>::reference tree_view_node,
321  const tpoint& coordinate,
322  const bool must_be_active)
323  {
324  if(W* widget
325  = tree_view_node.grid_.find_at(coordinate, must_be_active)) {
326 
327  return widget;
328  }
329 
330  if(tree_view_node.is_folded()) {
331  return nullptr;
332  }
333 
334  return find_at_aux<W>(tree_view_node.children_.begin(),
335  tree_view_node.children_.end(),
336  coordinate,
337  must_be_active);
338  }
339 };
340 
342  const bool must_be_active)
343 {
344  return ttree_view_node_implementation::find_at<twidget>(
345  *this, coordinate, must_be_active);
346 }
347 
348 const twidget* ttree_view_node::find_at(const tpoint& coordinate,
349  const bool must_be_active) const
350 {
351  return ttree_view_node_implementation::find_at<const twidget>(
352  *this, coordinate, must_be_active);
353 }
354 
355 twidget* ttree_view_node::find(const std::string& id, const bool must_be_active)
356 {
357  twidget* result = twidget::find(id, must_be_active);
358  return result ? result : grid_.find(id, must_be_active);
359 }
360 
362  const bool must_be_active) const
363 {
364  const twidget* result = twidget::find(id, must_be_active);
365  return result ? result : grid_.find(id, must_be_active);
366 }
367 
369  twindow& caller, const std::vector<twidget*>& call_stack)
370 {
371  std::vector<twidget*> child_call_stack = call_stack;
372  grid_.populate_dirty_list(caller, child_call_stack);
373 
374  if(is_folded()) {
375  return;
376  }
377 
378  for(auto & node : children_)
379  {
380  std::vector<twidget*> child_call_stack = call_stack;
381  node.impl_populate_dirty_list(caller, child_call_stack);
382  }
383 }
384 
386 {
387  return calculate_best_size(-1, tree_view().indention_step_size_);
388 }
389 
391 {
392  return true;
393 }
394 
395 tpoint ttree_view_node::get_current_size(bool assume_visible) const
396 {
397  if(!assume_visible && parent_node_ && parent_node_->is_folded()) {
398  return tpoint(0, 0);
399  }
400 
402  if(is_folded()) {
403  return size;
404  }
405 
406  for(boost::ptr_vector<ttree_view_node>::const_iterator itor
407  = children_.begin();
408  itor != children_.end();
409  ++itor) {
410 
411  const ttree_view_node& node = *itor;
412 
414  continue;
415  }
416 
417  tpoint node_size = node.get_current_size();
418 
419  size.y += node_size.y;
420  size.x = std::max(size.x, node_size.x);
421  }
422 
423  return size;
424 }
425 
427 {
429  if(get_indention_level() > 1) {
430  size.x += (get_indention_level() - 1)
432  }
433  return size;
434 }
435 
437 {
439  if(get_indention_level() > 1) {
440  size.x += (get_indention_level() - 1)
442  }
443 
444  for(boost::ptr_vector<ttree_view_node>::const_iterator itor
445  = children_.begin();
446  itor != children_.end();
447  ++itor) {
448 
449  const ttree_view_node& node = *itor;
450 
452  continue;
453  }
454 
455  tpoint node_size = node.get_current_size(true);
456 
457  size.y += node_size.y;
458  size.x = std::max(size.x, node_size.x);
459  }
460 
461  return size;
462 }
463 
465  const unsigned indention_step_size)
466  const
467 {
469 
470  tpoint best_size = grid_.get_best_size();
471  if(indention_level > 0) {
472  best_size.x += indention_level * indention_step_size;
473  }
474 
475  DBG_GUI_L << LOG_HEADER << " own grid best size " << best_size << ".\n";
476 
477  for(boost::ptr_vector<ttree_view_node>::const_iterator itor
478  = children_.begin();
479  itor != children_.end();
480  ++itor) {
481 
482  const ttree_view_node& node = *itor;
483 
485  continue;
486  }
487 
488  const tpoint node_size = node.calculate_best_size(indention_level + 1,
489  indention_step_size);
490 
491  if(!is_folded()) {
492  best_size.y += node_size.y;
493  }
494  best_size.x = std::max(best_size.x, node_size.x);
495  }
496 
497  DBG_GUI_L << LOG_HEADER << " result " << best_size << ".\n";
498  return best_size;
499 }
500 
502 {
503  // Inherited.
504  twidget::set_origin(origin);
505 
506  // Using layout_children seems to fail.
507  place(tree_view().indention_step_size_, origin, get_size().x);
508 }
509 
510 void ttree_view_node::place(const tpoint& origin, const tpoint& size)
511 {
512  // Inherited.
513  twidget::place(origin, size);
514 
515  tree_view().layout_children(true);
516 }
517 
518 unsigned ttree_view_node::place(const unsigned indention_step_size,
519  tpoint origin,
520  unsigned width)
521 {
523  DBG_GUI_L << LOG_HEADER << " origin " << origin << ".\n";
524 
525  const unsigned offset = origin.y;
526  tpoint best_size = grid_.get_best_size();
527  best_size.x = width;
528  grid_.place(origin, best_size);
529 
530  if(!is_root_node()) {
531  origin.x += indention_step_size;
532  assert(width >= indention_step_size);
533  width -= indention_step_size;
534  }
535  origin.y += best_size.y;
536 
537  if(is_folded()) {
538  DBG_GUI_L << LOG_HEADER << " folded node done.\n";
539  return origin.y - offset;
540  }
541 
542  DBG_GUI_L << LOG_HEADER << " set children.\n";
543  for(auto & node : children_)
544  {
545  origin.y += node.place(indention_step_size, origin, width);
546  }
547 
548  // Inherited.
549  twidget::set_size(tpoint(width, origin.y - offset));
550 
551  DBG_GUI_L << LOG_HEADER << " result " << (origin.y - offset) << ".\n";
552  return origin.y - offset;
553 }
554 
555 void ttree_view_node::set_visible_rectangle(const SDL_Rect& rectangle)
556 {
558  DBG_GUI_L << LOG_HEADER << " rectangle " << rectangle << ".\n";
559  grid_.set_visible_rectangle(rectangle);
560 
561  if(is_folded()) {
562  DBG_GUI_L << LOG_HEADER << " folded node done.\n";
563  return;
564  }
565 
566  for(auto & node : children_)
567  {
568  node.set_visible_rectangle(rectangle);
569  }
570 }
571 
573  int x_offset,
574  int y_offset)
575 {
576  grid_.draw_children(frame_buffer, x_offset, y_offset);
577 
578  if(is_folded()) {
579  return;
580  }
581 
582  for(auto & node : children_)
583  {
584  node.impl_draw_children(frame_buffer, x_offset, y_offset);
585  }
586 }
587 
588 void
590 {
591  DBG_GUI_E << LOG_HEADER << ' ' << event << ".\n";
592 
593  /**
594  * @todo Rewrite this sizing code for the folding/unfolding.
595  *
596  * The code works but feels rather hacky, so better move back to the
597  * drawingboard for 1.9.
598  */
599  const bool unfolded_new = toggle_->get_value_bool();
600  if(unfolded_ == unfolded_new) {
601  return;
602  }
603  unfolded_ = unfolded_new;
605 
607  callback_state_change_(*this);
608  }
609 }
610 
612  const event::tevent event, bool& handled, bool& halt)
613 {
614  DBG_GUI_E << LOG_HEADER << ' ' << event << ".\n";
615 
616  assert(label_);
617 
618  // We only snoop on the event so normally don't touch the handled, else if
619  // we snoop in preexcept when halting.
620 
621  if(label_->get_value()) {
622  // Forbid deselecting
623  halt = handled = true;
624  } else {
625  // Deselect current item
628  }
629 
630  tree_view().selected_item_ = this;
631 
632  if(tree_view().selection_change_callback_) {
634  }
635  }
636 }
637 
639  tgrid* grid,
640  const std::map<std::string /* widget id */, string_map>& data)
641 {
642  assert(grid);
643 
644  for(unsigned row = 0; row < grid->get_rows(); ++row) {
645  for(unsigned col = 0; col < grid->get_cols(); ++col) {
646  twidget* widget = grid->widget(row, col);
647  assert(widget);
648 
649  tgrid* child_grid = dynamic_cast<tgrid*>(widget);
650  // ttoggle_button* btn =
651  // dynamic_cast<ttoggle_button*>(widget);
652  ttoggle_panel* panel = dynamic_cast<ttoggle_panel*>(widget);
653  tcontrol* ctrl = dynamic_cast<tcontrol*>(widget);
654 
655  if(panel) {
656  panel->set_child_members(data);
657  } else if(child_grid) {
658  init_grid(child_grid, data);
659  } else if(ctrl) {
660  std::map<std::string, string_map>::const_iterator itor
661  = data.find(ctrl->id());
662 
663  if(itor == data.end()) {
664  itor = data.find("");
665  }
666  if(itor != data.end()) {
667  ctrl->set_members(itor->second);
668  }
669  // ctrl->set_members(data);
670  } else {
671 
672  // ERROR_LOG("Widget type '" << typeid(*widget).name() << "'.");
673  }
674  }
675  }
676 }
677 
679 {
680  static const std::string type = "tree_view_node";
681  return type;
682 }
683 
685 {
686  assert(static_cast<size_t>(index) < children_.size());
687  return children_[index];
688 }
689 
691 {
692  if(is_root_node()) {
693  return std::vector<int>();
694  }
695  else {
696  std::vector<int> res = parent_node_->describe_path();
697  const boost::ptr_vector<ttree_view_node>& parents_childs = parent_node_->children_;
698  for(int i = 0, size = parents_childs.size(); i < size; ++i) {
699  if(&parents_childs[i] == this) {
700  res.push_back(i);
701  return res;
702  }
703  }
704  assert(!"tree_view_node was not found in parent nodes children");
705  throw "assertion ignored"; //To silence 'no return value in this codepath' warning.
706  }
707 }
709 {
710  if(!parent_node_) {
711  return 0;
712  }
714  for(const auto& node : parent_node_->children_) {
715  if(&node == this) {
716  break;
717  }
718  res += node.get_current_size(true).y;
719  }
720  return res;
721 }
723 {
724  if(!parent_node_) {
725  return this;
726  }
728  return res == parent_node_ && !res->is_folded() ? this : res;
729 }
730 
732 {
733  assert(!is_root_node());
734  ttree_view_node* cur = nullptr;
735  for(size_t i = 0; i < parent_node_->size(); ++i) {
736  if(&parent_node_->children_[i] == this) {
737  if(i == 0) {
738  return parent_node_->is_root_node() ? nullptr : parent_node_;
739  }
740  else {
741  cur = &parent_node_->children_[i - 1];
742  break;
743  }
744  }
745  }
746  while(!cur->is_folded() && cur->size() > 0) {
747  cur = &cur->get_child_at(cur->size() - 1);
748  }
749  return cur;
750 }
751 
753 {
754  assert(!is_root_node());
755  if(!is_folded() && size() > 0) {
756  return &get_child_at(0);
757  }
758  ttree_view_node* cur = this;
759  while(cur->parent_node_ != nullptr) {
761 
762  for(size_t i = 0; i < parent.size(); ++i) {
763  if(&parent.children_[i] == cur) {
764  if(i < parent.size() - 1) {
765  return &parent.children_[i + 1];
766  }
767  else {
768  cur = &parent;
769  }
770  break;
771  }
772  }
773  }
774  return nullptr;
775 }
777 {
778  ttree_view_node* above = this;
779  do {
780  above = above->get_node_above();
781  } while(above != nullptr && above->label_ == nullptr);
782  return above;
783 }
785 {
786  ttree_view_node* below = this;
787  do {
788  below = below->get_node_below();
789  } while(below != nullptr && below->label_ == nullptr);
790  return below;
791 
792 }
794 {
795  if(!label_ || label_->get_value_bool()) {
796  return;
797  }
798 
801  }
802  tree_view().selected_item_ = this;
803 
804  if(tree_view().selection_change_callback_) {
806  }
807  label_->set_value_bool(true);
808 }
809 
810 void ttree_view_node::layout_initialise(const bool full_initialisation)
811 {
812  // Inherited.
813  twidget::layout_initialise(full_initialisation);
814  grid_.layout_initialise(full_initialisation);
815  // Clear child caches.
816  for(auto & child : children_)
817  {
818  child.layout_initialise(full_initialisation);
819  }
820 }
821 } // namespace gui2
Define the common log macros for the gui toolkit.
unsigned get_width() const
Definition: widget.cpp:294
std::vector< int > describe_path()
calculates the node indicies that we need to get from the root node to this node. ...
tgrid grid_
Grid holding our contents.
ttree_view_node * get_selectable_node_above()
void signal_handler_label_left_button_click(const event::tevent event, bool &handled, bool &halt)
size_t size() const
The "size" of the widget.
ttree_view_node & parent_node()
Returns the parent node.
#define DBG_GUI_L
Definition: log.hpp:58
unsigned indention_step_size_
Definition: tree_view.hpp:119
tselectable_ * toggle_
The toggle for the folded state.
void set_parent(twidget *parent)
Definition: widget.cpp:150
GLint level
Definition: glew.h:1220
virtual unsigned get_value() const =0
Is the control selected?
const std::vector< tnode_definition > & node_definitions_
The node definitions known to use.
bool is_folded() const
Is the node folded?
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1221
virtual void request_reduce_width(const unsigned maximum_width) override
See twidget::request_reduce_width.
Base container class.
Definition: grid.hpp:29
tvisible::scoped_enum get_visible() const
Definition: widget.cpp:471
tpoint get_size() const
Returns the size of the widget.
Definition: widget.cpp:274
unsigned int get_rows() const
Definition: grid.hpp:288
lg::log_domain log_gui_layout("gui/layout")
Definition: log.hpp:57
virtual void place(const tpoint &origin, const tpoint &size) override
See twidget::place.
Definition: grid.cpp:435
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1220
ttree_view_node * selected_item_
Definition: tree_view.hpp:125
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
Definition: glew.h:1347
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.
Definition: dispatcher.hpp:278
tpoint get_current_size(bool assume_visible=false) const
ttree_view_node & add_child(const std::string &id, const std::map< std::string, string_map > &data, const int index=-1)
Adds a child item to the list of child nodes.
tpoint get_best_size() const
Gets the best size for the widget.
Definition: widget.cpp:188
tpoint get_unfolded_size() const
virtual void layout_initialise(const bool full_initialisation)
How the layout engine works.
Definition: widget.cpp:162
virtual void set_value(const unsigned)=0
Select the control.
ttree_view_node * get_selectable_node_below()
A left mouse button click event for a widget.
Definition: handler.hpp:84
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:62
A class inherited from ttext_box that displays its input as stars.
Definition: field-fwd.hpp:23
std::function< void(twidget &)> selection_change_callback_
Definition: tree_view.hpp:127
GLintptr offset
Definition: glew.h:1650
twidget * parent()
Definition: widget.cpp:155
virtual tpoint calculate_best_size() const override
See twidget::calculate_best_size.
The user set the widget invisible, that means:
Definition: widget.hpp:103
static UNUSEDNOWARN std::string _(const char *str)
Definition: gettext.hpp:82
GLuint GLuint end
Definition: glew.h:1221
GLuint64EXT * result
Definition: glew.h:10727
#define VALIDATE(cond, message)
The macro to use for the validation of WML.
ttree_view & tree_view()
virtual void set_visible_rectangle(const SDL_Rect &rectangle) override
See twidget::set_visible_rectangle.
int y
y coordinate.
Definition: point.hpp:34
static W * find_at_aux(It begin, It end, const tpoint &coordinate, const bool must_be_active)
void populate_dirty_list(twindow &caller, std::vector< twidget * > &call_stack)
Adds a widget to the dirty list if it is dirty.
Definition: widget.cpp:386
bool get_value_bool() const
Definition: selectable.hpp:48
boost::ptr_vector< ttree_view_node > children_
Our children.
void signal_handler_left_button_click(const event::tevent event)
void impl_populate_dirty_list(twindow &caller, const std::vector< twidget * > &call_stack)
"Inherited" from twidget.
void draw_children(surface &frame_buffer, int x_offset, int y_offset)
Draws the children of a widget.
Definition: widget.cpp:356
The user sets the widget hidden, that means:
Definition: widget.hpp:91
#define log_scope2(domain, description)
Definition: log.hpp:186
std::function< void(twidget &)> callback_state_to_unfolded_
See tselectable_::set_callback_state_change.
virtual void place(const tpoint &origin, const tpoint &size)
Places the widget.
Definition: widget.cpp:233
tevent
The event send to the dispatcher.
Definition: handler.hpp:54
#define LOG_HEADER
std::function< void(twidget &)> callback_state_change_
See tselectable_::set_callback_state_change.
ttree_view_node * get_node_above()
Small abstract helper class.
Definition: selectable.hpp:32
int x
x coordinate.
Definition: point.hpp:31
virtual void set_visible_rectangle(const SDL_Rect &rectangle) override
See twidget::set_visible_rectangle.
Definition: grid.cpp:560
static W * find_at(typename utils::tconst_clone< ttree_view_node, W >::reference tree_view_node, const tpoint &coordinate, const bool must_be_active)
void init_grid(tgrid *grid, const std::map< std::string, string_map > &data)
GLuint res
Definition: glew.h:9258
The user sets the widget visible, that means:
Definition: widget.hpp:79
std::map< std::string, tfilter >::iterator itor
Definition: filter.cpp:199
ttree_view_node * get_node_below()
#define DBG_GUI_E
Definition: log.hpp:35
tselectable_ * label_
The label to show our selected state.
unsigned get_indention_level() const
The indention level of the node.
GLuint index
Definition: glew.h:1782
const std::string & id() const
Definition: widget.cpp:109
size_t i
Definition: function.cpp:1057
Holds a 2D point.
Definition: point.hpp:24
GLint GLint GLint GLint GLint x
Definition: glew.h:1220
Helper struct to clone the constness of one type to another.
Definition: const_clone.hpp:47
virtual twidget * find_at(const tpoint &coordinate, const bool must_be_active) override
See twidget::find_at.
bool is_root_node() const
Is this node the root node?
virtual void place(const tpoint &origin, const tpoint &size) override
See twidget::place.
Base class for all visible items.
Definition: control.hpp:34
void set_child_members(const std::map< std::string, string_map > &data)
Sets the members of the child controls.
twidget * find(const std::string &id, const bool must_be_active) override
See twidget::find.
GLsizeiptr size
Definition: glew.h:1649
ttree_view & tree_view_
The tree view that owns us.
GLenum GLenum GLvoid * row
Definition: glew.h:3805
virtual void set_origin(const tpoint &origin)
Sets the origin of the widget.
Definition: widget.cpp:216
tpoint get_folded_size() const
#define LOG_SCOPE_HEADER
cl_event event
Definition: glew.h:3070
virtual void set_members(const string_map &data)
Sets the members of the control.
Definition: control.cpp:99
bool disable_click_dismiss() const override
See twidget::disable_click_dismiss.
Base class for all widgets.
Definition: widget.hpp:49
const std::string & get_control_type() const
Returns the control_type of the ttree_view_node.
virtual void set_origin(const tpoint &origin) override
See twidget::set_origin.
std::function< void(twidget &)> callback_state_to_folded_
See tselectable_::set_callback_state_change.
virtual void layout_initialise(const bool full_initialisation) override
See twidget::layout_initialise.
Definition: grid.cpp:191
ttree_view_node * parent_node_
Our parent node.
twidget * find(const std::string &id, const bool must_be_active) override
See twidget::find.
Definition: grid.cpp:612
GLint GLint GLint GLint GLint GLint GLsizei width
Definition: glew.h:1220
const twidget * widget(const unsigned row, const unsigned col) const
Returns the widget in the selected cell.
Definition: grid.hpp:176
void set_value_bool(const bool value)
Definition: selectable.hpp:54
ttree_view_node & get_child_at(int index)
std::string::const_iterator iterator
Definition: tokenizer.hpp:21
Class for a toggle button.
ttree_view_node * get_last_visible_parent_node()
virtual void set_size(const tpoint &size)
Sets the size of the widget.
Definition: widget.cpp:222
virtual twidget * find(const std::string &id, const bool must_be_active)
Returns a widget with the wanted id.
Definition: widget.cpp:558
virtual void layout_children() override
See twidget::layout_children.
Definition: tree_view.cpp:112
unsigned int get_cols() const
Definition: grid.hpp:294
void set_visible(const tvisible::scoped_enum visible)
Definition: widget.cpp:445
ttree_view_node(const std::string &id, const std::vector< tnode_definition > &node_definitions, ttree_view_node *parent_node, ttree_view &parent_tree_view, const std::map< std::string, string_map > &data)
GLsizei const GLcharARB ** string
Definition: glew.h:4503
void resize_content(const int width_modification, const int height_modification, const int width__modification_pos=-1, const int height_modification_pos=-1)
Resizes the content.
Definition: tree_view.cpp:117
virtual void impl_draw_children(surface &frame_buffer, int x_offset, int y_offset) override
See twidget::impl_draw_children.
void clear()
Removes all child items from the widget.
void layout_initialise(const bool full_initialisation)
How the layout engine works.