1 |
schoenebeck |
3151 |
/* |
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_MACROEDITOR_H |
9 |
|
|
#define GIGEDIT_MACROEDITOR_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 |
schoenebeck |
3364 |
#ifdef GTKMM_HEADER_FILE |
20 |
|
|
# include GTKMM_HEADER_FILE(gtkmm.h) |
21 |
|
|
#else |
22 |
|
|
# include <gtkmm.h> |
23 |
|
|
#endif |
24 |
|
|
|
25 |
schoenebeck |
3151 |
#if HAVE_CONFIG_H |
26 |
|
|
# include <config.h> |
27 |
|
|
#endif |
28 |
|
|
#include "compat.h" |
29 |
schoenebeck |
3364 |
#if USE_GTKMM_BUILDER |
30 |
|
|
# include <gtkmm/builder.h> |
31 |
|
|
#else |
32 |
|
|
# include <gtkmm/uimanager.h> // deprecated in gtkmm >= 3.21.4 |
33 |
|
|
#endif |
34 |
schoenebeck |
3184 |
#include "wrapLabel.hh" |
35 |
schoenebeck |
3151 |
#include "ManagedWindow.h" |
36 |
|
|
|
37 |
schoenebeck |
3157 |
/** @brief Editor for gigedit macros. |
38 |
|
|
* |
39 |
|
|
* Implements a window which allows to edit the abstract tree of one macro |
40 |
|
|
* that may be applied with gigedit. |
41 |
|
|
*/ |
42 |
schoenebeck |
3151 |
class MacroEditor : public ManagedWindow { |
43 |
|
|
public: |
44 |
|
|
MacroEditor(); |
45 |
|
|
~MacroEditor(); |
46 |
schoenebeck |
3162 |
void setMacro(Serialization::Archive* macro, bool isClipboard); |
47 |
schoenebeck |
3151 |
|
48 |
schoenebeck |
3162 |
sigc::signal<void>& signal_changes_applied(); |
49 |
|
|
|
50 |
schoenebeck |
3151 |
// implementation for abstract methods of interface class "ManagedWindow" |
51 |
|
|
virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->macroEditorWindowX; } |
52 |
|
|
virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->macroEditorWindowY; } |
53 |
|
|
virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->macroEditorWindowW; } |
54 |
|
|
virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->macroEditorWindowH; } |
55 |
|
|
|
56 |
|
|
protected: |
57 |
|
|
Serialization::Archive* m_macroOriginal; |
58 |
|
|
Serialization::Archive m_macro; |
59 |
|
|
|
60 |
schoenebeck |
3162 |
sigc::signal<void> m_changes_applied; |
61 |
|
|
|
62 |
schoenebeck |
3364 |
VBox m_vbox; |
63 |
|
|
HBox m_footerHBox; |
64 |
|
|
HBox m_statusHBox; |
65 |
|
|
HButtonBox m_buttonBoxL; |
66 |
|
|
HButtonBox m_buttonBox; |
67 |
schoenebeck |
3151 |
Gtk::ScrolledWindow m_scrolledWindow; |
68 |
schoenebeck |
3184 |
#if GTKMM_MAJOR_VERSION < 3 |
69 |
|
|
view::WrapLabel m_labelIntro; |
70 |
|
|
#else |
71 |
|
|
Gtk::Label m_labelIntro; |
72 |
|
|
#endif |
73 |
schoenebeck |
3151 |
|
74 |
schoenebeck |
3170 |
class ComboOptionsModel : public Gtk::TreeModel::ColumnRecord { |
75 |
|
|
public: |
76 |
|
|
ComboOptionsModel() { |
77 |
|
|
add(m_col_choice); |
78 |
|
|
} |
79 |
|
|
|
80 |
|
|
Gtk::TreeModelColumn<Glib::ustring> m_col_choice; |
81 |
|
|
} m_comboOptionsModel; |
82 |
|
|
|
83 |
schoenebeck |
3151 |
class MacroModel : public Gtk::TreeModel::ColumnRecord { |
84 |
|
|
public: |
85 |
|
|
MacroModel() { |
86 |
|
|
add(m_col_name); |
87 |
|
|
add(m_col_type); |
88 |
|
|
add(m_col_value); |
89 |
|
|
add(m_col_uid); |
90 |
schoenebeck |
3170 |
add(m_col_allowTextEntry); |
91 |
|
|
add(m_col_editable); |
92 |
|
|
add(m_col_options); |
93 |
schoenebeck |
3151 |
} |
94 |
|
|
|
95 |
|
|
Gtk::TreeModelColumn<Glib::ustring> m_col_name; |
96 |
|
|
Gtk::TreeModelColumn<Glib::ustring> m_col_type; |
97 |
|
|
Gtk::TreeModelColumn<Glib::ustring> m_col_value; |
98 |
|
|
Gtk::TreeModelColumn<Serialization::UID> m_col_uid; |
99 |
schoenebeck |
3170 |
Gtk::TreeModelColumn<bool> m_col_allowTextEntry; |
100 |
|
|
Gtk::TreeModelColumn<bool> m_col_editable; |
101 |
|
|
Gtk::TreeModelColumn<Glib::RefPtr<Gtk::ListStore> > m_col_options; |
102 |
schoenebeck |
3151 |
} m_treeModelMacro; |
103 |
|
|
|
104 |
|
|
class MacroTreeStore : public Gtk::TreeStore { |
105 |
|
|
public: |
106 |
|
|
static Glib::RefPtr<MacroTreeStore> create(const MacroModel& columns) { |
107 |
|
|
return Glib::RefPtr<MacroTreeStore>( new MacroTreeStore(columns) ); |
108 |
|
|
} |
109 |
|
|
protected: |
110 |
|
|
MacroTreeStore(const MacroModel& columns) : Gtk::TreeStore(columns) {} |
111 |
|
|
}; |
112 |
|
|
|
113 |
|
|
Gtk::TreeView m_treeViewMacro; |
114 |
|
|
Glib::RefPtr<MacroTreeStore> m_treeStoreMacro; |
115 |
schoenebeck |
3170 |
Gtk::CellRendererCombo m_valueCellRenderer; |
116 |
|
|
Glib::RefPtr<Gtk::ListStore> m_comboBoxModel; |
117 |
schoenebeck |
3154 |
bool m_ignoreTreeViewValueChange; |
118 |
schoenebeck |
3151 |
|
119 |
|
|
Gtk::Label m_statusLabel; |
120 |
schoenebeck |
3154 |
Gtk::Button m_deleteButton; |
121 |
|
|
Gtk::Button m_inverseDeleteButton; |
122 |
schoenebeck |
3151 |
Gtk::Button m_applyButton; |
123 |
|
|
Gtk::Button m_cancelButton; |
124 |
|
|
|
125 |
schoenebeck |
3155 |
bool m_altKeyDown; |
126 |
schoenebeck |
3170 |
bool m_primaryKeyDown; // on Mac: Cmd key, on all other OSs: Ctrl key |
127 |
schoenebeck |
3155 |
|
128 |
schoenebeck |
3151 |
bool isModified() const; |
129 |
|
|
void onButtonCancel(); |
130 |
|
|
void onButtonApply(); |
131 |
|
|
void onWindowHide(); |
132 |
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 |
133 |
|
|
bool onWindowDelete(Gdk::Event& e); |
134 |
|
|
#endif |
135 |
|
|
bool onWindowDeleteP(GdkEventAny* e); |
136 |
schoenebeck |
3151 |
void updateStatus(); |
137 |
|
|
void updateStatusBar(); |
138 |
|
|
void reloadTreeView(); |
139 |
|
|
void buildTreeView(const Gtk::TreeModel::Row& parentRow, const Serialization::Object& parentObject); |
140 |
schoenebeck |
3154 |
void onTreeViewSelectionChanged(); |
141 |
schoenebeck |
3364 |
|
142 |
|
|
#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 |
143 |
|
|
bool onMacroTreeViewKeyRelease(Gdk::EventKey& key); |
144 |
|
|
#else |
145 |
schoenebeck |
3154 |
void onMacroTreeViewKeyRelease(GdkEventKey* button); |
146 |
schoenebeck |
3364 |
#endif |
147 |
schoenebeck |
3154 |
void onMacroTreeViewRowValueChanged(const Gtk::TreeModel::Path& path, |
148 |
|
|
const Gtk::TreeModel::iterator& iter); |
149 |
schoenebeck |
3170 |
void onMacroTreeViewRowValueChangedImpl(const Gtk::TreeModel::Path& path, |
150 |
|
|
const Gtk::TreeModel::iterator& iter, |
151 |
|
|
const Glib::ustring& value); |
152 |
|
|
void onValueCellEdited(const Glib::ustring& sPath, const Glib::ustring& text); |
153 |
schoenebeck |
3154 |
void deleteSelectedRows(); |
154 |
|
|
void inverseDeleteSelectedRows(); |
155 |
schoenebeck |
3155 |
void deleteRows(const std::vector<Gtk::TreeModel::Path>& rows); |
156 |
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 |
157 |
|
|
bool onKeyPressed(Gdk::EventKey& key); |
158 |
|
|
bool onKeyReleased(Gdk::EventKey& key); |
159 |
|
|
#else |
160 |
schoenebeck |
3155 |
bool onKeyPressed(GdkEventKey* key); |
161 |
|
|
bool onKeyReleased(GdkEventKey* key); |
162 |
schoenebeck |
3364 |
#endif |
163 |
schoenebeck |
3170 |
Glib::RefPtr<Gtk::ListStore> createComboOptions(const char** options); |
164 |
schoenebeck |
3151 |
}; |
165 |
|
|
|
166 |
|
|
#endif // GIGEDIT_MACROEDITOR_H |