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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3176 - (show annotations) (download) (as text)
Thu May 11 11:36:33 2017 UTC (6 years, 11 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 5299 byte(s)
* Macros Setup: Implemented duplicating macros.
* Bumped version (1.0.0.svn44).

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_MACROSSETUP_H
9 #define GIGEDIT_MACROSSETUP_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 Setup all gigedit macros.
29 *
30 * Shows a list with all gigedit macros configured by the user. It allows to
31 * add and remove macros, and to reorder the list of macros for altering the
32 * keyboard accelerators (F1 - F12) associated with the individual macros.
33 */
34 class MacrosSetup : public ManagedWindow {
35 public:
36 MacrosSetup();
37 ~MacrosSetup();
38 void setMacros(const std::vector<Serialization::Archive>& macros,
39 Serialization::Archive* pClipboardContent,
40 gig::DimensionRegion* pSelectedDimRgn);
41
42 sigc::signal<void, const std::vector<Serialization::Archive>& >& signal_macros_changed();
43
44 // implementation for abstract methods of interface class "ManagedWindow"
45 virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->macrosSetupWindowX; }
46 virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->macrosSetupWindowY; }
47 virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->macrosSetupWindowW; }
48 virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->macrosSetupWindowH; }
49
50 protected:
51 bool m_modified;
52 std::vector<Serialization::Archive> m_macros;
53 Serialization::Archive* m_clipboardContent;
54 gig::DimensionRegion* m_selectedDimRgn;
55
56 sigc::signal<void, const std::vector<Serialization::Archive>& > m_macros_changed;
57
58 Gtk::VBox m_vbox;
59 Gtk::HBox m_addHBox;
60 Gtk::HBox m_mainHBox;
61 Gtk::VBox m_rvbox;
62 Gtk::HButtonBox m_detailsButtonBox;
63 Gtk::HBox m_footerHBox;
64 Gtk::HBox m_statusHBox;
65 Gtk::HButtonBox m_buttonBoxL;
66 Gtk::HButtonBox m_buttonBox;
67 Gtk::ScrolledWindow m_scrolledWindow;
68
69 class MacroListModel : public Gtk::TreeModel::ColumnRecord {
70 public:
71 MacroListModel() {
72 add(m_col_key);
73 add(m_col_name);
74 add(m_col_comment);
75 add(m_col_created);
76 add(m_col_modified);
77 add(m_col_index);
78 }
79
80 Gtk::TreeModelColumn<Glib::ustring> m_col_key;
81 Gtk::TreeModelColumn<Glib::ustring> m_col_name;
82 Gtk::TreeModelColumn<Glib::ustring> m_col_comment;
83 Gtk::TreeModelColumn<Glib::ustring> m_col_created;
84 Gtk::TreeModelColumn<Glib::ustring> m_col_modified;
85 Gtk::TreeModelColumn<int> m_col_index;
86 } m_treeModelMacros;
87
88 class MacroListTreeStore : public Gtk::TreeStore {
89 public:
90 static Glib::RefPtr<MacroListTreeStore> create(const MacroListModel& columns) {
91 return Glib::RefPtr<MacroListTreeStore>( new MacroListTreeStore(columns) );
92 }
93 protected:
94 MacroListTreeStore(const MacroListModel& columns) : Gtk::TreeStore(columns) {}
95 };
96
97 Gtk::TreeView m_treeViewMacros;
98 Glib::RefPtr<MacroListTreeStore> m_treeStoreMacros;
99 bool m_ignoreTreeViewValueChange;
100 bool m_ignoreCommentTextViewChange;
101 bool m_modifiedBeforeMacroEditor;
102
103 Gtk::Button m_addFromClipboardButton;
104 Gtk::Button m_addFromSelectionButton;
105 Gtk::Button m_buttonUp;
106 Gtk::Button m_buttonDown;
107 Gtk::Button m_buttonEdit;
108 Gtk::Button m_buttonDuplicate;
109 Gtk::Label m_statusLabel;
110 Gtk::Button m_deleteButton;
111 Gtk::Button m_inverseDeleteButton;
112 Gtk::Button m_applyButton;
113 Gtk::Button m_cancelButton;
114 Gtk::Label m_labelComment;
115 Gtk::ScrolledWindow m_scrolledWindowComment;
116 Gtk::TextView m_textViewComment;
117
118 bool m_altKeyDown;
119 bool m_primaryKeyDown; // on Mac: Cmd key, on all other OSs: Ctrl key
120
121 int getSelectedMacroIndex() const;
122 Serialization::Archive* getSelectedMacro();
123 bool isModified() const;
124 void onButtonAddFromClipboard();
125 void onButtonAddFromSelection();
126 void onButtonUp();
127 void onButtonDown();
128 void moveByDir(int d);
129 void onButtonEdit();
130 void onButtonDuplicate();
131 void onCommentTextViewChanged();
132 void onButtonCancel();
133 void onButtonApply();
134 void onWindowHide();
135 bool onWindowDelete(GdkEventAny* e);
136 void updateStatus();
137 void updateStatusBar();
138 void reloadTreeView();
139 void onTreeViewSelectionChanged();
140 void onMacroTreeViewKeyRelease(GdkEventKey* button);
141 void onMacroTreeViewRowValueChanged(const Gtk::TreeModel::Path& path,
142 const Gtk::TreeModel::iterator& iter);
143 void onMacroEditorAppliedChanges();
144 void deleteSelectedRows();
145 void inverseDeleteSelectedRows();
146 void deleteRows(const std::vector<Gtk::TreeModel::Path>& rows);
147 void duplicateRows(const std::vector<Gtk::TreeModel::Path>& rows);
148 bool onKeyPressed(GdkEventKey* key);
149 bool onKeyReleased(GdkEventKey* key);
150 };
151
152 #endif // GIGEDIT_MACROSSETUP_H

  ViewVC Help
Powered by ViewVC