LayoutUtils: improve text dump of layout
- Show view names in addition to class names - Use class_name from ClassInfo.h to get class names (no functional change) - Use 4 spaces for indentation instead of 2
This commit is contained in:
@@ -12,8 +12,8 @@
|
|||||||
#include <LayoutUtils.h>
|
#include <LayoutUtils.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <typeinfo>
|
|
||||||
|
|
||||||
|
#include <ClassInfo.h>
|
||||||
#include <Layout.h>
|
#include <Layout.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
@@ -280,7 +280,7 @@ BLayoutUtils::GetLayoutTreeDump(BLayoutItem* item)
|
|||||||
BLayoutUtils::_GetLayoutTreeDump(BView* view, int level, BString& _output)
|
BLayoutUtils::_GetLayoutTreeDump(BView* view, int level, BString& _output)
|
||||||
{
|
{
|
||||||
BString indent;
|
BString indent;
|
||||||
indent.SetTo(' ', level * 2);
|
indent.SetTo(' ', level * 4);
|
||||||
|
|
||||||
if (view == NULL) {
|
if (view == NULL) {
|
||||||
_output << indent << "<null view>\n";
|
_output << indent << "<null view>\n";
|
||||||
@@ -292,12 +292,12 @@ BLayoutUtils::_GetLayoutTreeDump(BView* view, int level, BString& _output)
|
|||||||
BSize max = view->MaxSize();
|
BSize max = view->MaxSize();
|
||||||
BSize preferred = view->PreferredSize();
|
BSize preferred = view->PreferredSize();
|
||||||
_output << BString().SetToFormat(
|
_output << BString().SetToFormat(
|
||||||
"%sview %p (%s):\n"
|
"%sview %p (%s %s):\n"
|
||||||
"%s frame: (%f, %f, %f, %f)\n"
|
"%s frame: (%f, %f, %f, %f)\n"
|
||||||
"%s min: (%f, %f)\n"
|
"%s min: (%f, %f)\n"
|
||||||
"%s max: (%f, %f)\n"
|
"%s max: (%f, %f)\n"
|
||||||
"%s pref: (%f, %f)\n",
|
"%s pref: (%f, %f)\n",
|
||||||
indent.String(), view, typeid(*view).name(),
|
indent.String(), view, class_name(view), view->Name(),
|
||||||
indent.String(), frame.left, frame.top, frame.right, frame.bottom,
|
indent.String(), frame.left, frame.top, frame.right, frame.bottom,
|
||||||
indent.String(), min.width, min.height,
|
indent.String(), min.width, min.height,
|
||||||
indent.String(), max.width, max.height,
|
indent.String(), max.width, max.height,
|
||||||
@@ -310,7 +310,7 @@ BLayoutUtils::_GetLayoutTreeDump(BView* view, int level, BString& _output)
|
|||||||
|
|
||||||
int32 count = view->CountChildren();
|
int32 count = view->CountChildren();
|
||||||
for (int32 i = 0; i < count; i++) {
|
for (int32 i = 0; i < count; i++) {
|
||||||
_output << indent << " ---\n";
|
_output << indent << " ---\n";
|
||||||
_GetLayoutTreeDump(view->ChildAt(i), level + 1, _output);
|
_GetLayoutTreeDump(view->ChildAt(i), level + 1, _output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -326,7 +326,7 @@ BLayoutUtils::_GetLayoutTreeDump(BLayoutItem* item, int level,
|
|||||||
}
|
}
|
||||||
|
|
||||||
BString indent;
|
BString indent;
|
||||||
indent.SetTo(' ', level * 2);
|
indent.SetTo(' ', level * 4);
|
||||||
|
|
||||||
if (item == NULL) {
|
if (item == NULL) {
|
||||||
_output << indent << "<null item>\n";
|
_output << indent << "<null item>\n";
|
||||||
@@ -340,10 +340,10 @@ BLayoutUtils::_GetLayoutTreeDump(BLayoutItem* item, int level,
|
|||||||
BSize preferred = item->PreferredSize();
|
BSize preferred = item->PreferredSize();
|
||||||
if (isViewLayout) {
|
if (isViewLayout) {
|
||||||
_output << indent << BString().SetToFormat(" [layout %p (%s)]\n",
|
_output << indent << BString().SetToFormat(" [layout %p (%s)]\n",
|
||||||
layout, typeid(*layout).name());
|
layout, class_name(layout));
|
||||||
} else {
|
} else {
|
||||||
_output << indent << BString().SetToFormat("item %p (%s):\n",
|
_output << indent << BString().SetToFormat("item %p (%s):\n",
|
||||||
item, typeid(*item).name());
|
item, class_name(item));
|
||||||
}
|
}
|
||||||
_output << BString().SetToFormat(
|
_output << BString().SetToFormat(
|
||||||
"%s frame: (%f, %f, %f, %f)\n"
|
"%s frame: (%f, %f, %f, %f)\n"
|
||||||
@@ -360,7 +360,7 @@ BLayoutUtils::_GetLayoutTreeDump(BLayoutItem* item, int level,
|
|||||||
|
|
||||||
int32 count = layout->CountItems();
|
int32 count = layout->CountItems();
|
||||||
for (int32 i = 0; i < count; i++) {
|
for (int32 i = 0; i < count; i++) {
|
||||||
_output << indent << " ---\n";
|
_output << indent << " ---\n";
|
||||||
_GetLayoutTreeDump(layout->ItemAt(i), level + 1, false, _output);
|
_GetLayoutTreeDump(layout->ItemAt(i), level + 1, false, _output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user