-
-
Notifications
You must be signed in to change notification settings - Fork 22k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the File System Dock more user friendly #10261
Conversation
Thank you! This was always a pain when working on smaller laptop screens. |
Looks good to me, can you rebase the branch so I can test it locally? |
@HummusSamurai, just rebased the branch, and split the commit. |
Sorry, haven't had the opportunity to test it yet, but I still intend to. Could you rebase to solve the merge conflict? |
Edited files: editor/filesystem_dock.h editor/filesystem_dock.cpp
@akien-mga Quick question: |
Can't really complain when people give extension details about what they're doing, but it's true that it's a bit verbose and takes a while to review. But more than the verbosity of your explanations, what makes the review difficult is the sheer amount of changes - most are trivial, but given that so many unrelated changes are intertwined we still need to review line by line to spot potential regressions. For a future PR where you want to give explanations (which is great), feel free to put comments on the relevant lines using the GitHub interface, it would make it easier to read your explanations and the code changes at the same time. No need to detail things such as renaming variables for readability, that's self explanatory (at most we can discuss the name changes if there was a need for a consensus). |
Thanks for the feedback @akien-mga. I do definitely need to change my workflow to split the commits into more manageable chunks. Thats a great tip on using the github interface for commenting, I'll start using it 👍. |
From a cursory glance the changes look ok, let's get it tested in production and we'll see how it goes. I'm all for refactoring classes which have grown a bit unwieldy over time, but it's not trivial to assess the changes quickly without having them tested by many users. :) |
I understand it must have been difficult to review. I thank you for your patience in reviewing it. |
Ok, so I've gone through about half of editor/filesystem_dock.cpp (and subsequently editor/filesystem_dock.h), refactoring and adding usability improvements as I go. Unfortunately, since some of the refactoring and improvements are interlinked; it is difficult to split the commits. However, I will document the changes here:
Summary:
editor/filesystem_dock.h:
button_back
tobutton_tree
as it is used to go to the tree view from file view, and shouldn't be confused with going back in history. (logical)split_mode
tolow_height_mode
as split_mode is confusing as to which is split mode. (logical)history_max_size
int to limit the amount of remembered history, so memory isn't unnecessarily used. (memory)uncollapsed_paths
tocreate_tree
so when creating the res tree, the collapse state may be maintained. (enhancement)_update_history
to remove duplicated code from_fw_history
and_bw_history
. (Readability)keep_collapse_state
to_update_tree
so the tree has the option to maintain its collapse state whenever it is updated. (enhancement)_open_pressed
to_go_to_file_list
, its method implementation has been reduced to create an opposite to_go_to_tree
. (Logical)_go_to_dir
as its fuctionality can be achieved usingnavigate_to_path
. (Simplify)editor/filesystem_dock.cpp:
_create_tree
on res tree creation. (Enhancement)faves
tofavorite_paths
as it is more descriptive. (Readability)"res://"
andget_icon("Folder", "EditorIcons")
outside for loop (Performance)fv
tofave
as f prefix is used at later stages to refer to file (Consistency)NOTIFICATION_RESIZED
split_mode
=low_height_mode
(See editor/filesystem_dock.h pt.2)button_back
=button_tree
(See editor/filesystem_dock.h pt.1)_fs_changed()
as it is a method that should be run when the file system has changed, not when the dock is being resized. (Logical)NOTIFICATION_ENTER_TREE
String ei = "EditorIcons"
and used throughout. (Performance)button_back
=button_tree
(See editor/filesystem_dock.h pt.1)_go_to_dir
=navigate_to_path
. (See editor/filesystem_dock.h pt.8)_update_tree
into an else block as it shouldn't need to run if the file system is still scanning. (Performance)update_tree
is using its new parameter (See editor/filesystem_dock.h pt.6)NOTIFICATION_DRAG_BEGIN
if
statement toelse if
, to avoid checking the second if condition if the first is true. (Performance)NOTIFICATION_EDITOR_SETTINGS_CHANGED
String ei = "EditorIcons"
and use throughout. (Performance)back_button
=button_tree
(See editor/filesystem_dock.h pt.1)_update_file_display_toggle_button()
into the latter if statement, asset_display_mode
calls_update_file_display_mode
which calls_change_file_display
which calls_update_file_display_toggle_button
. (Performance)update_tree
uses new parameter (See editor/filesystem_dock.h pt.6)ti
tosel
to remain consistent with latter code. (Consistency)current_path
to show the selected item's path. (Useability)low_height_mode
=split_mode
(See editor/filesystem_dock.h pt.2)_open_pressed
with_update_files
as only_update_files
in_open_pressed
is needed now the above changes have been made. (Performance)String dir
variable, and set the global path variable directly, then use it throughout. (Performance)button_favorite->is_pressed()
from the if statement, as adding or removing a favorite, shouldn't need to rely onbutton_favorite
being pressed."res://"
on to the end of the path as it should already be there in the metadata. (Bug)dir_path
variable as we can just set the globalpath
variable directly. (Readability)_open_pressed
and added in the if clause to replicate its functionality. (See editor/filesystem_dock.h pt.7)split_mode
=low_height_mode
(See editor/filesystem_dock pt.2)if (use_folders)
block by reducing the if statements (Readability)ei
was moved to the beginning of the function. (Questionable)finfo
to make the code more descriptive. (Readability)big_icon
without initializing it tofile_thumbnail
yet, as it makes the code more readable if it is initialized in the following if statement. (Readability)..sources.size
if statement closer to the end. (Readability)item_index
to make the code more descriptive. (Readability)navigate_to_path
can do the same thing. (Simplify)set_disabled
check to make it easier to understand, from a programming standpoint. (Readability)button_favorite->show()
as it isn't needed. (Performance)_update_tree
is using its new parameter (See editor/filesystem_dock.h pt.6)_update_history
to reduce repetition. (Readability)_update_tree
is using its new parameter (See editor/filesystem_dock.h pt.6)set_disabled
check to make it easier to understand. (Readability)history.resize
into the if statement. (Performance)history_max_size
to keep history size limited. (See editor/filesystem_dock.h pt.3)set_disabled
check to make it easier to understand. (Readability)String path
tofpath
to avoid confusion with the global path variable. (Consistency)item
toselected
to be more descriptive. (Readability)FOLDER_EXPAND_ALL
andFOLDER_COLLAPSE_ALL
by setting the variableis_collapsed
to identify between the two options. (Simplify)String path
toString fpath
, to avoid confusion with global path. (Consistency)_open_pressed
to be more simple, and changed the name to_go_to_file_list
as it is the opposite of_go_to_tree
. (Logical)split_mode
=low_height_mode
. (See editor/filesystem_dock.h pt.2)_update_files
. (Readability)String path
tofpath
to avoid confusion with the global path variable. (Consistency)String path
tofpath
to avoid confusion with the global path variable. (Consistency)String path
tofpath
to avoid confusion with the global path variable. (Consistency)_update_tree
to use new parameter (See editor/filesystem_dock.h pt.6)String path
tofpath
to avoid confusion with the global path variable. (Consistency)file_options->add_separator()
lines. (Simplify)navigate_to_path
as it does the same thing. (Simplify)String p
tofpath
to be more descriptive and consistent. (Readability)_open_pressed
=_go_to_file_list
(See editor/filesystem_dock.h pt.7)_go_to_dir
=navigate_to_path
(See editor/filesystem_dock.h pt.8)path = "res://"
to the top, for more logical ordering.button_back
=button_tree
(See editor/filesystem_dock.h pt.1)max_history_size
, its current size of 20 is a testing value, can be changed. (See editor/filesystem_dock.h pt.3)split_mode
=low_height_mode
(See editor/filesystem_dock.h pt.2)