Loading...
Searching...
No Matches
gx_main_midi.h
Go to the documentation of this file.
/*
* Copyright (C) 2009, 2010 Hermann Meyer, James Warden, Andreas Degert
* Copyright (C) 2011 Pete Shorthose
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* ---------------------------------------------------------------------------
*
* This file is part of the guitarix GUI main class
* Note: this header file depends on gx_parameter.h
* and make use of the gx_engine namespace
*
* ----------------------------------------------------------------------------
*/
#pragma once
#ifndef SRC_HEADERS_GX_MAIN_MIDI_H_
#define SRC_HEADERS_GX_MAIN_MIDI_H_
#ifndef SRC_HEADERS_GX_PARAMETER_H_
#include "./gx_parameter.h"
#endif
#include <glibmm.h>
#include <gtk/gtk.h>
#include <iomanip>
#include <cstring>
#include <string>
class ToggleAction; //FIXME
namespace gx_main_midi {
/****************************************************************
** MidiControllerTable
*/
class MidiControllerTable: public sigc::trackable {
private:
enum {RESPONSE_DELETE_SELECTED};
static GtkWidget *window; // there can only be 1 window
GtkToggleButton *togglebutton;
GtkTreeSelection *selection;
GtkListStore *store;
Glib::RefPtr<ToggleAction> menuaction;
gx_engine::GxMachineBase& machine;
sigc::connection midi_conn;
static void response_cb(GtkWidget *widget, gint response_id, gpointer data);
static void edited_cb(GtkCellRendererText *renderer, gchar *path,
gchar *new_text, gpointer data);
static void destroy_cb(GtkWidget*, gpointer data);
static void toggleButtonSetSwitch(GtkWidget *w, gpointer data);
void set(bool v);
void load();
explicit MidiControllerTable(gx_engine::GxMachineBase& machine, Glib::RefPtr<ToggleAction> item);
~MidiControllerTable();
public:
static void toggle(gx_engine::GxMachineBase& machine, Glib::RefPtr<ToggleAction> item);
};
/*****************************************************************
** Midi Control
*/
class MidiConnect {
private:
enum { RESPONSE_DELETE = 1 };
std::map<gx_engine::Parameter::toggle_type, const char*> toggle_behaviour_descriptions {
{ gx_engine::Parameter::toggle_type::OnOff, "off /on states transition toggle" },
{ gx_engine::Parameter::toggle_type::Constant, "constant state toggle" },
{ gx_engine::Parameter::toggle_type::Toggle, "toggle state" },
{ gx_engine::Parameter::toggle_type::Commander, "always toggle" }
};
GtkListStore* store;
gx_engine::Parameter &param;
gx_engine::GxMachineBase& machine;
int current_control;
GtkAdjustment* adj_lower;
GtkAdjustment* adj_upper;
GtkToggleButton *use_toggle;
//
GtkWidget* dialog;
GtkWidget* entry_new;
GtkWidget* label_desc;
GtkWidget* toggle_behaviours;
static string ctr_desc(int ctr);
static const char *ctl_to_str(int n);
public:
MidiConnect(GdkEventButton *event, gx_engine::Parameter& param, gx_engine::GxMachineBase& machine);
static void midi_response_cb(GtkWidget *widget, gint response_id, gpointer data);
static void midi_destroy_cb(GtkWidget *widget, gpointer data);
static void toggle_behaviours_visibility(GtkWidget *widget, gpointer data);
static gboolean check_midi_cb(gpointer);
static void changed_text_handler(GtkEditable *entry, gpointer data);
};
} // end namespace
#endif // SRC_HEADERS_GX_MAIN_MIDI_H_
ToggleAction
Definition gx_main_window.h:59
gx_engine::GxMachineBase
Definition machine.h:59
gx_engine::Parameter
Definition gx_parameter.h:107
gx_engine::Parameter::Toggle
@ Toggle
Definition gx_parameter.h:110
gx_engine::Parameter::Commander
@ Commander
Definition gx_parameter.h:110
gx_engine::Parameter::OnOff
@ OnOff
Definition gx_parameter.h:110
gx_engine::Parameter::Constant
@ Constant
Definition gx_parameter.h:110
gx_main_midi::MidiConnect::RESPONSE_DELETE
@ RESPONSE_DELETE
Definition gx_main_midi.h:79
gx_main_midi::MidiConnect::adj_upper
GtkAdjustment * adj_upper
Definition gx_main_midi.h:91
gx_main_midi::MidiConnect::current_control
int current_control
Definition gx_main_midi.h:89
gx_main_midi::MidiConnect::toggle_behaviours_visibility
static void toggle_behaviours_visibility(GtkWidget *widget, gpointer data)
gx_main_midi::MidiConnect::label_desc
GtkWidget * label_desc
Definition gx_main_midi.h:96
gx_main_midi::MidiConnect::store
GtkListStore * store
Definition gx_main_midi.h:86
gx_main_midi::MidiConnect::dialog
GtkWidget * dialog
Definition gx_main_midi.h:94
gx_main_midi::MidiConnect::midi_response_cb
static void midi_response_cb(GtkWidget *widget, gint response_id, gpointer data)
gx_main_midi::MidiConnect::midi_destroy_cb
static void midi_destroy_cb(GtkWidget *widget, gpointer data)
gx_main_midi::MidiConnect::param
gx_engine::Parameter & param
Definition gx_main_midi.h:87
gx_main_midi::MidiConnect::MidiConnect
MidiConnect(GdkEventButton *event, gx_engine::Parameter &param, gx_engine::GxMachineBase &machine)
gx_main_midi::MidiConnect::ctl_to_str
static const char * ctl_to_str(int n)
gx_main_midi::MidiConnect::entry_new
GtkWidget * entry_new
Definition gx_main_midi.h:95
gx_main_midi::MidiConnect::toggle_behaviour_descriptions
std::map< gx_engine::Parameter::toggle_type, const char * > toggle_behaviour_descriptions
Definition gx_main_midi.h:80
gx_main_midi::MidiConnect::machine
gx_engine::GxMachineBase & machine
Definition gx_main_midi.h:88
gx_main_midi::MidiConnect::changed_text_handler
static void changed_text_handler(GtkEditable *entry, gpointer data)
gx_main_midi::MidiConnect::ctr_desc
static string ctr_desc(int ctr)
gx_main_midi::MidiConnect::check_midi_cb
static gboolean check_midi_cb(gpointer)
gx_main_midi::MidiConnect::adj_lower
GtkAdjustment * adj_lower
Definition gx_main_midi.h:90
gx_main_midi::MidiConnect::toggle_behaviours
GtkWidget * toggle_behaviours
Definition gx_main_midi.h:97
gx_main_midi::MidiConnect::use_toggle
GtkToggleButton * use_toggle
Definition gx_main_midi.h:92
gx_main_midi::MidiControllerTable::RESPONSE_DELETE_SELECTED
@ RESPONSE_DELETE_SELECTED
Definition gx_main_midi.h:52
gx_main_midi::MidiControllerTable::window
static GtkWidget * window
Definition gx_main_midi.h:53
gx_main_midi::MidiControllerTable::MidiControllerTable
MidiControllerTable(gx_engine::GxMachineBase &machine, Glib::RefPtr< ToggleAction > item)
gx_main_midi::MidiControllerTable::response_cb
static void response_cb(GtkWidget *widget, gint response_id, gpointer data)
gx_main_midi::MidiControllerTable::~MidiControllerTable
~MidiControllerTable()
gx_main_midi::MidiControllerTable::menuaction
Glib::RefPtr< ToggleAction > menuaction
Definition gx_main_midi.h:57
gx_main_midi::MidiControllerTable::set
void set(bool v)
gx_main_midi::MidiControllerTable::selection
GtkTreeSelection * selection
Definition gx_main_midi.h:55
gx_main_midi::MidiControllerTable::store
GtkListStore * store
Definition gx_main_midi.h:56
gx_main_midi::MidiControllerTable::machine
gx_engine::GxMachineBase & machine
Definition gx_main_midi.h:58
gx_main_midi::MidiControllerTable::edited_cb
static void edited_cb(GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer data)
gx_main_midi::MidiControllerTable::load
void load()
gx_main_midi::MidiControllerTable::toggle
static void toggle(gx_engine::GxMachineBase &machine, Glib::RefPtr< ToggleAction > item)
gx_main_midi::MidiControllerTable::destroy_cb
static void destroy_cb(GtkWidget *, gpointer data)
gx_main_midi::MidiControllerTable::toggleButtonSetSwitch
static void toggleButtonSetSwitch(GtkWidget *w, gpointer data)
gx_main_midi::MidiControllerTable::midi_conn
sigc::connection midi_conn
Definition gx_main_midi.h:59
gx_main_midi::MidiControllerTable::togglebutton
GtkToggleButton * togglebutton
Definition gx_main_midi.h:54
gx_parameter.h
gx_main_midi
Definition gx_main_midi.h:45