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 |
|
|
#include <gtkmm.h> |
20 |
|
|
#if HAVE_CONFIG_H |
21 |
|
|
# include <config.h> |
22 |
|
|
#endif |
23 |
|
|
#include "compat.h" |
24 |
|
|
#include <gtkmm/uimanager.h> |
25 |
|
|
#include <gtkmm/actiongroup.h> |
26 |
|
|
#include "ManagedWindow.h" |
27 |
|
|
|
28 |
schoenebeck |
3157 |
/** @brief Editor for gigedit macros. |
29 |
|
|
* |
30 |
|
|
* Implements a window which allows to edit the abstract tree of one macro |
31 |
|
|
* that may be applied with gigedit. |
32 |
|
|
*/ |
33 |
schoenebeck |
3151 |
class MacroEditor : public ManagedWindow { |
34 |
|
|
public: |
35 |
|
|
MacroEditor(); |
36 |
|
|
~MacroEditor(); |
37 |
schoenebeck |
3162 |
void setMacro(Serialization::Archive* macro, bool isClipboard); |
38 |
schoenebeck |
3151 |
|
39 |
schoenebeck |
3162 |
sigc::signal<void>& signal_changes_applied(); |
40 |
|
|
|
41 |
schoenebeck |
3151 |
// implementation for abstract methods of interface class "ManagedWindow" |
42 |
|
|
virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->macroEditorWindowX; } |
43 |
|
|
virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->macroEditorWindowY; } |
44 |
|
|
virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->macroEditorWindowW; } |
45 |
|
|
virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->macroEditorWindowH; } |
46 |
|
|
|
47 |
|
|
protected: |
48 |
|
|
Serialization::Archive* m_macroOriginal; |
49 |
|
|
Serialization::Archive m_macro; |
50 |
|
|
|
51 |
schoenebeck |
3162 |
sigc::signal<void> m_changes_applied; |
52 |
|
|
|
53 |
schoenebeck |
3151 |
Gtk::VBox m_vbox; |
54 |
|
|
Gtk::HBox m_footerHBox; |
55 |
|
|
Gtk::HBox m_statusHBox; |
56 |
schoenebeck |
3154 |
Gtk::HButtonBox m_buttonBoxL; |
57 |
schoenebeck |
3151 |
Gtk::HButtonBox m_buttonBox; |
58 |
|
|
Gtk::ScrolledWindow m_scrolledWindow; |
59 |
schoenebeck |
3162 |
//Gtk::Label m_labelIntro; |
60 |
schoenebeck |
3151 |
|
61 |
|
|
class MacroModel : public Gtk::TreeModel::ColumnRecord { |
62 |
|
|
public: |
63 |
|
|
MacroModel() { |
64 |
|
|
add(m_col_name); |
65 |
|
|
add(m_col_type); |
66 |
|
|
add(m_col_value); |
67 |
|
|
add(m_col_uid); |
68 |
|
|
} |
69 |
|
|
|
70 |
|
|
Gtk::TreeModelColumn<Glib::ustring> m_col_name; |
71 |
|
|
Gtk::TreeModelColumn<Glib::ustring> m_col_type; |
72 |
|
|
Gtk::TreeModelColumn<Glib::ustring> m_col_value; |
73 |
|
|
Gtk::TreeModelColumn<Serialization::UID> m_col_uid; |
74 |
|
|
} m_treeModelMacro; |
75 |
|
|
|
76 |
|
|
class MacroTreeStore : public Gtk::TreeStore { |
77 |
|
|
public: |
78 |
|
|
static Glib::RefPtr<MacroTreeStore> create(const MacroModel& columns) { |
79 |
|
|
return Glib::RefPtr<MacroTreeStore>( new MacroTreeStore(columns) ); |
80 |
|
|
} |
81 |
|
|
protected: |
82 |
|
|
MacroTreeStore(const MacroModel& columns) : Gtk::TreeStore(columns) {} |
83 |
|
|
}; |
84 |
|
|
|
85 |
|
|
Gtk::TreeView m_treeViewMacro; |
86 |
|
|
Glib::RefPtr<MacroTreeStore> m_treeStoreMacro; |
87 |
schoenebeck |
3154 |
bool m_ignoreTreeViewValueChange; |
88 |
schoenebeck |
3151 |
|
89 |
|
|
Gtk::Label m_statusLabel; |
90 |
schoenebeck |
3154 |
Gtk::Button m_deleteButton; |
91 |
|
|
Gtk::Button m_inverseDeleteButton; |
92 |
schoenebeck |
3151 |
Gtk::Button m_applyButton; |
93 |
|
|
Gtk::Button m_cancelButton; |
94 |
|
|
|
95 |
schoenebeck |
3155 |
bool m_altKeyDown; |
96 |
|
|
|
97 |
schoenebeck |
3151 |
bool isModified() const; |
98 |
|
|
void onButtonCancel(); |
99 |
|
|
void onButtonApply(); |
100 |
|
|
void onWindowHide(); |
101 |
|
|
bool onWindowDelete(GdkEventAny* e); |
102 |
|
|
void updateStatus(); |
103 |
|
|
void updateStatusBar(); |
104 |
|
|
void reloadTreeView(); |
105 |
|
|
void buildTreeView(const Gtk::TreeModel::Row& parentRow, const Serialization::Object& parentObject); |
106 |
schoenebeck |
3154 |
void onTreeViewSelectionChanged(); |
107 |
|
|
void onMacroTreeViewKeyRelease(GdkEventKey* button); |
108 |
|
|
void onMacroTreeViewRowValueChanged(const Gtk::TreeModel::Path& path, |
109 |
|
|
const Gtk::TreeModel::iterator& iter); |
110 |
|
|
void deleteSelectedRows(); |
111 |
|
|
void inverseDeleteSelectedRows(); |
112 |
schoenebeck |
3155 |
void deleteRows(const std::vector<Gtk::TreeModel::Path>& rows); |
113 |
|
|
bool onKeyPressed(GdkEventKey* key); |
114 |
|
|
bool onKeyReleased(GdkEventKey* key); |
115 |
schoenebeck |
3151 |
}; |
116 |
|
|
|
117 |
|
|
#endif // GIGEDIT_MACROEDITOR_H |