Adding Shortcut data structure

This commit is contained in:
SweetId 2023-10-15 13:46:31 -04:00
parent 8e3b181c4f
commit 72e7625900
1 changed files with 33 additions and 1 deletions

View File

@ -1,9 +1,41 @@
#pragma once
#include <NazaraEditor/Core/Core.hpp>
#include <Nazara/Platform.hpp>
#include <vector>
namespace Nz
{
struct Shortcut
struct NAZARAEDITOR_CORE_API Shortcut
{
bool bCtrl : 1;
bool bShift : 1;
std::vector<Nz::Keyboard::VKey> keys;
std::string ToString() const
{
std::ostringstream oss;
if (bCtrl) oss << "Ctrl+";
if (bShift) oss << "Shift+";
for (size_t i = 0; i < keys.size(); ++i)
{
oss << Nz::Keyboard::GetKeyName(keys[i]);
if (i < keys.size() - 1)
oss << "+";
}
return oss.str();
}
static Shortcut Create(Nz::Keyboard::VKey key, bool bCtrl, bool bShift)
{
Shortcut shortcut
{
.bCtrl = bCtrl,
.bShift = bShift,
.keys = { key }
};
return shortcut;
}
};
}