1 |
schoenebeck |
3157 |
/* |
2 |
|
|
Copyright (c) MMXVII Christian Schoenebeck |
3 |
|
|
|
4 |
|
|
This file is part of "gigedit" and released under the terms of the |
5 |
|
|
GNU General Public License version 2. |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#ifndef GIGEDIT_MACROSSETUP_H |
9 |
|
|
#define GIGEDIT_MACROSSETUP_H |
10 |
|
|
|
11 |
|
|
#ifdef LIBGIG_HEADER_FILE |
12 |
|
|
# include LIBGIG_HEADER_FILE(gig.h) |
13 |
|
|
# include LIBGIG_HEADER_FILE(Serialization.h) |
14 |
|
|
#else |
15 |
|
|
# include <gig.h> |
16 |
|
|
# include <Serialization.h> |
17 |
|
|
#endif |
18 |
|
|
|
19 |
|
|
#if HAVE_CONFIG_H |
20 |
|
|
# include <config.h> |
21 |
|
|
#endif |
22 |
|
|
#include "compat.h" |
23 |
schoenebeck |
3364 |
|
24 |
|
|
#if USE_GTKMM_BUILDER |
25 |
|
|
# include <gtkmm/builder.h> |
26 |
|
|
#else |
27 |
|
|
# include <gtkmm/uimanager.h> // deprecated in gtkmm >= 3.21.4 |
28 |
|
|
#endif |
29 |
|
|
#include <gtkmm/treeview.h> |
30 |
|
|
#include <gtkmm/treestore.h> |
31 |
|
|
#include <gtkmm/scrolledwindow.h> |
32 |
|
|
#include <gtkmm/textview.h> |
33 |
|
|
|
34 |
schoenebeck |
3184 |
#include "wrapLabel.hh" |
35 |
schoenebeck |
3157 |
#include "ManagedWindow.h" |
36 |
|
|
|
37 |
|
|
/** @brief Setup all gigedit macros. |
38 |
|
|
* |
39 |
|
|
* Shows a list with all gigedit macros configured by the user. It allows to |
40 |
|
|
* add and remove macros, and to reorder the list of macros for altering the |
41 |
|
|
* keyboard accelerators (F1 - F12) associated with the individual macros. |
42 |
|
|
*/ |
43 |
|
|
class MacrosSetup : public ManagedWindow { |
44 |
|
|
public: |
45 |
|
|
MacrosSetup(); |
46 |
|
|
~MacrosSetup(); |
47 |
schoenebeck |
3160 |
void setMacros(const std::vector<Serialization::Archive>& macros, |
48 |
|
|
Serialization::Archive* pClipboardContent, |
49 |
|
|
gig::DimensionRegion* pSelectedDimRgn); |
50 |
schoenebeck |
3157 |
|
51 |
|
|
sigc::signal<void, const std::vector<Serialization::Archive>& >& signal_macros_changed(); |
52 |
|
|
|
53 |
|
|
// implementation for abstract methods of interface class "ManagedWindow" |
54 |
|
|
virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->macrosSetupWindowX; } |
55 |
|
|
virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->macrosSetupWindowY; } |
56 |
|
|
virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->macrosSetupWindowW; } |
57 |
|
|
virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->macrosSetupWindowH; } |
58 |
|
|
|
59 |
|
|
protected: |
60 |
schoenebeck |
3160 |
bool m_modified; |
61 |
schoenebeck |
3157 |
std::vector<Serialization::Archive> m_macros; |
62 |
schoenebeck |
3160 |
Serialization::Archive* m_clipboardContent; |
63 |
|
|
gig::DimensionRegion* m_selectedDimRgn; |
64 |
schoenebeck |
3157 |
|
65 |
|
|
sigc::signal<void, const std::vector<Serialization::Archive>& > m_macros_changed; |
66 |
|
|
|
67 |
schoenebeck |
3364 |
VBox m_vbox; |
68 |
|
|
HBox m_addHBox; |
69 |
|
|
HBox m_mainHBox; |
70 |
|
|
VBox m_rvbox; |
71 |
|
|
HButtonBox m_detailsButtonBox; |
72 |
|
|
HBox m_footerHBox; |
73 |
|
|
HBox m_statusHBox; |
74 |
|
|
HButtonBox m_buttonBoxL; |
75 |
|
|
HButtonBox m_buttonBox; |
76 |
schoenebeck |
3157 |
Gtk::ScrolledWindow m_scrolledWindow; |
77 |
schoenebeck |
3184 |
#if GTKMM_MAJOR_VERSION < 3 |
78 |
|
|
view::WrapLabel m_labelIntro; |
79 |
|
|
#else |
80 |
|
|
Gtk::Label m_labelIntro; |
81 |
|
|
#endif |
82 |
schoenebeck |
3157 |
|
83 |
|
|
class MacroListModel : public Gtk::TreeModel::ColumnRecord { |
84 |
|
|
public: |
85 |
|
|
MacroListModel() { |
86 |
|
|
add(m_col_key); |
87 |
|
|
add(m_col_name); |
88 |
|
|
add(m_col_comment); |
89 |
|
|
add(m_col_created); |
90 |
|
|
add(m_col_modified); |
91 |
|
|
add(m_col_index); |
92 |
|
|
} |
93 |
|
|
|
94 |
|
|
Gtk::TreeModelColumn<Glib::ustring> m_col_key; |
95 |
|
|
Gtk::TreeModelColumn<Glib::ustring> m_col_name; |
96 |
|
|
Gtk::TreeModelColumn<Glib::ustring> m_col_comment; |
97 |
|
|
Gtk::TreeModelColumn<Glib::ustring> m_col_created; |
98 |
|
|
Gtk::TreeModelColumn<Glib::ustring> m_col_modified; |
99 |
|
|
Gtk::TreeModelColumn<int> m_col_index; |
100 |
|
|
} m_treeModelMacros; |
101 |
|
|
|
102 |
|
|
class MacroListTreeStore : public Gtk::TreeStore { |
103 |
|
|
public: |
104 |
|
|
static Glib::RefPtr<MacroListTreeStore> create(const MacroListModel& columns) { |
105 |
|
|
return Glib::RefPtr<MacroListTreeStore>( new MacroListTreeStore(columns) ); |
106 |
|
|
} |
107 |
|
|
protected: |
108 |
|
|
MacroListTreeStore(const MacroListModel& columns) : Gtk::TreeStore(columns) {} |
109 |
|
|
}; |
110 |
|
|
|
111 |
|
|
Gtk::TreeView m_treeViewMacros; |
112 |
|
|
Glib::RefPtr<MacroListTreeStore> m_treeStoreMacros; |
113 |
|
|
bool m_ignoreTreeViewValueChange; |
114 |
schoenebeck |
3162 |
bool m_ignoreCommentTextViewChange; |
115 |
|
|
bool m_modifiedBeforeMacroEditor; |
116 |
schoenebeck |
3157 |
|
117 |
schoenebeck |
3160 |
Gtk::Button m_addFromClipboardButton; |
118 |
|
|
Gtk::Button m_addFromSelectionButton; |
119 |
schoenebeck |
3162 |
Gtk::Button m_buttonUp; |
120 |
|
|
Gtk::Button m_buttonDown; |
121 |
|
|
Gtk::Button m_buttonEdit; |
122 |
schoenebeck |
3176 |
Gtk::Button m_buttonDuplicate; |
123 |
schoenebeck |
3157 |
Gtk::Label m_statusLabel; |
124 |
|
|
Gtk::Button m_deleteButton; |
125 |
|
|
Gtk::Button m_inverseDeleteButton; |
126 |
|
|
Gtk::Button m_applyButton; |
127 |
|
|
Gtk::Button m_cancelButton; |
128 |
schoenebeck |
3162 |
Gtk::Label m_labelComment; |
129 |
|
|
Gtk::ScrolledWindow m_scrolledWindowComment; |
130 |
|
|
Gtk::TextView m_textViewComment; |
131 |
schoenebeck |
3157 |
|
132 |
|
|
bool m_altKeyDown; |
133 |
schoenebeck |
3160 |
bool m_primaryKeyDown; // on Mac: Cmd key, on all other OSs: Ctrl key |
134 |
schoenebeck |
3157 |
|
135 |
schoenebeck |
3162 |
int getSelectedMacroIndex() const; |
136 |
|
|
Serialization::Archive* getSelectedMacro(); |
137 |
schoenebeck |
3157 |
bool isModified() const; |
138 |
schoenebeck |
3160 |
void onButtonAddFromClipboard(); |
139 |
|
|
void onButtonAddFromSelection(); |
140 |
schoenebeck |
3162 |
void onButtonUp(); |
141 |
|
|
void onButtonDown(); |
142 |
|
|
void moveByDir(int d); |
143 |
|
|
void onButtonEdit(); |
144 |
schoenebeck |
3176 |
void onButtonDuplicate(); |
145 |
schoenebeck |
3162 |
void onCommentTextViewChanged(); |
146 |
schoenebeck |
3157 |
void onButtonCancel(); |
147 |
|
|
void onButtonApply(); |
148 |
|
|
void onWindowHide(); |
149 |
schoenebeck |
3364 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2 |
150 |
|
|
bool onWindowDelete(Gdk::Event& e); |
151 |
|
|
#endif |
152 |
|
|
bool onWindowDeleteP(GdkEventAny* e); |
153 |
schoenebeck |
3157 |
void updateStatus(); |
154 |
|
|
void updateStatusBar(); |
155 |
|
|
void reloadTreeView(); |
156 |
|
|
void onTreeViewSelectionChanged(); |
157 |
schoenebeck |
3364 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2 |
158 |
|
|
bool onMacroTreeViewKeyRelease(Gdk::EventKey& button); |
159 |
|
|
#else |
160 |
schoenebeck |
3157 |
void onMacroTreeViewKeyRelease(GdkEventKey* button); |
161 |
schoenebeck |
3364 |
#endif |
162 |
schoenebeck |
3157 |
void onMacroTreeViewRowValueChanged(const Gtk::TreeModel::Path& path, |
163 |
|
|
const Gtk::TreeModel::iterator& iter); |
164 |
schoenebeck |
3162 |
void onMacroEditorAppliedChanges(); |
165 |
schoenebeck |
3157 |
void deleteSelectedRows(); |
166 |
|
|
void inverseDeleteSelectedRows(); |
167 |
|
|
void deleteRows(const std::vector<Gtk::TreeModel::Path>& rows); |
168 |
schoenebeck |
3176 |
void duplicateRows(const std::vector<Gtk::TreeModel::Path>& rows); |
169 |
schoenebeck |
3364 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2 |
170 |
|
|
bool onKeyPressed(Gdk::EventKey& key); |
171 |
|
|
bool onKeyReleased(Gdk::EventKey& key); |
172 |
|
|
#else |
173 |
schoenebeck |
3157 |
bool onKeyPressed(GdkEventKey* key); |
174 |
|
|
bool onKeyReleased(GdkEventKey* key); |
175 |
schoenebeck |
3364 |
#endif |
176 |
schoenebeck |
3157 |
}; |
177 |
|
|
|
178 |
|
|
#endif // GIGEDIT_MACROSSETUP_H |