/[svn]/gigedit/trunk/src/gigedit/MacroEditor.h
ViewVC logotype

Contents of /gigedit/trunk/src/gigedit/MacroEditor.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3170 - (show annotations) (download) (as text)
Wed May 10 21:21:14 2017 UTC (6 years, 11 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 4868 byte(s)
* Macro Editor: Fixed deleting rows when delete button was hit
  without Ctrl being pressed.
* Macro Editor: Show combo box with textual options for enum types.
* Bumped version (1.0.0.svn42).

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_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 /** @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 class MacroEditor : public ManagedWindow {
34 public:
35 MacroEditor();
36 ~MacroEditor();
37 void setMacro(Serialization::Archive* macro, bool isClipboard);
38
39 sigc::signal<void>& signal_changes_applied();
40
41 // 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 sigc::signal<void> m_changes_applied;
52
53 Gtk::VBox m_vbox;
54 Gtk::HBox m_footerHBox;
55 Gtk::HBox m_statusHBox;
56 Gtk::HButtonBox m_buttonBoxL;
57 Gtk::HButtonBox m_buttonBox;
58 Gtk::ScrolledWindow m_scrolledWindow;
59 //Gtk::Label m_labelIntro;
60
61 class ComboOptionsModel : public Gtk::TreeModel::ColumnRecord {
62 public:
63 ComboOptionsModel() {
64 add(m_col_choice);
65 }
66
67 Gtk::TreeModelColumn<Glib::ustring> m_col_choice;
68 } m_comboOptionsModel;
69
70 class MacroModel : public Gtk::TreeModel::ColumnRecord {
71 public:
72 MacroModel() {
73 add(m_col_name);
74 add(m_col_type);
75 add(m_col_value);
76 add(m_col_uid);
77 add(m_col_allowTextEntry);
78 add(m_col_editable);
79 add(m_col_options);
80 }
81
82 Gtk::TreeModelColumn<Glib::ustring> m_col_name;
83 Gtk::TreeModelColumn<Glib::ustring> m_col_type;
84 Gtk::TreeModelColumn<Glib::ustring> m_col_value;
85 Gtk::TreeModelColumn<Serialization::UID> m_col_uid;
86 Gtk::TreeModelColumn<bool> m_col_allowTextEntry;
87 Gtk::TreeModelColumn<bool> m_col_editable;
88 Gtk::TreeModelColumn<Glib::RefPtr<Gtk::ListStore> > m_col_options;
89 } m_treeModelMacro;
90
91 class MacroTreeStore : public Gtk::TreeStore {
92 public:
93 static Glib::RefPtr<MacroTreeStore> create(const MacroModel& columns) {
94 return Glib::RefPtr<MacroTreeStore>( new MacroTreeStore(columns) );
95 }
96 protected:
97 MacroTreeStore(const MacroModel& columns) : Gtk::TreeStore(columns) {}
98 };
99
100 Gtk::TreeView m_treeViewMacro;
101 Glib::RefPtr<MacroTreeStore> m_treeStoreMacro;
102 Gtk::CellRendererCombo m_valueCellRenderer;
103 Glib::RefPtr<Gtk::ListStore> m_comboBoxModel;
104 bool m_ignoreTreeViewValueChange;
105
106 Gtk::Label m_statusLabel;
107 Gtk::Button m_deleteButton;
108 Gtk::Button m_inverseDeleteButton;
109 Gtk::Button m_applyButton;
110 Gtk::Button m_cancelButton;
111
112 bool m_altKeyDown;
113 bool m_primaryKeyDown; // on Mac: Cmd key, on all other OSs: Ctrl key
114
115 bool isModified() const;
116 void onButtonCancel();
117 void onButtonApply();
118 void onWindowHide();
119 bool onWindowDelete(GdkEventAny* e);
120 void updateStatus();
121 void updateStatusBar();
122 void reloadTreeView();
123 void buildTreeView(const Gtk::TreeModel::Row& parentRow, const Serialization::Object& parentObject);
124 void onTreeViewSelectionChanged();
125 void onMacroTreeViewKeyRelease(GdkEventKey* button);
126 void onMacroTreeViewRowValueChanged(const Gtk::TreeModel::Path& path,
127 const Gtk::TreeModel::iterator& iter);
128 void onMacroTreeViewRowValueChangedImpl(const Gtk::TreeModel::Path& path,
129 const Gtk::TreeModel::iterator& iter,
130 const Glib::ustring& value);
131 void onValueCellEdited(const Glib::ustring& sPath, const Glib::ustring& text);
132 void deleteSelectedRows();
133 void inverseDeleteSelectedRows();
134 void deleteRows(const std::vector<Gtk::TreeModel::Path>& rows);
135 bool onKeyPressed(GdkEventKey* key);
136 bool onKeyReleased(GdkEventKey* key);
137 Glib::RefPtr<Gtk::ListStore> createComboOptions(const char** options);
138 };
139
140 #endif // GIGEDIT_MACROEDITOR_H

  ViewVC Help
Powered by ViewVC