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