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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3184 - (hide annotations) (download) (as text)
Wed May 17 12:28:39 2017 UTC (7 years ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 4965 byte(s)
* Added bunch of help text and tooltips for the new
  "Macro Setup" and "Macro Editor" windows.
* wrapLabel: Fixed wrong dimensions when using
  padding.
* Bumped version (1.0.0.svn46).

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

  ViewVC Help
Powered by ViewVC