From 76ac60f9f3ec4be96dae23fe20d4c17aa1a34e2d Mon Sep 17 00:00:00 2001 From: kpl Date: Fri, 16 Nov 2012 01:21:34 -0800 Subject: [PATCH] Initial time line control added --- .gitignore | 3 + Makefile.am | 29 +++-- src/kc/Fl_Splitter.cpp | 265 ----------------------------------------- src/kc/Fl_Splitter.h | 74 ------------ src/kc/kcApp.cpp | 99 ++++++++++----- src/kc/kcApp.h | 20 ++-- 6 files changed, 107 insertions(+), 383 deletions(-) delete mode 100644 src/kc/Fl_Splitter.cpp delete mode 100644 src/kc/Fl_Splitter.h diff --git a/.gitignore b/.gitignore index af37e38..79c254d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ # directories to ignore libcm +libgm +libkplfltk +tlCtl .deps autom4te.cache diff --git a/Makefile.am b/Makefile.am index e9fc954..60f7df3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,12 +11,13 @@ include_HEADERS= -AM_CPPFLAGS = -D _GNU_SOURCE -I.. -I$(srcdir)/src/libcm -I$(srcdir)/src/libcm/dsp -I$(srcdir)/src/libcm/vop -I$(srcdir)/src/libcm/app -AM_CFLAGS = -Wno-multichar -AM_CXXFLAGS = -AM_LDFLAGS = -MYLIBS = -lpthread -lfftw3f -lfftw3 -lfltk -CMLIBS = src/libcm/libcm.la # autoconfig manual recommends storing direct referenes to non-3rd party libraries rather than using -L and -l +AM_CPPFLAGS = -D _GNU_SOURCE -I.. -I$(srcdir)/src/libcm -I$(srcdir)/src/libcm/dsp -I$(srcdir)/src/libcm/vop -I$(srcdir)/src/libcm/app +AM_CPPFLAGS += -I$(srcdir)/src/libkplfltk -I$(srcdir)/src/libgm -I$(srcdir)/src/tlCtl +AM_CFLAGS = -Wno-multichar +AM_CXXFLAGS = +AM_LDFLAGS = +MYLIBS = -lpthread -lfftw3f -lfftw3 -lfltk -lcairo -lX11 +CMLIBS = src/libcm/libcm.la src/libgm/libgm.la src/libkplfltk/libkplfltk.la # autoconfig manual recommends storing direct referenes to non-3rd party libraries rather than using -L and -l # debug/release switches @@ -55,10 +56,22 @@ src_libcm_libcm_la_SOURCES = $(cmSRC) $(cmHDR) include_HEADERS += $(cmHDR) lib_LTLIBRARIES += src/libcm/libcm.la +include src/libkplfltk/Makefile.am +src_libkplfltk_libkplfltk_la_SOURCES = $(kplfltkSRC) $(kplfltkHDR) +include_HEADERS += $(kplfltkHDR) +lib_LTLIBRARIES += src/libkplfltk/libkplfltk.la -src_kc_kc_SOURCES = src/kc/kcMain.cpp +include src/libgm/Makefile.am +src_libgm_libgm_la_SOURCES = $(gmSRC) $(gmHDR) +include_HEADERS += $(gmHDR) +lib_LTLIBRARIES += src/libgm/libgm.la + +include src/tlCtl/Makefile.am +src_kc_kc_SOURCES = $(tlCtlSRC) + +src_kc_kc_SOURCES += src/kc/kcMain.cpp src_kc_kc_SOURCES += src/kc/kcApp.h src/kc/kcApp.cpp -src_kc_kc_SOURCES += src/kc/Fl_Splitter.h src/kc/Fl_Splitter.cpp +# src_kc_kc_SOURCES += src/kc/Fl_Splitter.h src/kc/Fl_Splitter.cpp src_kc_kc_SOURCES += src/kc/Fl_File_Btn.h src/kc/Fl_Vert_Progress.h src_kc_kc_SOURCES += src/kc/Fl_File_Btn.cpp src/kc/Fl_Vert_Progress.cpp diff --git a/src/kc/Fl_Splitter.cpp b/src/kc/Fl_Splitter.cpp deleted file mode 100644 index c8887d2..0000000 --- a/src/kc/Fl_Splitter.cpp +++ /dev/null @@ -1,265 +0,0 @@ -// Code based on: http://www.mail-archive.com/fltk@easysw.com/msg04573.html -// Lucas Sanner/Ian MacArthur -#include -#include "Fl_Splitter.h" - -void Fl_HSplitter::draw() -{ - Fl_Group::draw(); - fl_color(FL_BLACK); - fl_line_style( FL_DOT, 1); - - if(bSplit && Fl::event_button1() != 0) - { - fl_push_clip(x(), y(), w(), h()); - - yPos = Fl::event_y(); - - if(Fl::event_y() > h() - (border * 2)) - yPos = h() - (border * 2); - - if(Fl::event_y() < y() + (border * 2)) - yPos = y() + (border * 2); - - fl_line( x() + border, yPos - 1, x() + w() - (border*2), yPos - 1 ); - fl_line( x() + border, yPos , x() + w() - (border*2), yPos ); - fl_line( x() + border, yPos + 1, x() + w() - (border*2), yPos + 1 ); - - /* - fl_line( - x() + border, - yPos, - x() + w() - (border*2), - yPos ); - - fl_line( - x() + border, - yPos + 1, - x() + w() - (border*2), - yPos + 1 ); - */ - - fl_pop_clip(); - } - else - { - fl_push_clip(x(), y(), w(), h()); - fl_pop_clip(); - } -} - -int Fl_HSplitter::handle(int e) -{ - int ret = Fl_Group::handle(e); - - switch(e) - { - case FL_MOVE: - - if(Fl::event_y() > hCtnl - border && Fl::event_y() < hCtnl + border) - { - fl_cursor(FL_CURSOR_NS); - bSplit = true; - } - else - { - fl_cursor(FL_CURSOR_DEFAULT); - bSplit = false; - } - - return 1; - - case FL_PUSH: - - if(Fl::event_button() == FL_LEFT_MOUSE && bSplit) - { - redraw(); - } - - return 1; - - case FL_RELEASE: - - if(Fl::event_button() == FL_LEFT_MOUSE && bSplit) - { - container1->resize(x(), y(), w(), yPos - y()); - hCtnl = yPos; - container2->resize(x(),hCtnl, w(), h() - (yPos - y())); - - if( stretchTopFl ) - init_sizes(); - - bSplit = false; - redraw(); - } - - return 1; - - case FL_DRAG: - - if(bSplit && Fl::event_state(FL_BUTTON1) != 0) - redraw(); - - return 1; - } - - return(ret); -} - - -Fl_HSplitter::Fl_HSplitter(int x, int y, int w, int h, int h1, const char *l, bool stretchBotFl) - : Fl_Group(x, y, w, h, l) -{ - int h2 = h - h1; - - begin(); - container1 = new Splitter_Container(x, y, w, h1); - //container1->color((Fl_Color) FL_RED); - end(); - - begin(); - container2 = new Splitter_Container(x, y + h1, w, h2); - //container2->color((Fl_Color) FL_BLUE); - end(); - - hCtnl = y + h1; - bSplit = false; - stretchTopFl = !stretchBotFl; - - border = Fl::box_dy(FL_DOWN_BOX); - - if( stretchTopFl ) - resizable(container1); -} - -void Fl_HSplitter::resize_splitter(int x, int y, int w, int h) -{ - resize(x, y, w, h); - - if( stretchTopFl ) - { - hCtnl = container1->h() + y; - yPos = hCtnl; - } - else - { - container1->resize(x, y, w, hCtnl - y); - container2->resize(x, hCtnl, w, h - (hCtnl - y)); - } - -} - - - -void Fl_VSplitter::draw() -{ - Fl_Group::draw(); - fl_color(FL_BLACK); - fl_line_style( FL_DOT, 1); - - if(bSplit && Fl::event_button1() != 0) - { - fl_push_clip(x(), y(), w(), h()); - - xPos = Fl::event_x(); - - if(Fl::event_x() > w() - (border * 2)) - xPos = w() - (border * 2); - - if(Fl::event_x() < x() + (border * 2)) - xPos = x() + (border * 2); - - fl_line(xPos - 1, y() + border, xPos - 1, y() + h() - (border * 2)); - fl_line(xPos, y() + border, xPos, y() + h() - (border * 2)); - fl_line(xPos + 1, y() + border, xPos + 1, y() + h() - (border * 2)); - - fl_pop_clip(); - } - else - { - fl_push_clip(x(), y(), w(), h()); - fl_pop_clip(); - } -} - -int Fl_VSplitter::handle(int e) -{ - int ret = Fl_Group::handle(e); - - switch(e) - { - case FL_MOVE: - - if(Fl::event_x() > wCtn1 - border && Fl::event_x() < wCtn1 + border) - { - fl_cursor(FL_CURSOR_WE); - bSplit = true; - } - else - { - fl_cursor(FL_CURSOR_DEFAULT); - bSplit = false; - } - - return 1; - - case FL_PUSH: - - if(Fl::event_button() == FL_LEFT_MOUSE && bSplit) - { - redraw(); - } - - return 1; - - case FL_RELEASE: - - if(Fl::event_button() == FL_LEFT_MOUSE && bSplit) - { - container1->resize(x(), y(), xPos, h()); - wCtn1 = xPos; - container2->resize(wCtn1, y(), w() - wCtn1, h()); - bSplit = false; - redraw(); - } - - return 1; - - case FL_DRAG: - - if(bSplit && Fl::event_state(FL_BUTTON1) != 0) - redraw(); - - return 1; - } - - return(ret); -} - -Fl_VSplitter::Fl_VSplitter(int x, int y, int w, int h, const char *l) - : Fl_Group(x, y, w, h, l) -{ - begin(); - container1 = new Splitter_Container(x, y, w / 2, h); - //container1->color((Fl_Color) FL_RED); - end(); - - begin(); - container2 = new Splitter_Container(x + (w / 2), y, w / 2, h); - //container2->color((Fl_Color) FL_BLUE); - end(); - - wCtn1 = w / 2; - bSplit = false; - - border = Fl::box_dx(FL_DOWN_BOX); - -} - -void Fl_VSplitter::resize_splitter(int x, int y, int w, int h) -{ - resize(x, y, w, h); - container1->resize(x, y, wCtn1, h); - container2->resize(wCtn1, y, w - wCtn1, h); -} - diff --git a/src/kc/Fl_Splitter.h b/src/kc/Fl_Splitter.h deleted file mode 100644 index 3fef293..0000000 --- a/src/kc/Fl_Splitter.h +++ /dev/null @@ -1,74 +0,0 @@ -// Code based on: http://www.mail-archive.com/fltk@easysw.com/msg04573.html -// Lucas Sanner/Ian MacArthur - -#ifndef Fl_Splitter_h -#define Fl_Splitter_h - -#include -#include -#include -#include - - -class Splitter_Container : public Fl_Group -{ - void draw() - { - fl_push_clip(x(), y(), w(), h()); - Fl_Group::draw(); - fl_pop_clip(); - } - - public: - - Splitter_Container(int x, int y, int w, int h, char *l = NULL) - : Fl_Group(x, y, w, h, l) - { - //box(FL_DOWN_BOX); - } -}; - -class Fl_HSplitter : public Fl_Group -{ - int hCtnl, border, yPos; - bool bSplit; - bool stretchTopFl; // set to make top container stretch when splitter is resized - int hh2; - - void draw(); - - int handle(int e); - - public: - - Splitter_Container *container1, *container2; - - Fl_HSplitter(int x, int y, int w, int h, int h1, const char *l=NULL, bool stretchBotFl=false); - - void resize_splitter(int x, int y, int w, int h); - -}; - - -class Fl_VSplitter : public Fl_Group -{ - - int wCtn1, border, xPos; - bool bSplit; - - void draw(); - int handle(int e); - - public: - - Splitter_Container *container1, *container2; - - Fl_VSplitter(int x, int y, int w, int h, const char *l = NULL); - - void resize_splitter(int x, int y, int w, int h); - - - -}; - -#endif diff --git a/src/kc/kcApp.cpp b/src/kc/kcApp.cpp index f08d95a..fafee45 100644 --- a/src/kc/kcApp.cpp +++ b/src/kc/kcApp.cpp @@ -42,14 +42,38 @@ #include "cmAudDspLocal.h" #include "kcApp.h" -#include "kcApp.h" +#include "cmAudioFile.h" +#include "cmAudioFileMgr.h" + +#include "cmMidi.h" +#include "cmMidiFile.h" +#include "cmTimeLine.h" +#include "cmScore.h" +#include "cmGr.h" +#include "cmGrDevCtx.h" +#include "cmGrPlot.h" +#include "cmGrPage.h" +#include "cmGrDevDrvFltk.h" +#include "cmGrDevDrvCairoFltk.h" +#include "cmGrWidgetFltk.h" + +#include "Fl_CbLinker.h" + +#include "cmGrPlotPageFltk.h" +#include "cmGrPlotCtlrFltk.h" +#include "gvHashFunc.h" +#include "cmGrTlCtlrFltk.h" +#include "cmGrScCtlrFltk.h" + +#include "cmdIf.h" +#include "tlCtl.h" #define TIMER_PERIOD (1.0/20.0) // 50ms kcApp::kcApp(int w, int h, const char *l, int argc, char *argv[]) : Fl_Double_Window(w, h, l), - menu(NULL),splt(NULL), + splt(NULL),_menu(NULL), _adlH(cmAdlNullHandle),_aiH(cmAiNullHandle), _statIdx(0),_pageList(NULL),_ctlList(NULL),_prH(cmPrNullHandle),_prefsFn(NULL), _stopTimerFl(false),_jsH(cmJsonNullHandle),_newPageFl(true),_incrColW(0),_colW(0),_horzBordFl(false),_horzBord(0), @@ -62,7 +86,8 @@ kcApp::kcApp(int w, int h, const char *l, int argc, char *argv[]) // the main window is divided between the menu bar on top // and a horizontal splitter on the bottom begin(); - splt = new Fl_HSplitter(0, 0, w, h-kStatusH, h-kStatusH-100); + _createMenu(w,kMenuH); + splt = new Fl_HSplitter(0, kMenuH, w, h-kStatusH-kMenuH, h-kStatusH-kMenuH-100); end(); // Create a text display object for console output and @@ -99,8 +124,7 @@ kcApp::kcApp(int w, int h, const char *l, int argc, char *argv[]) ctl_grp->begin(); Fl_Box* bx = new Fl_Box(FL_NO_BOX,ctl_grp->x()+ctl_grp->w(),ctl_grp->y()+ctl_grp->h(),1,1,NULL); ctl_grp->resizable(bx); - ctl_grp->end(); - tabs->end(); + ctl_grp->end(); tabs->end(); */ // Create an empty tab group and make it resizable @@ -243,7 +267,7 @@ kcApp::kcKmRC_t kcApp::audioDspFinalize() void kcApp::resize(int x, int y, int w, int h) { Fl_Double_Window::resize(x, y, w, h); - splt->resize_splitter(0, 0, w, h-kStatusH); + splt->resize(0, kMenuH, w, h-kStatusH); } @@ -303,7 +327,7 @@ void kcApp::_createSetupDlg( Fl_Group* grp ) grp->end(); } -/* + void kcApp::_createMenu(int w, int h) { Fl_Menu_Item items[] = @@ -319,12 +343,11 @@ void kcApp::_createMenu(int w, int h) { 0 } }; - menu = new Fl_Menu_Bar(0,0,w,h); - menu->copy(items); + _menu = new Fl_Menu_Bar(0,0,w,h); + _menu->copy(items); } -*/ - void kcApp::_createPage( const char* title ) +void kcApp::_createPage( const char* title ) { int tx,ty,th,tw; tabs->client_area(tx,ty,tw,th); @@ -564,7 +587,7 @@ void kcApp::_getNewCtlPosn( const cmDspUiHdr_t* m, int& x, int& y, int& w, int& } } -kcApp::ctl_t* kcApp::_createCtl( const cmDspUiHdr_t* m, unsigned typeId, int& x, int& y, int& w, int& h ) +kcApp::ctl_t* kcApp::_createCtl( const cmDspUiHdr_t* m, unsigned typeId, int& x, int& y, int& w, int& h, bool posnFl ) { ctl_t* cp = new ctl_t; @@ -574,7 +597,8 @@ kcApp::ctl_t* kcApp::_createCtl( const cmDspUiHdr_t* m, unsigned typeId, int& x, cp->typeId = typeId; cp->mstrFl = m->uiId == cmInvalidId; - _getNewCtlPosn(m,x,y,w,h); + if( posnFl ) + _getNewCtlPosn(m,x,y,w,h); return cp; } @@ -1187,17 +1211,19 @@ void kcApp::_setLabelValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* v void kcApp::_createTmln( const cmDspUiHdr_t* m ) { int x,y,w=0,h=0; - ctl_t* cp = _createCtl(m, kTmlnTypeId, x,y,w,h ); + ctl_t* cp = _createCtl(m, kTmlnTypeId, x,y,w,h, false ); - cp->u.tmln.text = new Fl_Input(x,y,w,h); + cp->u.tmln.tlctl = new tlCtl(&_ctx,NULL); - _insertNewCtl(cp, m, cp->u.tmln.text, cp->u.tmln.varIdArray, kTmlnVarCnt ); + _createPage("TimeLine"); + + cp->u.tmln.tlctl->initScoreCtlr(this, _pageList->grp, _menu ); } void kcApp::_setTmlnValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* vp ) { unsigned i=0; - Fl_Input* tp = cp->u.tmln.text; + //tlCtl* tp = cp->u.tmln.tlctl; for(i=0; iu.tmln.varIdArray[i] == instVarId ) @@ -1205,21 +1231,34 @@ void kcApp::_setTmlnValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* vp switch(i) { case kTmlnValArgIdx: - tp->value( cmDsvStrcz(vp)); + //tp->value( cmDsvStrcz(vp)); break; case kTmlnLblArgIdx: { const char* lbl = cmDsvStrcz(vp); - if( lbl == NULL ) - tp->label(NULL); - else - tp->copy_label( lbl ); + } + break; - tp->align(FL_ALIGN_RIGHT); - tp->resize( tp->x(), tp->y(), tp->w()/2, tp->h()); - tp->redraw(); - + case kTmlnFileArgIdx: + { + const char* fn; + if((fn = cmDsvStrcz(vp)) != NULL ) + { + cp->u.tmln.tlctl->openTlFile(fn); + //cp->u.tmln.tlctl->redraw(); + } + } + break; + + case kTmlnPathArgIdx: + { + const char* path; + if((path = cmDsvStrcz(vp)) != NULL ) + { + cp->u.tmln.tlctl->setAudioFilePath(path); + //cp->u.tmln.tlctl->redraw(); + } } break; @@ -1860,6 +1899,10 @@ void kcApp::_callback(void* data) return; } + ctl_t* cp = _ctlList; + for(; cp!=NULL; cp=cp->linkPtr) + if( cp->typeId == kTmlnTypeId ) + delete cp->u.tmln.tlctl; // When all windows are windows are closed then the app. // will close - so hiding the application window @@ -2076,8 +2119,8 @@ void kcApp::_ctl_cb(ctl_t* cp) break; case kTmlnTypeId: - instVarId = cp->u.text.varIdArray[ kTmlnValArgIdx ]; - cmDsvSetStrz(&value,(cmChar_t*)cp->u.tmln.text->value()); + //instVarId = cp->u.text.varIdArray[ kTmlnValArgIdx ]; + //cmDsvSetStrz(&value,(cmChar_t*)cp->u.tmln.text->value()); break; default: diff --git a/src/kc/kcApp.h b/src/kc/kcApp.h index e5f1b20..30c9b34 100644 --- a/src/kc/kcApp.h +++ b/src/kc/kcApp.h @@ -17,6 +17,7 @@ class Fl_Select_Browser; class Fl_Valuator; class Fl_Value_Input; class Fl_Progress; +class tlCtl; class kcApp : public Fl_Double_Window { @@ -64,7 +65,7 @@ private: kSsPhaseMax = 20 }; - Fl_Menu_Bar* menu; + //Fl_Menu_Bar* menu; Fl_HSplitter* splt; Fl_Box* ind[4]; Fl_Text_Buffer* buf; @@ -138,7 +139,9 @@ private: kTmlnValArgIdx = 0, kTmlnLblArgIdx = 1, - kTmlnVarCnt = 2 + kTmlnFileArgIdx= 2, + kTmlnPathArgIdx= 3, + kTmlnVarCnt = 4 }; @@ -223,7 +226,7 @@ private: typedef struct tmln_str { - Fl_Input* text; + tlCtl* tlctl; char* val; unsigned varIdArray[ kTmlnVarCnt ]; } tmln_t; @@ -278,6 +281,7 @@ private: cmCtx_t _ctx; + Fl_Menu_Bar* _menu; cmAdlH_t _adlH; cmAiH_t _aiH; unsigned _statIdx; @@ -288,9 +292,9 @@ private: const cmChar_t* _prefsFn; bool _stopTimerFl; cmJsonH_t _jsH; - bool _newPageFl; - unsigned _incrColW; - unsigned _colW; + bool _newPageFl; + unsigned _incrColW; + unsigned _colW; bool _horzBordFl; unsigned _horzBord; unsigned _closeCnt; @@ -303,7 +307,7 @@ private: void resize(int x, int y, int w, int h); void _createSetupDlg(Fl_Group* grp); - + void _createMenu( int w, int h ); void _createPage( const char* title ); unsigned _getCtlCount() const; @@ -311,7 +315,7 @@ private: void _clearSsArray(); void _getNewCtlPosn( const cmDspUiHdr_t* m, int& x, int& y, int& w, int& h ); ctl_t* _findCtl( unsigned instId, unsigned asSubIdx, unsigned mstrFl=false ); - ctl_t* _createCtl( const cmDspUiHdr_t* m, unsigned typeId, int& x, int& y, int& w, int& h ); + ctl_t* _createCtl( const cmDspUiHdr_t* m, unsigned typeId, int& x, int& y, int& w, int& h, bool posnFl=true ); void _insertNewCtl( ctl_t* cp, const cmDspUiHdr_t* m, Fl_Widget* wdgt, unsigned* varIdArray, unsigned varIdCnt ); void _createSlider( const cmDspUiHdr_t* m );