mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-05 17:11:40 -05:00
-Working on binding map
This commit is contained in:
parent
cc47fe4a74
commit
0c5d9cbd0c
7 changed files with 206 additions and 32 deletions
118
src/avtk/bindings.cxx
Normal file
118
src/avtk/bindings.cxx
Normal file
|
@ -0,0 +1,118 @@
|
|||
|
||||
|
||||
#include "bindings.h"
|
||||
|
||||
namespace Avtk
|
||||
{
|
||||
|
||||
Bindings::Bindings( int _x, int _y, int _w, int _h, const char *_label ) :
|
||||
Fl_Button(_x, _y, _w, _h, _label)
|
||||
{
|
||||
x = _x;
|
||||
y = _y;
|
||||
w = _w;
|
||||
h = _h;
|
||||
|
||||
label = _label;
|
||||
|
||||
highlight = false;
|
||||
mouseOver = false;
|
||||
}
|
||||
|
||||
|
||||
void Bindings::draw()
|
||||
{
|
||||
if (damage() & FL_DAMAGE_ALL)
|
||||
{
|
||||
cairo_t *cr = Fl::cairo_cc();
|
||||
cairo_save( cr );
|
||||
|
||||
int drawY = 0;
|
||||
for( int i = 0; i < 10; i++) // draw each binding
|
||||
{
|
||||
cairo_rectangle( cr, x+2, y + drawY, 100, 25 );
|
||||
drawY += 28;
|
||||
}
|
||||
cairo_set_source_rgba(cr, 0 / 255.f, 0 / 255.f , 0 / 255.f, 0.4);
|
||||
cairo_fill(cr);
|
||||
|
||||
cairo_restore( cr );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Bindings::resize(int X, int Y, int W, int H)
|
||||
{
|
||||
Fl_Widget::resize(X,Y,W,H);
|
||||
x = X;
|
||||
y = Y;
|
||||
w = W;
|
||||
h = H;
|
||||
redraw();
|
||||
}
|
||||
|
||||
/*
|
||||
int Bindings::handle(int event)
|
||||
{
|
||||
switch(event)
|
||||
{
|
||||
case FL_PUSH:
|
||||
highlight = 0;
|
||||
redraw();
|
||||
return 1;
|
||||
case FL_DRAG:
|
||||
{
|
||||
if ( Fl::event_state(FL_BUTTON1) )
|
||||
{
|
||||
if ( mouseClicked == false ) // catch the "click" event
|
||||
{
|
||||
mouseClickedX = Fl::event_x();
|
||||
mouseClickedY = Fl::event_y();
|
||||
mouseClicked = true;
|
||||
}
|
||||
|
||||
float delta = (mouseClickedY - Fl::event_y() ) / float(h);
|
||||
// handle the x / y swap, and the inverting of direction (mouseX / Y relative)
|
||||
if ( orientationHorizontal )
|
||||
delta = ( Fl::event_x() - mouseClickedX ) / float(w);
|
||||
|
||||
float valY = value();
|
||||
valY += delta;
|
||||
|
||||
if ( valY > 1.0 ) valY = 1.0;
|
||||
if ( valY < 0.0 ) valY = 0.0;
|
||||
|
||||
set_value( valY );
|
||||
|
||||
mouseClickedX = Fl::event_x();
|
||||
mouseClickedY = Fl::event_y();
|
||||
redraw();
|
||||
do_callback();
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
case FL_ENTER:
|
||||
return 1;
|
||||
case FL_RELEASE:
|
||||
if (highlight) {
|
||||
highlight = 0;
|
||||
redraw();
|
||||
do_callback();
|
||||
}
|
||||
mouseClicked = false;
|
||||
return 1;
|
||||
case FL_SHORTCUT:
|
||||
if ( test_shortcut() )
|
||||
{
|
||||
do_callback();
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
default:
|
||||
return Fl_Widget::handle(event);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
} // namespace Avtk
|
28
src/avtk/bindings.h
Normal file
28
src/avtk/bindings.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
|
||||
#ifndef AVTK_BINDINGS_H
|
||||
#define AVTK_BINDINGS_H
|
||||
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Button.H>
|
||||
|
||||
namespace Avtk
|
||||
{
|
||||
|
||||
class Bindings : public Fl_Button
|
||||
{
|
||||
public:
|
||||
Bindings( int _x, int _y, int _w, int _h, const char *_label = 0 );
|
||||
|
||||
bool mouseOver;
|
||||
bool highlight;
|
||||
int x, y, w, h;
|
||||
const char* label;
|
||||
|
||||
void draw();
|
||||
//int handle(int event);
|
||||
void resize(int X, int Y, int W, int H);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // AVTK_BINDINGS_H
|
33
src/controller/binding.hxx
Normal file
33
src/controller/binding.hxx
Normal file
|
@ -0,0 +1,33 @@
|
|||
|
||||
|
||||
#ifndef LUPPP_BINDING_H
|
||||
#define LUPPP_BINDING_H
|
||||
|
||||
#include <map>
|
||||
|
||||
/// a LupppAction represents the Event type, as from Event.hxx
|
||||
typedef int LupppAction;
|
||||
|
||||
class Binding
|
||||
{
|
||||
public:
|
||||
Binding() : status(0), data(0), action(0), active(false),track(-2),scene(-1),send(-1){}
|
||||
|
||||
unsigned char status;
|
||||
unsigned char data;
|
||||
|
||||
/// the action this binding relates to: this is an integer based on the
|
||||
/// event.hxx enumeration of event types
|
||||
LupppAction action;
|
||||
|
||||
/// arguments to the event: track number, scene number etc
|
||||
int active;
|
||||
int track;
|
||||
int scene;
|
||||
int send;
|
||||
|
||||
/// maps from Gridlogic::State to MIDI output value from binding
|
||||
std::map<int,int> clipStateMap;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -5,37 +5,13 @@
|
|||
|
||||
#include "controller.hxx"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "../cjson/cJSON.h"
|
||||
#include "../observer/midi.hxx"
|
||||
|
||||
/// a LupppAction represents the Event type, as from Event.hxx
|
||||
typedef int LupppAction;
|
||||
|
||||
class Binding
|
||||
{
|
||||
public:
|
||||
Binding() : status(0), data(0), action(0), active(false),track(-2),scene(-1),send(-1){}
|
||||
|
||||
unsigned char status;
|
||||
unsigned char data;
|
||||
|
||||
/// the action this binding relates to: this is an integer based on the
|
||||
/// event.hxx enumeration of event types
|
||||
LupppAction action;
|
||||
|
||||
/// arguments to the event: track number, scene number etc
|
||||
int active;
|
||||
int track;
|
||||
int scene;
|
||||
int send;
|
||||
|
||||
/// maps from Gridlogic::State to MIDI output value from binding
|
||||
std::map<int,int> clipStateMap;
|
||||
};
|
||||
#include "binding.hxx"
|
||||
|
||||
/** GenericMIDI
|
||||
* This class is used to load a <controller>.cfg JSON file as a MIDI map.
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "eventhandler.hxx"
|
||||
|
||||
#include "controller/binding.hxx"
|
||||
|
||||
|
||||
static void writeBindEnable(Fl_Widget* w, void* data)
|
||||
|
@ -28,12 +29,17 @@ OptionsWindow::OptionsWindow()
|
|||
int x, y, w, h;
|
||||
tabs->client_area( x, y, w, h, 25 );
|
||||
|
||||
Fl_Group* bindings = new Fl_Group( x, y, w, h, "Binding");
|
||||
Fl_Group* bindingGroup = new Fl_Group( x, y, w, h, "Binding");
|
||||
{
|
||||
targetLabel = new Fl_Box(x + 110,y + 5, 200, 25,"");
|
||||
targetLabelStat = new Fl_Box(x + 100,y + 5, 75, 25,"Target: ");
|
||||
targetLabel = new Fl_Box(x + 140,y + 5, 200, 25,"");
|
||||
bindEnable = new Avtk::LightButton(x + 5, y + 5, 100, 25, "Bind Enable");
|
||||
|
||||
Fl_Scroll* s = new Fl_Scroll( x + 5, y + 35, 400, 250 );
|
||||
bindings = new Avtk::Bindings( x + 5, y + 35, 400, 450 );
|
||||
s->end();
|
||||
}
|
||||
bindings->end();
|
||||
bindingGroup->end();
|
||||
|
||||
Fl_Group* controllers = new Fl_Group( x, y, w, h, "Controllers");
|
||||
controllers->hide();
|
||||
|
@ -73,4 +79,8 @@ void OptionsWindow::setBindEnable(bool e)
|
|||
setTarget("");
|
||||
}
|
||||
|
||||
void OptionsWindow::addBinding( Binding* b)
|
||||
{
|
||||
//bindingTable->insert();
|
||||
}
|
||||
|
||||
|
|
|
@ -7,12 +7,16 @@
|
|||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Box.H>
|
||||
#include <FL/Fl_Tabs.H>
|
||||
#include <FL/Fl_Table.H>
|
||||
#include <FL/Fl_Group.H>
|
||||
#include <FL/Fl_Double_Window.H>
|
||||
|
||||
#include "avtk/bindings.h"
|
||||
#include "avtk/avtk_button.h"
|
||||
#include "avtk/avtk_light_button.h"
|
||||
|
||||
class Binding;
|
||||
|
||||
class OptionsWindow
|
||||
{
|
||||
public:
|
||||
|
@ -21,17 +25,22 @@ class OptionsWindow
|
|||
void show();
|
||||
void setTarget(const char* t);
|
||||
void setBindEnable(bool b);
|
||||
void addBinding( Binding* b );
|
||||
|
||||
private:
|
||||
Fl_Double_Window* window;
|
||||
Fl_Tabs* tabs;
|
||||
|
||||
// bindings
|
||||
Avtk::Bindings* bindings;
|
||||
char* target;
|
||||
|
||||
Fl_Box* targetLabel;
|
||||
|
||||
Avtk::Button* ctlrButton;
|
||||
Fl_Box* targetLabelStat;
|
||||
Avtk::LightButton* bindEnable;
|
||||
|
||||
// Controller
|
||||
Avtk::Button* ctlrButton;
|
||||
|
||||
};
|
||||
|
||||
#endif // LUPPP_OPTIONS_H
|
||||
|
|
|
@ -150,7 +150,7 @@ void TimeManager::process(Buffers* buffers)
|
|||
{
|
||||
beatInProcess = true;
|
||||
|
||||
LUPPP_NOTE("Beat %i, nframesToBeat %i", beat, nframesToBeat );
|
||||
//LUPPP_NOTE("Beat %i, nframesToBeat %i", beat, nframesToBeat );
|
||||
|
||||
// inform observers of new beat FIRST
|
||||
for(uint i = 0; i < observers.size(); i++)
|
||||
|
|
Loading…
Add table
Reference in a new issue