Feature/keybindings (#1708)

* Add action manager to handle actions in replacement of keyboard shortcuts
* Implement new Action concept
* Remove the shortcutscomponent as it is no longer needed
* Update profile version from 1.0 to 1.1
* Add action dialog
* Restructure of key specification in keys.h
* Remove solid field-of-view keybind from the newhorizons profile as the setting no longer exists
This commit is contained in:
Alexander Bock
2021-08-18 10:58:20 +02:00
committed by GitHub
parent b651170565
commit 34985f64a6
72 changed files with 3443 additions and 3157 deletions
+2 -2
View File
@@ -26,6 +26,7 @@ include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake)
set(HEADER_FILES
include/gui.h
include/guiactioncomponent.h
include/guiassetcomponent.h
include/guicomponent.h
include/guifilepathcomponent.h
@@ -37,7 +38,6 @@ set(HEADER_FILES
include/guimissioncomponent.h
include/guiparallelcomponent.h
include/guipropertycomponent.h
include/guishortcutscomponent.h
include/guispacetimecomponent.h
include/guiiswacomponent.h
include/imgui_include.h
@@ -47,6 +47,7 @@ source_group("Header Files" FILES ${HEADER_FILES})
set(SOURCE_FILES
src/gui.cpp
src/guiactioncomponent.cpp
src/guiassetcomponent.cpp
src/guicomponent.cpp
src/guifilepathcomponent.cpp
@@ -58,7 +59,6 @@ set(SOURCE_FILES
src/guimissioncomponent.cpp
src/guiparallelcomponent.cpp
src/guipropertycomponent.cpp
src/guishortcutscomponent.cpp
src/guispacetimecomponent.cpp
src/guiiswacomponent.cpp
src/renderproperties.cpp
+3 -3
View File
@@ -27,6 +27,7 @@
#include <modules/imgui/include/guicomponent.h>
#include <modules/imgui/include/guiactioncomponent.h>
#include <modules/imgui/include/guiassetcomponent.h>
#include <modules/imgui/include/guifilepathcomponent.h>
#include <modules/imgui/include/guigibscomponent.h>
@@ -38,7 +39,6 @@
#include <modules/imgui/include/guimissioncomponent.h>
#include <modules/imgui/include/guiparallelcomponent.h>
#include <modules/imgui/include/guipropertycomponent.h>
#include <modules/imgui/include/guishortcutscomponent.h>
#include <modules/imgui/include/guispacetimecomponent.h>
#include <openspace/properties/property.h>
#include <openspace/properties/scalar/boolproperty.h>
@@ -121,7 +121,7 @@ public:
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
GuiIswaComponent _iswa;
#endif // OPENSPACE_MODULE_ISWA_ENABLED
GuiShortcutsComponent _shortcuts;
GuiActionComponent _actions;
GuiJoystickComponent _joystick;
GuiParallelComponent _parallel;
GuiPropertyComponent _featuredProperties;
@@ -153,7 +153,7 @@ private:
#endif
&_asset,
&_shortcuts,
&_actions,
&_joystick,
&_filePath,
@@ -29,9 +29,9 @@
namespace openspace::gui {
class GuiShortcutsComponent : public GuiComponent {
class GuiActionComponent : public GuiComponent {
public:
GuiShortcutsComponent();
GuiActionComponent();
void render() override;
};
@@ -22,12 +22,12 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <modules/imgui/include/guishortcutscomponent.h>
#include <modules/imgui/include/guiactioncomponent.h>
#include <modules/imgui/include/gui.h>
#include <openspace/engine/globals.h>
#include <openspace/interaction/actionmanager.h>
#include <openspace/interaction/keybindingmanager.h>
#include <openspace/interaction/shortcutmanager.h>
#include <openspace/scripting/scriptengine.h>
#include <openspace/util/keys.h>
@@ -35,11 +35,11 @@
namespace openspace::gui {
GuiShortcutsComponent::GuiShortcutsComponent()
GuiActionComponent::GuiActionComponent()
: GuiComponent("Shortcuts", "Shortcuts")
{}
void GuiShortcutsComponent::render() {
void GuiActionComponent::render() {
ImGui::SetNextWindowCollapsed(_isCollapsed);
bool v = _isEnabled;
@@ -47,62 +47,50 @@ void GuiShortcutsComponent::render() {
_isEnabled = v;
_isCollapsed = ImGui::IsWindowCollapsed();
using K = KeyWithModifier;
using V = std::string;
const std::multimap<K, V>& binds = global::keybindingManager->keyBindings();
// First the actual shortcuts
CaptionText("Shortcuts");
const std::vector<interaction::ShortcutManager::ShortcutInformation>& shortcuts =
global::shortcutManager->shortcuts();
for (size_t i = 0; i < shortcuts.size(); ++i) {
const interaction::ShortcutManager::ShortcutInformation& info = shortcuts[i];
if (ImGui::Button(info.name.c_str())) {
global::scriptEngine->queueScript(
info.script,
scripting::ScriptEngine::RemoteScripting(info.synchronization)
);
std::set<std::string> boundActions;
CaptionText("Keybindings");
for (const std::pair<const K, V>& p : binds) {
boundActions.insert(p.second);
if (ImGui::Button(ghoul::to_string(p.first).c_str())) {
global::actionManager->triggerAction(p.second, ghoul::Dictionary());
}
ImGui::SameLine();
// Poor mans table layout
ImGui::SetCursorPosX(125.f);
ImGui::Text("%s", info.documentation.c_str());
if (!info.synchronization) {
const interaction::Action& a = global::actionManager->action(p.second);
ImGui::Text("%s", a.documentation.c_str());
if (!a.synchronization) {
ImGui::SameLine();
ImGui::Text("(%s)", "local");
}
}
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 25.f);
CaptionText("Other Actions");
for (const interaction::Action& action : global::actionManager->actions()) {
// We only show all of the other actions that are not currently bound to keys here
if (boundActions.find(action.identifier) != boundActions.end()) {
continue;
}
// Then display all the keybinds as buttons as well, for good measure
CaptionText("Keybindings");
using K = KeyWithModifier;
using V = interaction::KeybindingManager::KeyInformation;
const std::multimap<K, V>& binds = global::keybindingManager->keyBindings();
for (const std::pair<const K, V>& p : binds) {
if (ImGui::Button(ghoul::to_string(p.first).c_str())) {
global::scriptEngine->queueScript(
p.second.command,
scripting::ScriptEngine::RemoteScripting(p.second.synchronization)
);
if (ImGui::Button(action.identifier.c_str())) {
global::actionManager->triggerAction(action.command, ghoul::Dictionary());
}
ImGui::SameLine();
// Poor mans table layout
ImGui::SetCursorPosX(125.f);
ImGui::SetCursorPosX(350.f);
ImGui::Text("%s", p.second.documentation.c_str());
if (!p.second.synchronization) {
ImGui::Text("%s", action.documentation.c_str());
if (!action.synchronization) {
ImGui::SameLine();
ImGui::Text("(%s)", "local");
}
}
}