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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3749 - (hide annotations) (download) (as text)
Sun Feb 16 18:39:53 2020 UTC (4 years, 2 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 5006 byte(s)
* Script 'patch' variables editor: double click anywhere on a script's
  title row (or hitting <enter> while that row is selected) opens
  script source code editor for that double clicked script.

* Also show a tooltip and a pencil icon on such rows to make user
  visually aware about this feature.

* Bumped version (1.1.1.svn17).

1 schoenebeck 3737 /*
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 schoenebeck 3749 sigc::signal<void, gig::Script*> signal_edit_script;
59 schoenebeck 3737
60     class VarsModel : public Gtk::TreeModel::ColumnRecord {
61     public:
62     VarsModel() {
63     add(m_col_name);
64     add(m_col_name_color);
65     add(m_col_name_weight);
66     add(m_col_type);
67     add(m_col_value);
68     add(m_col_value_color);
69     add(m_col_value_weight);
70     add(m_col_value_tooltip);
71     add(m_col_slot);
72     add(m_col_allowTextEntry);
73     add(m_col_editable);
74     add(m_col_options);
75     add(m_col_script);
76     }
77    
78     Gtk::TreeModelColumn<Glib::ustring> m_col_name;
79     Gtk::TreeModelColumn<Glib::ustring> m_col_name_color;
80     Gtk::TreeModelColumn<int> m_col_name_weight;
81     Gtk::TreeModelColumn<Glib::ustring> m_col_type;
82     Gtk::TreeModelColumn<Glib::ustring> m_col_value;
83     Gtk::TreeModelColumn<Glib::ustring> m_col_value_color;
84     Gtk::TreeModelColumn<int> m_col_value_weight;
85     Gtk::TreeModelColumn<Glib::ustring> m_col_value_tooltip;
86     Gtk::TreeModelColumn<int> m_col_slot;
87     Gtk::TreeModelColumn<bool> m_col_allowTextEntry;
88     Gtk::TreeModelColumn<bool> m_col_editable;
89     Gtk::TreeModelColumn<Glib::RefPtr<Gtk::ListStore> > m_col_options;
90     Gtk::TreeModelColumn<gig::Script*> m_col_script;
91     } m_treeModel;
92    
93     class VarsTreeStore : public Gtk::TreeStore {
94     public:
95     static Glib::RefPtr<VarsTreeStore> create(const VarsModel& columns) {
96     return Glib::RefPtr<VarsTreeStore>( new VarsTreeStore(columns) );
97     }
98     protected:
99     VarsTreeStore(const VarsModel& columns) : Gtk::TreeStore(columns) {}
100     };
101    
102     Gtk::TreeView m_treeView;
103     Glib::RefPtr<VarsTreeStore> m_treeStore;
104     Gtk::CellRendererCombo m_valueCellRenderer;
105     bool m_ignoreTreeViewValueChange;
106    
107     protected:
108     void buildTreeViewVar(const Gtk::TreeModel::Row& parentRow, int iScriptSlot,
109     gig::Script* script, const std::string name,
110     const struct PatchVar* var);
111     void buildTreeViewSlot(const Gtk::TreeModel::Row& parentRow, int iScriptSlot);
112     void reloadTreeView();
113     void onValueCellEdited(const Glib::ustring& sPath, const Glib::ustring& text);
114     void onTreeViewSelectionChanged();
115     bool onQueryTreeViewTooltip(int x, int y, bool keyboardTip,
116     const Glib::RefPtr<Gtk::Tooltip>& tooltip);
117     #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
118     bool onTreeViewKeyRelease(Gdk::EventKey& key);
119     #else
120     void onTreeViewKeyRelease(GdkEventKey* button);
121     #endif
122     void deleteRows(const std::vector<Gtk::TreeModel::Path>& rows);
123     void onTreeViewRowChanged(const Gtk::TreeModel::Path& path,
124     const Gtk::TreeModel::iterator& iter);
125     void onTreeViewRowValueChanged(const Gtk::TreeModel::Path& path,
126     const Gtk::TreeModel::iterator& iter,
127     const Glib::ustring value);
128     private:
129     ::gig::Instrument* m_instrument;
130 schoenebeck 3748 bool m_editing;
131 schoenebeck 3737 };
132    
133     #endif // SCRIPT_PATCH_VARS_H

  ViewVC Help
Powered by ViewVC