tahoma2d/toonz/sources/include/tw/shortcutmanager.h

85 lines
1.5 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef SHORTCUTMANAGER_INCLUDED
#define SHORTCUTMANAGER_INCLUDED
#include "tw/tw.h"
#undef DVAPI
#undef DVVAR
#ifdef TWIN_EXPORTS
#define DVAPI DV_EXPORT_API
#define DVVAR DV_EXPORT_VAR
#else
#define DVAPI DV_IMPORT_API
#define DVVAR DV_IMPORT_VAR
#endif
2016-06-15 18:43:10 +12:00
// forward declarations
2016-03-19 06:57:51 +13:00
class TKeyListener;
class TFilePath;
//
// Shortcut
//
2016-06-15 18:43:10 +12:00
class DVAPI TShortcut {
string m_id;
wstring m_name;
TKeyListener *m_listener;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TShortcut(string id);
virtual ~TShortcut();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
string getId() const { return m_id; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setName(wstring name) { m_name = name; }
wstring getName() const { return m_name; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
string getKeyName() const;
void setKeyName(string keyName);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
virtual void onKeyDown() = 0;
virtual void onKeyUp(bool mouseEventReceived) {}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
virtual string getType() const = 0;
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
// not implemented
TShortcut(const TShortcut &);
TShortcut &operator=(const TShortcut &);
2016-03-19 06:57:51 +13:00
};
//
// Shortcut controller
//
2016-06-15 18:43:10 +12:00
class DVAPI TShortcutManager { // singleton
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
class Imp;
Imp *m_imp;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TShortcutManager();
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
~TShortcutManager();
static TShortcutManager *instance();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setKeyName(string id, string keyName);
string getKeyName(string id);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TShortcut *getShortcutByKeyName(string keyName);
TShortcut *getShortcutById(string keyName);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void getShortcuts(std::vector<const TShortcut *> &shortcuts);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// get ownership
void add(TShortcut *shortcut);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setPath(const TFilePath &path);
const TFilePath &getPath() const;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void load();
void save();
2016-03-19 06:57:51 +13:00
};
#endif