1 |
/* |
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 |
|
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 |
#include "wrapLabel.hh" |
35 |
#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 |
void setMacros(const std::vector<Serialization::Archive>& macros, |
48 |
Serialization::Archive* pClipboardContent, |
49 |
gig::DimensionRegion* pSelectedDimRgn); |
50 |
|
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 |
bool m_modified; |
61 |
std::vector<Serialization::Archive> m_macros; |
62 |
Serialization::Archive* m_clipboardContent; |
63 |
gig::DimensionRegion* m_selectedDimRgn; |
64 |
|
65 |
sigc::signal<void, const std::vector<Serialization::Archive>& > m_macros_changed; |
66 |
|
67 |
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 |
Gtk::ScrolledWindow m_scrolledWindow; |
77 |
#if GTKMM_MAJOR_VERSION < 3 |
78 |
view::WrapLabel m_labelIntro; |
79 |
#else |
80 |
Gtk::Label m_labelIntro; |
81 |
#endif |
82 |
|
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 |
bool m_ignoreCommentTextViewChange; |
115 |
bool m_modifiedBeforeMacroEditor; |
116 |
|
117 |
Gtk::Button m_addFromClipboardButton; |
118 |
Gtk::Button m_addFromSelectionButton; |
119 |
Gtk::Button m_buttonUp; |
120 |
Gtk::Button m_buttonDown; |
121 |
Gtk::Button m_buttonEdit; |
122 |
Gtk::Button m_buttonDuplicate; |
123 |
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 |
Gtk::Label m_labelComment; |
129 |
Gtk::ScrolledWindow m_scrolledWindowComment; |
130 |
Gtk::TextView m_textViewComment; |
131 |
|
132 |
bool m_altKeyDown; |
133 |
bool m_primaryKeyDown; // on Mac: Cmd key, on all other OSs: Ctrl key |
134 |
|
135 |
int getSelectedMacroIndex() const; |
136 |
Serialization::Archive* getSelectedMacro(); |
137 |
bool isModified() const; |
138 |
void onButtonAddFromClipboard(); |
139 |
void onButtonAddFromSelection(); |
140 |
void onButtonUp(); |
141 |
void onButtonDown(); |
142 |
void moveByDir(int d); |
143 |
void onButtonEdit(); |
144 |
void onButtonDuplicate(); |
145 |
void onCommentTextViewChanged(); |
146 |
void onButtonCancel(); |
147 |
void onButtonApply(); |
148 |
void onWindowHide(); |
149 |
#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 |
void updateStatus(); |
154 |
void updateStatusBar(); |
155 |
void reloadTreeView(); |
156 |
void onTreeViewSelectionChanged(); |
157 |
#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 |
void onMacroTreeViewKeyRelease(GdkEventKey* button); |
161 |
#endif |
162 |
void onMacroTreeViewRowValueChanged(const Gtk::TreeModel::Path& path, |
163 |
const Gtk::TreeModel::iterator& iter); |
164 |
void onMacroEditorAppliedChanges(); |
165 |
void deleteSelectedRows(); |
166 |
void inverseDeleteSelectedRows(); |
167 |
void deleteRows(const std::vector<Gtk::TreeModel::Path>& rows); |
168 |
void duplicateRows(const std::vector<Gtk::TreeModel::Path>& rows); |
169 |
#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 |
bool onKeyPressed(GdkEventKey* key); |
174 |
bool onKeyReleased(GdkEventKey* key); |
175 |
#endif |
176 |
}; |
177 |
|
178 |
#endif // GIGEDIT_MACROSSETUP_H |