Skip to content

Commit

Permalink
Merge pull request godotengine#50146 from reduz/fix-tree
Browse files Browse the repository at this point in the history
Clean up Tree
  • Loading branch information
akien-mga authored Jul 4, 2021
2 parents 5c3055e + f4379cb commit 6bf26fb
Show file tree
Hide file tree
Showing 16 changed files with 224 additions and 43 deletions.
44 changes: 44 additions & 0 deletions doc/classes/Tree.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@
Returns the column index at [code]position[/code], or -1 if no item is there.
</description>
</method>
<method name="get_column_expand_ratio" qualifiers="const">
<return type="int">
</return>
<argument index="0" name="column" type="int">
</argument>
<description>
</description>
</method>
<method name="get_column_title" qualifiers="const">
<return type="String">
</return>
Expand Down Expand Up @@ -264,6 +272,22 @@
To tell whether a column of an item is selected, use [method TreeItem.is_selected].
</description>
</method>
<method name="is_column_clipping_content" qualifiers="const">
<return type="bool">
</return>
<argument index="0" name="column" type="int">
</argument>
<description>
</description>
</method>
<method name="is_column_expanding" qualifiers="const">
<return type="bool">
</return>
<argument index="0" name="column" type="int">
</argument>
<description>
</description>
</method>
<method name="scroll_to_item">
<return type="void">
</return>
Expand All @@ -272,6 +296,16 @@
<description>
</description>
</method>
<method name="set_column_clip_content">
<return type="void">
</return>
<argument index="0" name="column" type="int">
</argument>
<argument index="1" name="enable" type="bool">
</argument>
<description>
</description>
</method>
<method name="set_column_custom_minimum_width">
<return type="void">
</return>
Expand All @@ -294,6 +328,16 @@
If [code]true[/code], the column will have the "Expand" flag of [Control]. Columns that have the "Expand" flag will use their "min_width" in a similar fashion to [member Control.size_flags_stretch_ratio].
</description>
</method>
<method name="set_column_expand_ratio">
<return type="void">
</return>
<argument index="0" name="column" type="int">
</argument>
<argument index="1" name="ratio" type="int">
</argument>
<description>
</description>
</method>
<method name="set_column_title">
<return type="void">
</return>
Expand Down
1 change: 1 addition & 0 deletions editor/action_map_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,7 @@ ActionMapEditor::ActionMapEditor() {
action_tree->set_hide_root(true);
action_tree->set_column_titles_visible(true);
action_tree->set_column_title(0, TTR("Action"));
action_tree->set_column_clip_content(0, true);
action_tree->set_column_title(1, TTR("Deadzone"));
action_tree->set_column_expand(1, false);
action_tree->set_column_custom_minimum_width(1, 80 * EDSCALE);
Expand Down
5 changes: 5 additions & 0 deletions editor/debugger/editor_network_profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,23 @@ EditorNetworkProfiler::EditorNetworkProfiler() {
counters_display->set_column_titles_visible(true);
counters_display->set_column_title(0, TTR("Node"));
counters_display->set_column_expand(0, true);
counters_display->set_column_clip_content(0, true);
counters_display->set_column_custom_minimum_width(0, 60 * EDSCALE);
counters_display->set_column_title(1, TTR("Incoming RPC"));
counters_display->set_column_expand(1, false);
counters_display->set_column_clip_content(1, true);
counters_display->set_column_custom_minimum_width(1, 120 * EDSCALE);
counters_display->set_column_title(2, TTR("Incoming RSET"));
counters_display->set_column_expand(2, false);
counters_display->set_column_clip_content(2, true);
counters_display->set_column_custom_minimum_width(2, 120 * EDSCALE);
counters_display->set_column_title(3, TTR("Outgoing RPC"));
counters_display->set_column_expand(3, false);
counters_display->set_column_clip_content(3, true);
counters_display->set_column_custom_minimum_width(3, 120 * EDSCALE);
counters_display->set_column_title(4, TTR("Outgoing RSET"));
counters_display->set_column_expand(4, false);
counters_display->set_column_clip_content(4, true);
counters_display->set_column_custom_minimum_width(4, 120 * EDSCALE);
add_child(counters_display);

Expand Down
9 changes: 6 additions & 3 deletions editor/debugger/editor_profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,13 +631,16 @@ EditorProfiler::EditorProfiler() {
variables->set_column_titles_visible(true);
variables->set_column_title(0, TTR("Name"));
variables->set_column_expand(0, true);
variables->set_column_custom_minimum_width(0, 60 * EDSCALE);
variables->set_column_clip_content(0, true);
variables->set_column_expand_ratio(0, 60);
variables->set_column_title(1, TTR("Time"));
variables->set_column_expand(1, false);
variables->set_column_custom_minimum_width(1, 100 * EDSCALE);
variables->set_column_clip_content(1, true);
variables->set_column_expand_ratio(1, 100);
variables->set_column_title(2, TTR("Calls"));
variables->set_column_expand(2, false);
variables->set_column_custom_minimum_width(2, 60 * EDSCALE);
variables->set_column_clip_content(2, true);
variables->set_column_expand_ratio(2, 60);
variables->connect("item_edited", callable_mp(this, &EditorProfiler::_item_edited));

graph = memnew(TextureRect);
Expand Down
3 changes: 3 additions & 0 deletions editor/debugger/editor_visual_profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,12 +773,15 @@ EditorVisualProfiler::EditorVisualProfiler() {
variables->set_column_titles_visible(true);
variables->set_column_title(0, TTR("Name"));
variables->set_column_expand(0, true);
variables->set_column_clip_content(0, true);
variables->set_column_custom_minimum_width(0, 60);
variables->set_column_title(1, TTR("CPU"));
variables->set_column_expand(1, false);
variables->set_column_clip_content(1, true);
variables->set_column_custom_minimum_width(1, 60 * EDSCALE);
variables->set_column_title(2, TTR("GPU"));
variables->set_column_expand(2, false);
variables->set_column_clip_content(2, true);
variables->set_column_custom_minimum_width(2, 60 * EDSCALE);
variables->connect("cell_selected", callable_mp(this, &EditorVisualProfiler::_item_selected));

Expand Down
2 changes: 2 additions & 0 deletions editor/debugger/script_editor_debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1644,8 +1644,10 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {

error_tree->set_column_expand(0, false);
error_tree->set_column_custom_minimum_width(0, 140);
error_tree->set_column_clip_content(0, true);

error_tree->set_column_expand(1, true);
error_tree->set_column_clip_content(1, true);

error_tree->set_select_mode(Tree::SELECT_ROW);
error_tree->set_hide_root(true);
Expand Down
8 changes: 7 additions & 1 deletion editor/dependency_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,11 @@ DependencyEditor::DependencyEditor() {
tree->set_columns(2);
tree->set_column_titles_visible(true);
tree->set_column_title(0, TTR("Resource"));
tree->set_column_clip_content(0, true);
tree->set_column_expand_ratio(0, 2);
tree->set_column_title(1, TTR("Path"));
tree->set_column_clip_content(1, true);
tree->set_column_expand_ratio(1, 1);
tree->set_hide_root(true);
tree->connect("button_pressed", callable_mp(this, &DependencyEditor::_load_pressed));

Expand Down Expand Up @@ -769,9 +773,11 @@ OrphanResourcesDialog::OrphanResourcesDialog() {
files = memnew(Tree);
files->set_columns(2);
files->set_column_titles_visible(true);
files->set_column_custom_minimum_width(1, 100);
files->set_column_custom_minimum_width(1, 100 * EDSCALE);
files->set_column_expand(0, true);
files->set_column_clip_content(0, true);
files->set_column_expand(1, false);
files->set_column_clip_content(1, true);
files->set_column_title(0, TTR("Resource"));
files->set_column_title(1, TTR("Owns"));
files->set_hide_root(true);
Expand Down
8 changes: 3 additions & 5 deletions editor/editor_autoload_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,19 +882,17 @@ EditorAutoloadSettings::EditorAutoloadSettings() {

tree->set_column_title(0, TTR("Name"));
tree->set_column_expand(0, true);
tree->set_column_custom_minimum_width(0, 100 * EDSCALE);
tree->set_column_expand_ratio(0, 1);

tree->set_column_title(1, TTR("Path"));
tree->set_column_expand(1, true);
tree->set_column_custom_minimum_width(1, 100 * EDSCALE);
tree->set_column_clip_content(1, true);
tree->set_column_expand_ratio(1, 2);

tree->set_column_title(2, TTR("Global Variable"));
tree->set_column_expand(2, false);
// Reserve enough space for translations of "Global Variable" which may be longer.
tree->set_column_custom_minimum_width(2, 150 * EDSCALE);

tree->set_column_expand(3, false);
tree->set_column_custom_minimum_width(3, 120 * EDSCALE);

tree->connect("cell_selected", callable_mp(this, &EditorAutoloadSettings::_autoload_selected));
tree->connect("item_edited", callable_mp(this, &EditorAutoloadSettings::_autoload_edited));
Expand Down
2 changes: 2 additions & 0 deletions editor/editor_help_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,11 @@ EditorHelpSearch::EditorHelpSearch() {
results_tree->set_v_size_flags(Control::SIZE_EXPAND_FILL);
results_tree->set_columns(2);
results_tree->set_column_title(0, TTR("Name"));
results_tree->set_column_clip_content(0, true);
results_tree->set_column_title(1, TTR("Member Type"));
results_tree->set_column_expand(1, false);
results_tree->set_column_custom_minimum_width(1, 150 * EDSCALE);
results_tree->set_column_clip_content(1, true);
results_tree->set_custom_minimum_size(Size2(0, 100) * EDSCALE);
results_tree->set_hide_root(true);
results_tree->set_select_mode(Tree::SELECT_ROW);
Expand Down
5 changes: 5 additions & 0 deletions editor/editor_plugin_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,15 @@ EditorPluginSettings::EditorPluginSettings() {
plugin_list->set_column_title(3, TTR("Status:"));
plugin_list->set_column_title(4, TTR("Edit:"));
plugin_list->set_column_expand(0, true);
plugin_list->set_column_clip_content(0, true);
plugin_list->set_column_expand(1, false);
plugin_list->set_column_clip_content(1, true);
plugin_list->set_column_expand(2, false);
plugin_list->set_column_clip_content(2, true);
plugin_list->set_column_expand(3, false);
plugin_list->set_column_clip_content(3, true);
plugin_list->set_column_expand(4, false);
plugin_list->set_column_clip_content(4, true);
plugin_list->set_column_custom_minimum_width(1, 100 * EDSCALE);
plugin_list->set_column_custom_minimum_width(2, 250 * EDSCALE);
plugin_list->set_column_custom_minimum_width(3, 80 * EDSCALE);
Expand Down
2 changes: 2 additions & 0 deletions editor/localization_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,9 @@ LocalizationEditor::LocalizationEditor() {
translation_remap_options->set_column_title(1, TTR("Locale"));
translation_remap_options->set_column_titles_visible(true);
translation_remap_options->set_column_expand(0, true);
translation_remap_options->set_column_clip_content(0, true);
translation_remap_options->set_column_expand(1, false);
translation_remap_options->set_column_clip_content(1, true);
translation_remap_options->set_column_custom_minimum_width(1, 200);
translation_remap_options->connect("item_edited", callable_mp(this, &LocalizationEditor::_translation_res_option_changed));
translation_remap_options->connect("button_pressed", callable_mp(this, &LocalizationEditor::_translation_res_option_delete));
Expand Down
6 changes: 4 additions & 2 deletions editor/plugins/animation_player_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,10 @@ void AnimationPlayerEditor::_animation_blend() {
blend_editor.dialog->popup_centered(Size2(400, 400) * EDSCALE);

blend_editor.tree->set_hide_root(true);
blend_editor.tree->set_column_custom_minimum_width(0, 10);
blend_editor.tree->set_column_custom_minimum_width(1, 3);
blend_editor.tree->set_column_expand_ratio(0, 10);
blend_editor.tree->set_column_clip_content(0, true);
blend_editor.tree->set_column_expand_ratio(1, 3);
blend_editor.tree->set_column_clip_content(1, true);

List<StringName> anims;
player->get_animation_list(&anims);
Expand Down
6 changes: 4 additions & 2 deletions editor/plugins/resource_preloader_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,10 @@ ResourcePreloaderEditor::ResourcePreloaderEditor() {
tree = memnew(Tree);
tree->connect("button_pressed", callable_mp(this, &ResourcePreloaderEditor::_cell_button_pressed));
tree->set_columns(2);
tree->set_column_custom_minimum_width(0, 2);
tree->set_column_custom_minimum_width(1, 3);
tree->set_column_expand_ratio(0, 2);
tree->set_column_clip_content(0, true);
tree->set_column_expand_ratio(1, 3);
tree->set_column_clip_content(1, true);
tree->set_column_expand(0, true);
tree->set_column_expand(1, true);
tree->set_v_size_flags(SIZE_EXPAND_FILL);
Expand Down
3 changes: 3 additions & 0 deletions editor/plugins/theme_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,11 +930,14 @@ ThemeItemImportTree::ThemeItemImportTree() {
import_items_tree->set_column_title(IMPORT_ITEM, TTR("Import"));
import_items_tree->set_column_title(IMPORT_ITEM_DATA, TTR("With Data"));
import_items_tree->set_column_expand(0, true);
import_items_tree->set_column_clip_content(0, true);
import_items_tree->set_column_expand(IMPORT_ITEM, false);
import_items_tree->set_column_expand(IMPORT_ITEM_DATA, false);
import_items_tree->set_column_custom_minimum_width(0, 160 * EDSCALE);
import_items_tree->set_column_custom_minimum_width(IMPORT_ITEM, 80 * EDSCALE);
import_items_tree->set_column_custom_minimum_width(IMPORT_ITEM_DATA, 80 * EDSCALE);
import_items_tree->set_column_clip_content(1, true);
import_items_tree->set_column_clip_content(2, true);

ScrollContainer *import_bulk_sc = memnew(ScrollContainer);
import_bulk_sc->set_custom_minimum_size(Size2(260.0, 0.0) * EDSCALE);
Expand Down
Loading

0 comments on commit 6bf26fb

Please sign in to comment.