Skip to content

Commit

Permalink
Add common macros header
Browse files Browse the repository at this point in the history
  • Loading branch information
Naros committed Jun 28, 2024
1 parent fa287b2 commit bb57474
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
22 changes: 22 additions & 0 deletions src/common/macros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// This file is part of the Godot Orchestrator project.
//
// Copyright (c) 2023-present Vahera Studios LLC and its contributors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef ORCHESTRATOR_MACROS_H
#define ORCHESTRATOR_MACROS_H

#define OACCEL_KEY(mask,key) (Key(static_cast<int>(mask) | static_cast<int>(key)))

#endif // ORCHESTRATOR_MACROS_H
7 changes: 4 additions & 3 deletions src/editor/graph/graph_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "graph_node.h"

#include "common/logger.h"
#include "common/macros.h"
#include "common/scene_utils.h"
#include "common/settings.h"
#include "editor/plugins/orchestrator_editor_plugin.h"
Expand Down Expand Up @@ -425,9 +426,9 @@ void OrchestratorGraphNode::_show_context_menu(const Vector2& p_position)
_context_menu->add_icon_item(SceneUtils::get_editor_icon("Remove"), "Delete", CM_DELETE, KEY_DELETE);
_context_menu->set_item_disabled(_context_menu->get_item_index(CM_DELETE), !_node->can_user_delete_node());

_context_menu->add_icon_item(SceneUtils::get_editor_icon("ActionCut"), "Cut", CM_CUT, Key(KEY_MASK_CTRL | KEY_X));
_context_menu->add_icon_item(SceneUtils::get_editor_icon("ActionCopy"), "Copy", CM_COPY, Key(KEY_MASK_CTRL | KEY_C));
_context_menu->add_icon_item(SceneUtils::get_editor_icon("Duplicate"), "Duplicate", CM_DUPLICATE, Key(KEY_MASK_CTRL | KEY_D));
_context_menu->add_icon_item(SceneUtils::get_editor_icon("ActionCut"), "Cut", CM_CUT, OACCEL_KEY(KEY_MASK_CTRL, KEY_X));
_context_menu->add_icon_item(SceneUtils::get_editor_icon("ActionCopy"), "Copy", CM_COPY, OACCEL_KEY(KEY_MASK_CTRL, KEY_C));
_context_menu->add_icon_item(SceneUtils::get_editor_icon("Duplicate"), "Duplicate", CM_DUPLICATE, OACCEL_KEY(KEY_MASK_CTRL, KEY_D));
_context_menu->add_icon_item(SceneUtils::get_editor_icon("DistractionFree"), "Toggle Resizer", CM_RESIZABLE);

_context_menu->add_icon_item(SceneUtils::get_editor_icon("Loop"), "Refresh Nodes", CM_REFRESH);
Expand Down
19 changes: 9 additions & 10 deletions src/editor/main_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
//
#include "main_view.h"

#include "common/macros.h"
#include "common/settings.h"
#include "common/scene_utils.h"
#include "common/version.h"
Expand Down Expand Up @@ -52,8 +53,6 @@
#include <godot_cpp/classes/v_split_container.hpp>
#include <godot_cpp/templates/hash_set.hpp>

#define SKEY(m,k) Key(static_cast<int>(m) | static_cast<int>(k))

