15 #define GETTEXT_DOMAIN "wesnoth-lib"
18 #ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
24 #ifdef GUI2_EXPERIMENTAL_LISTBOX
61 +
'_' + std::to_string(col);
79 return get_child_id(parent_id, row, col) +
"_W";
86 time_t
t = time(
nullptr);
87 tm* lt = localtime(&t);
89 strftime(buf,
sizeof(buf),
"%Y%m%d_%H%M%S", lt);
94 return (
formatter() << buf <<
'_' << counter <<
'_').str();
98 const unsigned ALL = UINT_MAX;
100 const unsigned SIZE_INFO = 1 << 0;
104 const unsigned STATE_INFO = 1 << 1;
108 unsigned domain_ = 0;
111 tdebug_layout_graph::tdebug_layout_graph(
const twindow* window)
112 : window_(window), sequence_number_(0), filename_base_(get_base_filename())
125 for(
const auto &
param : params)
132 }
else if(
param ==
"size") {
134 }
else if(
param ==
"state") {
135 level_ |= STATE_INFO;
138 std::cerr <<
"Unknown level '" <<
param <<
"' is ignored.\n";
143 void tdebug_layout_graph::set_domain(
const std::string& domain)
153 for(
const auto &
param : params)
160 }
else if(
param ==
"show") {
162 }
else if(
param ==
"layout") {
166 std::cerr <<
"Unknown domain '" <<
param <<
"' is ignored.\n";
172 const unsigned domain)
175 if((domain_ & domain) != domain) {
184 + std::to_string(++sequence_number_)
185 +
"-" + generator +
".dot";
187 std::ofstream file(filename.c_str());
189 file <<
"//Basic layout graph for window id '" << window_->id()
190 <<
"' using definition '" << window_->definition_ <<
"'.\n"
191 <<
"digraph window {\n"
192 <<
"\tnode [shape=record, style=filled, fillcolor=\"bisque\"];\n"
193 <<
"\trankdir=LR;\n";
195 widget_generate_info(file, window_,
"root");
200 void tdebug_layout_graph::widget_generate_info(std::ostream& out,
201 const twidget* widget,
203 const bool embedded)
const
208 <<
" [label=<<table border=\"0\" cellborder=\"1\" cellspacing=\"0\">";
210 widget_generate_basic_info(out, widget);
211 if(level_ & STATE_INFO)
212 widget_generate_state_info(out, widget);
213 if(level_ & SIZE_INFO)
214 widget_generate_size_info(out, widget);
218 out <<
", fillcolor=\"palegoldenrod\"";
222 const tgrid*
grid =
dynamic_cast<const tgrid*
>(widget);
224 const tcontainer_* container =
dynamic_cast<const tcontainer_*
>(widget);
228 widget_generate_info(out, &container->grid(),
id +
"_G",
true);
229 out <<
"\t" <<
id <<
" -> " <<
id <<
"_G"
230 <<
" [label=\"(grid)\"];\n";
233 const tscrollbar_container* scrollbar_container
234 =
dynamic_cast<const tscrollbar_container*
>(widget);
236 if(scrollbar_container) {
237 widget_generate_info(
238 out, scrollbar_container->content_grid_,
id +
"_C",
true);
239 out <<
"\t" <<
id <<
" -> " <<
id <<
"_C"
240 <<
" [label=\"(content)\"];\n";
243 const tlistbox* listbox =
dynamic_cast<const tlistbox*
>(widget);
245 assert(listbox->generator_);
248 const tgenerator_* generator =
dynamic_cast<const tgenerator_*
>(widget);
251 for(
size_t i = 0;
i < generator->get_item_count(); ++
i) {
256 widget_generate_info(out, &generator->item(
i), child_id,
true);
258 out <<
"\t" <<
id <<
" -> " << child_id
259 <<
" [label=\"(item)\"];\n";
264 grid_generate_info(out, grid,
id);
270 if(label.size() > 50) {
271 label = label.substr(0, 50) +
"...";
280 void tdebug_layout_graph::widget_generate_basic_info(std::ostream& out,
281 const twidget* widget)
285 = level_ & (SIZE_INFO | STATE_INFO) ?
" bgcolor=\"gray\"" :
"";
286 const tcontrol* control =
dynamic_cast<const tcontrol*
>(widget);
288 out <<
"<tr><td" << header_background <<
">" <<
'\n'
289 <<
"type=" << get_type(widget) <<
'\n' <<
"</td></tr>" <<
'\n'
290 <<
"<tr><td" << header_background <<
">" <<
'\n'
291 <<
"id=" << widget->id() <<
'\n' <<
"</td></tr>" <<
'\n' <<
"<tr><td"
292 << header_background <<
">" <<
'\n' <<
"address=" << widget <<
'\n'
293 <<
"</td></tr>" <<
'\n' <<
"<tr><td" << header_background <<
">" <<
'\n'
294 <<
"parent=" << widget->parent_ <<
'\n' <<
"</td></tr>" <<
'\n';
296 out <<
"<tr><td" << header_background <<
">" <<
'\n'
297 <<
"label=" << format_label(control->label()) <<
'\n' <<
"<tr><td"
298 << header_background <<
">" <<
'\n'
299 <<
"definition=" << control->definition_ <<
'\n' <<
"</td></tr>"
300 <<
'\n' <<
"</td></tr>\n";
304 void tdebug_layout_graph::widget_generate_state_info(std::ostream& out,
305 const twidget* widget)
308 const tcontrol* control =
dynamic_cast<const tcontrol*
>(widget);
314 <<
"tooltip=" << control->tooltip() <<
'\n' <<
"</td></tr>\n"
316 <<
"help message" << control->help_message() <<
'\n'
320 <<
"active=" << control->get_active() <<
'\n' <<
"</td></tr>\n"
322 <<
"visible=" << control->get_visible() <<
'\n' <<
"</td></tr>\n"
324 <<
"drawing action=" << control->get_drawing_action() <<
'\n'
327 <<
"clip rect=" << control->clipping_rectangle_ <<
'\n'
330 <<
"use tooltip on label overflow="
331 << control->get_use_tooltip_on_label_overflow() <<
'\n'
334 <<
"does block click dismiss=" << control->disable_click_dismiss()
335 <<
'\n' <<
"</td></tr>\n";
337 const tscrollbar_container* scrollbar_container
338 =
dynamic_cast<const tscrollbar_container*
>(widget);
340 if(scrollbar_container) {
342 <<
"vertical_scrollbar_mode_="
343 << scrollbar_container->vertical_scrollbar_mode_ <<
'\n'
346 <<
"horizontal_scrollbar_mode_="
347 << scrollbar_container->horizontal_scrollbar_mode_ <<
'\n'
352 void tdebug_layout_graph::widget_generate_size_info(std::ostream& out,
353 const twidget* widget)
const
356 <<
"can wrap=" << widget->can_wrap() <<
'\n' <<
"</td></tr>\n"
358 <<
"size=" << widget->get_size() <<
'\n' <<
"</td></tr>\n"
360 <<
"position=" << widget->get_origin() <<
'\n' <<
"</td></tr>\n"
362 <<
"last_best_size_=" << widget->last_best_size_ <<
'\n'
365 <<
"layout_size_=" << widget->layout_size_ <<
'\n' <<
"</td></tr>\n";
368 const tcontrol* control =
dynamic_cast<const tcontrol*
>(widget);
372 <<
"minimum config size=" << control->get_config_minimum_size()
373 <<
'\n' <<
"</td></tr>\n"
375 <<
"default config size=" << control->get_config_default_size()
376 <<
'\n' <<
"</td></tr>\n"
378 <<
"maximum config size=" << control->get_config_maximum_size()
379 <<
'\n' <<
"</td></tr>\n"
381 <<
"shrunken_=" << control->shrunken_ <<
'\n' <<
"</td></tr>\n";
384 const tcontainer_* container =
dynamic_cast<const tcontainer_*
>(widget);
388 <<
"border_space=" << container->border_space() <<
'\n'
393 void tdebug_layout_graph::grid_generate_info(std::ostream& out,
397 assert(!parent_id.empty());
402 out <<
"\n\n\t// The children of " << parent_id <<
".\n";
404 for(
unsigned row = 0;
row < grid->get_rows(); ++
row) {
405 for(
unsigned col = 0; col < grid->get_cols(); ++col) {
407 const twidget* widget = grid->child(
row, col).widget();
410 widget_generate_info(
411 out, widget, get_child_widget_id(parent_id,
row, col));
415 out <<
"\n\t// The grid child data of " << parent_id <<
".\n";
417 for(
unsigned row = 0;
row < grid->get_rows(); ++
row) {
418 for(
unsigned col = 0; col < grid->get_cols(); ++col) {
420 child_generate_info(out,
421 grid->child(
row, col),
422 get_child_id(parent_id,
row, col));
427 out <<
"\n\t// The links of " << parent_id <<
".\n";
429 for(
unsigned row = 0;
row < grid->get_rows(); ++
row) {
430 for(
unsigned col = 0; col < grid->get_cols(); ++col) {
433 out <<
"\t" << parent_id <<
" -> "
434 << get_child_id(parent_id,
row, col) <<
" [label=\"(" <<
row
435 <<
',' << col <<
")\"];\n";
438 out <<
"\t" << get_child_id(parent_id,
row, col) <<
" -> "
439 << get_child_widget_id(parent_id,
row, col) <<
";\n";
444 void tdebug_layout_graph::child_generate_info(std::ostream& out,
445 const tgrid::tchild& child,
450 unsigned flags = child.get_flags();
452 out <<
"\t" <<
id <<
" [style=\"\", label=<<table border=\"0\" "
453 "cellborder=\"1\" cellspacing=\"0\">\n";
459 out <<
"send to client";
462 out <<
"align to top";
468 out <<
"align to bottom";
471 out <<
"unknown value("
476 out <<
"\n</td></tr>\n"
478 <<
"horizontal flag=";
482 out <<
"send to client";
485 out <<
"align to left";
491 out <<
"align to right";
494 out <<
"unknown value("
499 out <<
"\n</td></tr>\n"
501 <<
"border location=";
512 result +=
"bottom, ";
518 if(!result.empty()) {
519 result.resize(result.size() - 2);
525 out <<
"\n</td></tr>\n"
527 <<
"border_size=" << child.get_border_size() <<
"\n</td></tr>\n";
529 out <<
"</table>>];\n";
532 std::string tdebug_layout_graph::get_type(
const twidget* widget)
const
534 const tcontrol* control =
dynamic_cast<const tcontrol*
>(widget);
536 return control->get_control_type();
538 const tgrid* grid =
dynamic_cast<const tgrid*
>(widget);
539 const tgenerator_* generator =
dynamic_cast<const tgenerator_*
>(widget);
543 }
else if(generator) {
size_t strftime(char *str, size_t count, const std::string &format, const std::tm *time)
static const unsigned HORIZONTAL_SHIFT
static const unsigned BORDER_BOTTOM
static const unsigned BORDER_ALL
rng * generator
This generator is automatically synced during synced context.
static const unsigned HORIZONTAL_MASK
static const unsigned HORIZONTAL_ALIGN_RIGHT
static const unsigned VERTICAL_GROW_SEND_TO_CLIENT
static const unsigned HORIZONTAL_GROW_SEND_TO_CLIENT
static const unsigned BORDER_RIGHT
static const unsigned BORDER_TOP
static const unsigned VERTICAL_SHIFT
A class inherited from ttext_box that displays its input as stars.
static const unsigned HORIZONTAL_ALIGN_LEFT
GLenum GLuint GLsizei const char * buf
static const unsigned VERTICAL_ALIGN_TOP
cl_event GLbitfield flags
void set_level(const std::string &value)
static const unsigned VERTICAL_ALIGN_CENTER
std::string replace(std::string str, const std::string &src, const std::string &dst)
Replace all instances of src in str with dst.
GLenum GLenum GLvoid * row
static const unsigned HORIZONTAL_ALIGN_CENTER
std::vector< std::string > split(std::string const &val, const char c, const int flags)
Splits a (comma-)separated string into a vector of pieces.
static const unsigned VERTICAL_MASK
static const unsigned VERTICAL_ALIGN_BOTTOM
GLsizei const GLcharARB ** string
static const unsigned BORDER_LEFT