Guitarix
gx_main_midi.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009, 2010 Hermann Meyer, James Warden, Andreas Degert
3  * Copyright (C) 2011 Pete Shorthose
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  * ---------------------------------------------------------------------------
19  *
20  * This file is part of the guitarix GUI main class
21  * Note: this header file depends on gx_parameter.h
22  * and make use of the gx_engine namespace
23  *
24  * ----------------------------------------------------------------------------
25  */
26 
27 #pragma once
28 
29 #ifndef SRC_HEADERS_GX_MAIN_MIDI_H_
30 #define SRC_HEADERS_GX_MAIN_MIDI_H_
31 
32 #ifndef SRC_HEADERS_GX_PARAMETER_H_
33 #include "./gx_parameter.h"
34 #endif
35 
36 #include <glibmm.h>
37 #include <gtk/gtk.h>
38 
39 #include <iomanip>
40 #include <cstring>
41 #include <string>
42 
43 class ToggleAction; //FIXME
44 
45 namespace gx_main_midi {
46 /****************************************************************
47  ** MidiControllerTable
48  */
49 
50 class MidiControllerTable: public sigc::trackable {
51  private:
53  static GtkWidget *window; // there can only be 1 window
54  GtkToggleButton *togglebutton;
55  GtkTreeSelection *selection;
56  GtkListStore *store;
57  Glib::RefPtr<ToggleAction> menuaction;
59  sigc::connection midi_conn;
60  static void response_cb(GtkWidget *widget, gint response_id, gpointer data);
61  static void edited_cb(GtkCellRendererText *renderer, gchar *path,
62  gchar *new_text, gpointer data);
63  static void destroy_cb(GtkWidget*, gpointer data);
64  static void toggleButtonSetSwitch(GtkWidget *w, gpointer data);
65  void set(bool v);
66  void load();
67  explicit MidiControllerTable(gx_engine::GxMachineBase& machine, Glib::RefPtr<ToggleAction> item);
69  public:
70  static void toggle(gx_engine::GxMachineBase& machine, Glib::RefPtr<ToggleAction> item);
71 };
72 
73 /*****************************************************************
74  ** Midi Control
75  */
76 
77 class MidiConnect {
78  private:
79  enum { RESPONSE_DELETE = 1 };
80  std::map<gx_engine::Parameter::toggle_type, const char*> toggle_behaviour_descriptions {
81  { gx_engine::Parameter::toggle_type::OnOff, "off /on states transition toggle" },
82  { gx_engine::Parameter::toggle_type::Constant, "constant state toggle" },
83  { gx_engine::Parameter::toggle_type::Toggle, "toggle state" },
84  { gx_engine::Parameter::toggle_type::Commander, "always toggle" }
85  };
86  GtkListStore* store;
90  GtkAdjustment* adj_lower;
91  GtkAdjustment* adj_upper;
92  GtkToggleButton *use_toggle;
93  //
94  GtkWidget* dialog;
95  GtkWidget* entry_new;
96  GtkWidget* label_desc;
97  GtkWidget* toggle_behaviours;
98  static string ctr_desc(int ctr);
99  static const char *ctl_to_str(int n);
100  public:
102  static void midi_response_cb(GtkWidget *widget, gint response_id, gpointer data);
103  static void midi_destroy_cb(GtkWidget *widget, gpointer data);
104  static void toggle_behaviours_visibility(GtkWidget *widget, gpointer data);
105  static gboolean check_midi_cb(gpointer);
106  static void changed_text_handler(GtkEditable *entry, gpointer data);
107 };
108 
109 } // end namespace
110 #endif // SRC_HEADERS_GX_MAIN_MIDI_H_
111 
gx_main_midi::MidiControllerTable::load
void load()
gx_main_midi::MidiConnect::current_control
int current_control
Definition: gx_main_midi.h:91
gx_main_midi::MidiConnect::RESPONSE_DELETE
@ RESPONSE_DELETE
Definition: gx_main_midi.h:83
gx_parameter.h
gx_main_midi::MidiControllerTable::togglebutton
GtkToggleButton * togglebutton
Definition: gx_main_midi.h:56
gx_engine::GxMachineBase
Definition: machine.h:55
gx_main_midi::MidiConnect::toggle_behaviours_visibility
static void toggle_behaviours_visibility(GtkWidget *widget, gpointer data)
gx_main_midi
Definition: gx_main_midi.h:45
gx_main_midi::MidiConnect::midi_destroy_cb
static void midi_destroy_cb(GtkWidget *widget, gpointer data)
gx_main_midi::MidiConnect::ctr_desc
static string ctr_desc(int ctr)
gx_main_midi::MidiControllerTable::response_cb
static void response_cb(GtkWidget *widget, gint response_id, gpointer data)
gx_main_midi::MidiConnect::store
GtkListStore * store
Definition: gx_main_midi.h:88
gx_main_midi::MidiConnect::ctl_to_str
static const char * ctl_to_str(int n)
gx_main_midi::MidiControllerTable::machine
gx_engine::GxMachineBase & machine
Definition: gx_main_midi.h:60
gx_main_midi::MidiConnect::toggle_behaviour_descriptions
std::map< gx_engine::Parameter::toggle_type, const char * > toggle_behaviour_descriptions
Definition: gx_main_midi.h:82
gx_main_midi::MidiControllerTable::window
static GtkWidget * window
Definition: gx_main_midi.h:55
gx_main_midi::MidiConnect::midi_response_cb
static void midi_response_cb(GtkWidget *widget, gint response_id, gpointer data)
gx_main_midi::MidiControllerTable::midi_conn
sigc::connection midi_conn
Definition: gx_main_midi.h:61
gx_main_midi::MidiConnect::use_toggle
GtkToggleButton * use_toggle
Definition: gx_main_midi.h:94
gx_main_midi::MidiControllerTable::set
void set(bool v)
gx_main_midi::MidiConnect::MidiConnect
MidiConnect(GdkEventButton *event, gx_engine::Parameter &param, gx_engine::GxMachineBase &machine)
gx_main_midi::MidiConnect::changed_text_handler
static void changed_text_handler(GtkEditable *entry, gpointer data)
gx_main_midi::MidiControllerTable::menuaction
Glib::RefPtr< ToggleAction > menuaction
Definition: gx_main_midi.h:59
gx_main_midi::MidiConnect::toggle_behaviours
GtkWidget * toggle_behaviours
Definition: gx_main_midi.h:99
gx_main_midi::MidiControllerTable::MidiControllerTable
MidiControllerTable(gx_engine::GxMachineBase &machine, Glib::RefPtr< ToggleAction > item)
gx_main_midi::MidiConnect::dialog
GtkWidget * dialog
Definition: gx_main_midi.h:96
gx_main_midi::MidiConnect
Definition: gx_main_midi.h:77
gx_main_midi::MidiConnect::adj_upper
GtkAdjustment * adj_upper
Definition: gx_main_midi.h:93
gx_main_midi::MidiControllerTable::destroy_cb
static void destroy_cb(GtkWidget *, gpointer data)
ToggleAction
Definition: gx_main_window.h:59
gx_main_midi::MidiControllerTable
Definition: gx_main_midi.h:50
gx_main_midi::MidiConnect::check_midi_cb
static gboolean check_midi_cb(gpointer)
gx_main_midi::MidiControllerTable::edited_cb
static void edited_cb(GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer data)
gx_main_midi::MidiControllerTable::~MidiControllerTable
~MidiControllerTable()
gx_main_midi::MidiConnect::label_desc
GtkWidget * label_desc
Definition: gx_main_midi.h:98
gx_main_midi::MidiControllerTable::RESPONSE_DELETE_SELECTED
@ RESPONSE_DELETE_SELECTED
Definition: gx_main_midi.h:56
gx_main_midi::MidiConnect::entry_new
GtkWidget * entry_new
Definition: gx_main_midi.h:97
gx_main_midi::MidiControllerTable::selection
GtkTreeSelection * selection
Definition: gx_main_midi.h:57
gx_main_midi::MidiControllerTable::toggle
static void toggle(gx_engine::GxMachineBase &machine, Glib::RefPtr< ToggleAction > item)
gx_main_midi::MidiConnect::param
gx_engine::Parameter & param
Definition: gx_main_midi.h:89
gx_main_midi::MidiConnect::machine
gx_engine::GxMachineBase & machine
Definition: gx_main_midi.h:90
gx_main_midi::MidiConnect::adj_lower
GtkAdjustment * adj_lower
Definition: gx_main_midi.h:92
gx_main_midi::MidiControllerTable::store
GtkListStore * store
Definition: gx_main_midi.h:58
gx_engine::Parameter
Definition: gx_parameter.h:106
gx_main_midi::MidiControllerTable::toggleButtonSetSwitch
static void toggleButtonSetSwitch(GtkWidget *w, gpointer data)