OrchestratorMainView::OrchestratorMainView(OrchestratorPlugin* p_plugin, OrchestratorWindowWrapper* p_window_wrapper)
{
_plugin = p_plugin;
Expand Down Expand Up @@ -93,7 +92,7 @@ void OrchestratorMainView::_notification(int p_what)
_file_menu->set_v_size_flags(SIZE_SHRINK_BEGIN);
_file_menu->set_text("File");
_file_menu->get_popup()->clear();
_file_menu->get_popup()->add_item("New Orchestration...", AccelMenuIds::NEW, SKEY(KEY_MASK_CTRL, KEY_N));
_file_menu->get_popup()->add_item("New Orchestration...", AccelMenuIds::NEW, OACCEL_KEY(KEY_MASK_CTRL, KEY_N));
_file_menu->get_popup()->add_item("Open...", AccelMenuIds::OPEN);

_recent_history = memnew(PopupMenu);
Expand All @@ -105,19 +104,19 @@ void OrchestratorMainView::_notification(int p_what)
_update_recent_history();

_file_menu->get_popup()->add_separator();
_file_menu->get_popup()->add_item("Save", AccelMenuIds::SAVE, SKEY(KEY_MASK_CTRL | KEY_MASK_ALT, KEY_S));
_file_menu->get_popup()->add_item("Save", AccelMenuIds::SAVE, OACCEL_KEY(KEY_MASK_CTRL | KEY_MASK_ALT, KEY_S));
_file_menu->get_popup()->add_item("Save As...", AccelMenuIds::SAVE_AS);
_file_menu->get_popup()->add_item("Save All", AccelMenuIds::SAVE_ALL, SKEY(KEY_MASK_SHIFT | KEY_MASK_ALT, KEY_S));
_file_menu->get_popup()->add_item("Save All", AccelMenuIds::SAVE_ALL, OACCEL_KEY(KEY_MASK_SHIFT | KEY_MASK_ALT, KEY_S));
_file_menu->get_popup()->add_separator();
_file_menu->get_popup()->add_item("Show in Filesystem", AccelMenuIds::SHOW_IN_FILESYSTEM);
_file_menu->get_popup()->add_separator();
_file_menu->get_popup()->add_item("Close", AccelMenuIds::CLOSE, SKEY(KEY_MASK_CTRL, KEY_W));
_file_menu->get_popup()->add_item("Close", AccelMenuIds::CLOSE, OACCEL_KEY(KEY_MASK_CTRL, KEY_W));
_file_menu->get_popup()->add_item("Close All", AccelMenuIds::CLOSE_ALL);
_file_menu->get_popup()->add_separator();
_file_menu->get_popup()->add_item("Run", AccelMenuIds::RUN, SKEY(KEY_MASK_SHIFT | KEY_MASK_CTRL, KEY_X));
_file_menu->get_popup()->add_item("Run", AccelMenuIds::RUN, OACCEL_KEY(KEY_MASK_SHIFT | KEY_MASK_CTRL, KEY_X));
_file_menu->get_popup()->add_separator();
_file_menu->get_popup()->add_item("Toggle Orchestrator Panel", AccelMenuIds::TOGGLE_LEFT_PANEL, SKEY(KEY_MASK_CTRL, KEY_BACKSLASH));
_file_menu->get_popup()->add_item("Toggle Component Panel", AccelMenuIds::TOGGLE_RIGHT_PANEL, SKEY(KEY_MASK_CTRL, KEY_SLASH));
_file_menu->get_popup()->add_item("Toggle Orchestrator Panel", AccelMenuIds::TOGGLE_LEFT_PANEL, OACCEL_KEY(KEY_MASK_CTRL, KEY_BACKSLASH));
_file_menu->get_popup()->add_item("Toggle Component Panel", AccelMenuIds::TOGGLE_RIGHT_PANEL, OACCEL_KEY(KEY_MASK_CTRL, KEY_SLASH));
_file_menu->get_popup()->connect("id_pressed", callable_mp(this, &OrchestratorMainView::_on_menu_option));
_file_menu->get_popup()->connect("about_to_popup",
callable_mp(this, &OrchestratorMainView::_on_prepare_file_menu));
Expand All @@ -128,7 +127,7 @@ void OrchestratorMainView::_notification(int p_what)
_goto_menu->set_v_size_flags(SIZE_SHRINK_BEGIN);
_goto_menu->set_text("Goto");
_goto_menu->get_popup()->clear();
_goto_menu->get_popup()->add_item("Goto Node", AccelMenuIds::GOTO_NODE, SKEY(KEY_MASK_CTRL, KEY_L));
_goto_menu->get_popup()->add_item("Goto Node", AccelMenuIds::GOTO_NODE, OACCEL_KEY(KEY_MASK_CTRL, KEY_L));
_goto_menu->get_popup()->connect("id_pressed", callable_mp(this, &OrchestratorMainView::_on_menu_option));
_goto_menu->get_popup()->connect("about_to_popup", callable_mp(this, &OrchestratorMainView::_on_prepare_goto_menu));
left_menu->add_child(_goto_menu);
Expand Down

0 comments on commit bb57474

Please sign in to comment.