1 |
/* |
2 |
Copyright (c) MMXX 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 SCRIPT_PATCH_VARS_H |
9 |
#define SCRIPT_PATCH_VARS_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 |
#ifdef GTKMM_HEADER_FILE |
20 |
# include GTKMM_HEADER_FILE(gtkmm.h) |
21 |
#else |
22 |
# include <gtkmm.h> |
23 |
#endif |
24 |
|
25 |
#if HAVE_CONFIG_H |
26 |
# include <config.h> |
27 |
#endif |
28 |
#include "compat.h" |
29 |
#if USE_GTKMM_BUILDER |
30 |
# include <gtkmm/builder.h> |
31 |
#else |
32 |
# include <gtkmm/uimanager.h> // deprecated in gtkmm >= 3.21.4 |
33 |
#endif |
34 |
#include "wrapLabel.hh" |
35 |
|
36 |
#include "scripteditor.h" // lazy inclusion of LS script VM header files |
37 |
|
38 |
/** @brief Editor for real-time instrument script 'patch' variables. |
39 |
* |
40 |
* 'Patch' variables are special variable types in real-time instrument scripts |
41 |
* which allow to override their initial value on a per instrument basis. That |
42 |
* allows to share the same script among multiple instruments, while at the same |
43 |
* time being able to fine tune certain aspects of the script for a specific |
44 |
* instrument. |
45 |
* |
46 |
* This class implements a window which allows to edit such 'patch' variables |
47 |
* for the currently selected instrument. In Gigedit this is currently available |
48 |
* under the 'Script' tab on the right hand side of Gigedit's main window. |
49 |
*/ |
50 |
class ScriptPatchVars : public Gtk::ScrolledWindow { |
51 |
public: |
52 |
ScriptPatchVars(); |
53 |
void setInstrument(gig::Instrument* pInstrument, bool forceUpdate = false); |
54 |
void deleteSelectedRows(); |
55 |
|
56 |
sigc::signal<void, gig::Instrument*> signal_vars_to_be_changed; |
57 |
sigc::signal<void, gig::Instrument*> signal_vars_changed; |
58 |
|
59 |
class VarsModel : public Gtk::TreeModel::ColumnRecord { |
60 |
public: |
61 |
VarsModel() { |
62 |
add(m_col_name); |
63 |
add(m_col_name_color); |
64 |
add(m_col_name_weight); |
65 |
add(m_col_type); |
66 |
add(m_col_value); |
67 |
add(m_col_value_color); |
68 |
add(m_col_value_weight); |
69 |
add(m_col_value_tooltip); |
70 |
add(m_col_slot); |
71 |
add(m_col_allowTextEntry); |
72 |
add(m_col_editable); |
73 |
add(m_col_options); |
74 |
add(m_col_script); |
75 |
} |
76 |
|
77 |
Gtk::TreeModelColumn<Glib::ustring> m_col_name; |
78 |
Gtk::TreeModelColumn<Glib::ustring> m_col_name_color; |
79 |
Gtk::TreeModelColumn<int> m_col_name_weight; |
80 |
Gtk::TreeModelColumn<Glib::ustring> m_col_type; |
81 |
Gtk::TreeModelColumn<Glib::ustring> m_col_value; |
82 |
Gtk::TreeModelColumn<Glib::ustring> m_col_value_color; |
83 |
Gtk::TreeModelColumn<int> m_col_value_weight; |
84 |
Gtk::TreeModelColumn<Glib::ustring> m_col_value_tooltip; |
85 |
Gtk::TreeModelColumn<int> m_col_slot; |
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 |
Gtk::TreeModelColumn<gig::Script*> m_col_script; |
90 |
} m_treeModel; |
91 |
|
92 |
class VarsTreeStore : public Gtk::TreeStore { |
93 |
public: |
94 |
static Glib::RefPtr<VarsTreeStore> create(const VarsModel& columns) { |
95 |
return Glib::RefPtr<VarsTreeStore>( new VarsTreeStore(columns) ); |
96 |
} |
97 |
protected: |
98 |
VarsTreeStore(const VarsModel& columns) : Gtk::TreeStore(columns) {} |
99 |
}; |
100 |
|
101 |
Gtk::TreeView m_treeView; |
102 |
Glib::RefPtr<VarsTreeStore> m_treeStore; |
103 |
Gtk::CellRendererCombo m_valueCellRenderer; |
104 |
bool m_ignoreTreeViewValueChange; |
105 |
|
106 |
protected: |
107 |
void buildTreeViewVar(const Gtk::TreeModel::Row& parentRow, int iScriptSlot, |
108 |
gig::Script* script, const std::string name, |
109 |
const struct PatchVar* var); |
110 |
void buildTreeViewSlot(const Gtk::TreeModel::Row& parentRow, int iScriptSlot); |
111 |
void reloadTreeView(); |
112 |
void onValueCellEdited(const Glib::ustring& sPath, const Glib::ustring& text); |
113 |
void onTreeViewSelectionChanged(); |
114 |
bool onQueryTreeViewTooltip(int x, int y, bool keyboardTip, |
115 |
const Glib::RefPtr<Gtk::Tooltip>& tooltip); |
116 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2 |
117 |
bool onTreeViewKeyRelease(Gdk::EventKey& key); |
118 |
#else |
119 |
void onTreeViewKeyRelease(GdkEventKey* button); |
120 |
#endif |
121 |
void deleteRows(const std::vector<Gtk::TreeModel::Path>& rows); |
122 |
void onTreeViewRowChanged(const Gtk::TreeModel::Path& path, |
123 |
const Gtk::TreeModel::iterator& iter); |
124 |
void onTreeViewRowValueChanged(const Gtk::TreeModel::Path& path, |
125 |
const Gtk::TreeModel::iterator& iter, |
126 |
const Glib::ustring value); |
127 |
private: |
128 |
::gig::Instrument* m_instrument; |
129 |
//bool m_editing; |
130 |
}; |
131 |
|
132 |
#endif // SCRIPT_PATCH_VARS_H |