/[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 3162 - (show annotations) (download) (as text)
Tue May 9 14:35:23 2017 UTC (6 years, 11 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 3780 byte(s)
* Macros Setup: Implemented reordering macros by "Up" and
  "Down" buttons (and accordingly also altering the
  F1 ... F12 acceleration keys they are assigned to).
* Macros Setup: Implemented calling Macro Editor from
  this macro setup dialog by hitting "Edit" button.
* Macros Setup: Implemented editing comment on macros.
* Macros Setup: Enabled various icons.
* Bumped version (1.0.0.svn41).

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 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 bool m_ignoreTreeViewValueChange;
88
89 Gtk::Label m_statusLabel;
90 Gtk::Button m_deleteButton;
91 Gtk::Button m_inverseDeleteButton;
92 Gtk::Button m_applyButton;
93 Gtk::Button m_cancelButton;
94
95 bool m_altKeyDown;
96
97 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 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 void deleteRows(const std::vector<Gtk::TreeModel::Path>& rows);
113 bool onKeyPressed(GdkEventKey* key);
114 bool onKeyReleased(GdkEventKey* key);
115 };
116
117 #endif // GIGEDIT_MACROEDITOR_H

  ViewVC Help
Powered by ViewVC