Skip to content

Commit

Permalink
hierarchy refactor; UX
Browse files Browse the repository at this point in the history
  • Loading branch information
nem0 committed Sep 28, 2024
1 parent 7361ac0 commit 4765c08
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/editor/asset_browser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ struct AssetBrowserImpl : AssetBrowser {
addPlugin(m_world_asset_plugin, Span(world_exts));
m_app.getAssetCompiler().addPlugin(m_world_asset_plugin, Span(world_exts));
m_app.getSettings().registerPtr("asset_browser_open", &m_is_open);
m_app.getSettings().registerPtr("asset_browser_thumbnails", &m_show_thumbnails);
m_app.getSettings().registerPtr("asset_browser_thumbnail_size", &m_thumbnail_size);
}

void focusSearch() {
Expand Down Expand Up @@ -172,10 +174,19 @@ struct AssetBrowserImpl : AssetBrowser {
ASSERT(m_plugins.size() == 0);
}

void selectAll() {
m_selected_resources.clear();
for (const FileInfo& info : m_file_infos) {
m_selected_resources.push(info.filepath);
}
}

bool onAction(const Action& action) override {
CommonActions& common = m_app.getCommonActions();
if (&action == &m_back_action) goBackDir();
else if (&action == &m_forward_action) goForwardDir();
else if (&action == &m_app.getCommonActions().del && !m_selected_resources.empty()) m_request_delete = true;
else if (&action == &common.del && !m_selected_resources.empty()) m_request_delete = true;
else if (&action == &common.select_all) selectAll();
else return false;
return true;
}
Expand Down
4 changes: 4 additions & 0 deletions src/editor/studio_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ struct StudioAppImpl final : StudioApp
removeAction(&m_common_actions.cam_left);
removeAction(&m_common_actions.cam_up);
removeAction(&m_common_actions.cam_down);
removeAction(&m_common_actions.select_all);

for (Action* action : m_owned_actions) {
removeAction(action);
Expand Down Expand Up @@ -2386,6 +2387,9 @@ struct StudioAppImpl final : StudioApp
addAction(&m_common_actions.cam_up);
m_common_actions.cam_down.init("Move down", "Move camera down", "moveDown", "", Action::LOCAL);
addAction(&m_common_actions.cam_down);
m_common_actions.select_all.init("Select all", "Select all", "select_all", "", Action::IMGUI_PRIORITY);
addAction(&m_common_actions.select_all);


m_show_all_actions_action.init("Show all actions", "Show all actions", "show_all_actions", "", os::Keycode::P, Action::Modifiers::CTRL | Action::Modifiers::SHIFT, Action::Type::IMGUI_PRIORITY);
m_show_all_actions_action.func.bind<&StudioAppImpl::showAllActionsGUI>(this);
Expand Down
1 change: 1 addition & 0 deletions src/editor/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ struct CommonActions {
Action cam_right;
Action cam_up;
Action cam_down;
Action select_all;
};

inline Action::Modifiers operator |(Action::Modifiers a, Action::Modifiers b) { return Action::Modifiers((u8)a | (u8)b); }
Expand Down

0 comments on commit 4765c08

Please sign in to comment.