Extract editor edit action router
This commit is contained in:
@@ -35,7 +35,6 @@ void ProjectPanel::Render() {
|
||||
}
|
||||
|
||||
Actions::ObserveFocusedActionRoute(*m_context, EditorActionRoute::Project);
|
||||
HandleKeyboardShortcuts();
|
||||
|
||||
auto& manager = m_context->GetProjectManager();
|
||||
|
||||
@@ -150,30 +149,6 @@ void ProjectPanel::Render() {
|
||||
}
|
||||
}
|
||||
|
||||
AssetItemPtr ProjectPanel::GetSelectedItem() const {
|
||||
return m_context ? Actions::GetSelectedAssetItem(*m_context) : nullptr;
|
||||
}
|
||||
|
||||
void ProjectPanel::HandleKeyboardShortcuts() {
|
||||
if (!m_context) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto& manager = m_context->GetProjectManager();
|
||||
const AssetItemPtr selectedItem = GetSelectedItem();
|
||||
const Actions::ShortcutContext shortcutContext = Actions::FocusedWindowShortcutContext();
|
||||
|
||||
Actions::HandleShortcut(Actions::MakeNavigateBackAction(manager.CanNavigateBack()), shortcutContext, [&]() {
|
||||
manager.NavigateBack();
|
||||
});
|
||||
Actions::HandleShortcut(Actions::MakeOpenAssetAction(Commands::CanOpenAsset(selectedItem)), shortcutContext, [&]() {
|
||||
Commands::OpenAsset(*m_context, selectedItem);
|
||||
});
|
||||
Actions::HandleShortcut(Actions::MakeDeleteAssetAction(selectedItem != nullptr), shortcutContext, [&]() {
|
||||
Commands::DeleteAsset(manager, manager.GetSelectedIndex());
|
||||
});
|
||||
}
|
||||
|
||||
void ProjectPanel::RenderAssetItem(const AssetItemPtr& item, int index) {
|
||||
auto& manager = m_context->GetProjectManager();
|
||||
bool isSelected = (manager.GetSelectedIndex() == index);
|
||||
|
||||
Reference in New Issue
Block a user