[PD-cvs] externals/grill/vst/src Editor.h,1.2,1.3 EditorWin.cpp,1.3,1.4 VstHost.cpp,1.12,1.13 VstHost.h,1.8,1.9 main.cpp,1.17,1.18

Thomas Grill xovo at users.sourceforge.net
Wed Aug 25 04:42:08 CEST 2004


Update of /cvsroot/pure-data/externals/grill/vst/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26798/src

Modified Files:
	Editor.h EditorWin.cpp VstHost.cpp VstHost.h main.cpp 
Log Message:
 ""

Index: main.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/main.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** main.cpp	24 Aug 2004 02:44:38 -0000	1.17
--- main.cpp	25 Aug 2004 02:42:06 -0000	1.18
***************
*** 20,24 ****
  
  
! #define VST_VERSION "0.1.0pre14"
  
  
--- 20,24 ----
  
  
! #define VST_VERSION "0.1.0pre15"
  
  
***************
*** 51,54 ****
--- 51,58 ----
      V ms_winx(I x) { if(plug) plug->SetX(x); }
      V ms_winy(I y) { if(plug) plug->SetY(y); }
+     V ms_wincaption(bool c) { if(plug) plug->SetCaption(c); }
+     V mg_wincaption(bool &c) const { c = plug && plug->GetCaption(); }
+     V ms_wintitle(const t_symbol *t) { if(plug) plug->SetTitle(GetString(t)); }
+     V mg_wintitle(const t_symbol *&t) const { t = plug?MakeSymbol(plug->GetTitle()):sym__; }
  
      V mg_chnsin(I &c) const { c = plug?plug->GetNumInputs():0; }
***************
*** 144,147 ****
--- 148,153 ----
      FLEXT_CALLVAR_I(mg_winx,ms_winx)
      FLEXT_CALLVAR_I(mg_winy,ms_winy)
+     FLEXT_CALLVAR_B(mg_wincaption,ms_wincaption)
+     FLEXT_CALLVAR_S(mg_wintitle,ms_wintitle)
  
      FLEXT_CALLGET_I(mg_chnsin)
***************
*** 202,205 ****
--- 208,213 ----
      FLEXT_CADDATTR_VAR(c,"x",mg_winx,ms_winx);
  	FLEXT_CADDATTR_VAR(c,"y",mg_winy,ms_winy);
+ 	FLEXT_CADDATTR_VAR(c,"caption",mg_wincaption,ms_wincaption);
+ 	FLEXT_CADDATTR_VAR(c,"title",mg_wintitle,ms_wintitle);
  
      FLEXT_CADDATTR_GET(c,"ins",mg_chnsin);
***************
*** 247,252 ****
  {
      if(plug) {
!         ms_edit(false);
!         ClearBuf();
          delete plug; plug = NULL;
      }
--- 255,260 ----
  {
      if(plug) {
!         plug->Edit(false);
!         ClearBuf(); // needs valid plug
          delete plug; plug = NULL;
      }

Index: Editor.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/Editor.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Editor.h	27 Jan 2004 03:41:26 -0000	1.2
--- Editor.h	25 Aug 2004 02:42:06 -0000	1.3
***************
*** 19,22 ****
--- 19,24 ----
  void MoveEditor(VSTPlugin *p,int x,int y);
  void SizeEditor(VSTPlugin *p,int x,int y);
+ void TitleEditor(VSTPlugin *p,const char *t); 
+ void CaptionEditor(VSTPlugin *p,bool c); 
  bool IsEditorShown(const VSTPlugin *p);
  

Index: VstHost.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/VstHost.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** VstHost.cpp	23 Aug 2004 02:42:16 -0000	1.12
--- VstHost.cpp	25 Aug 2004 02:42:06 -0000	1.13
***************
*** 14,19 ****
  #include <ctype.h>
  
- static VstTimeInfo _timeInfo;
- 
  typedef AEffect *(VSTCALLBACK *PVSTMAIN)(audioMasterCallback audioMaster);
  
--- 14,17 ----
***************
*** 21,25 ****
  VSTPlugin::VSTPlugin():
      h_dll(NULL),hwnd(NULL),_pEffect(NULL),
!     posx(0),posy(0),
  	_midichannel(0),queue_size(0),
      paramnamecnt(0)
--- 19,23 ----
  VSTPlugin::VSTPlugin():
      h_dll(NULL),hwnd(NULL),_pEffect(NULL),
!     posx(0),posy(0),caption(true),
  	_midichannel(0),queue_size(0),
      paramnamecnt(0)
***************
*** 33,37 ****
  int VSTPlugin::Instance(const char *dllname)
  {
! 	h_dll = LoadLibrary(dllname);
  	if(!h_dll)
  		return VSTINSTANCE_ERR_NO_VALID_FILE;
--- 31,39 ----
  int VSTPlugin::Instance(const char *dllname)
  {
! #ifdef FLEXT_DEBUG
!         flext::post("New Plugin 1 - %x",this);
! #endif
! 
!     h_dll = LoadLibrary(dllname);
  	if(!h_dll)
  		return VSTINSTANCE_ERR_NO_VALID_FILE;
***************
*** 89,92 ****
--- 91,102 ----
  	}
  	
+     if(*_sProductName) {
+         char tmp[256];
+         sprintf(tmp,"vst~ - %s",_sProductName);
+         title = tmp;
+     }
+     else
+         title = "vst~";
+ 
  	*_sVendorName = 0;
  	Dispatch( effGetVendorString, 0, 0, &_sVendorName, 0.0f);
***************
*** 94,97 ****
--- 104,111 ----
  	_sDllName = dllname;
  
+ #ifdef FLEXT_DEBUG
+         flext::post("New Plugin 2 - %x",this);
+ #endif
+ 
  	return VSTINSTANCE_NO_ERROR;
  }
***************
*** 132,138 ****
  		Dispatch(effClose);
  
  		_pEffect = NULL;
          if(h_dll) { FreeLibrary(h_dll); h_dll = NULL; }
! 	}
  }
  
--- 146,168 ----
  		Dispatch(effClose);
  
+ #ifdef FLEXT_DEBUG
+         flext::post("Free Plugin 1 - %x",this);
+ #endif
+ 
  		_pEffect = NULL;
+ 
+         // \TODO
+         // Here, we really have to wait until the editor thread has terminated
+         // otherwise WM_DESTROY etc. messages may still be pending
+         // in other words: this is a design flaw
+         // There should be a data stub accessible from the plugin object and the thread
+         // holding the necessary data, so that both can operate independently
+ 
          if(h_dll) { FreeLibrary(h_dll); h_dll = NULL; }
! 
! #ifdef FLEXT_DEBUG
!         flext::post("Free Plugin 2 - %x",this);
! #endif
!     }
  }
  
***************
*** 247,252 ****
  void VSTPlugin::StopEditing() 
  { 
! 	Dispatch(effEditClose);					
!     hwnd = NULL; 
  }
  
--- 277,284 ----
  void VSTPlugin::StopEditing() 
  { 
!     if(Is()) {
! 	    Dispatch(effEditClose);					
!         hwnd = NULL; 
!     }
  }
  
***************
*** 360,369 ****
  }
  
  
  
  void VSTPlugin::processReplacing( float **inputs, float **outputs, long sampleframes )
  {
  	_pEffect->processReplacing( _pEffect , inputs , outputs , sampleframes );
- 
  }
  
--- 392,414 ----
  }
  
+ void VSTPlugin::SetCaption(bool c) 
+ {
+     if(Is()) {
+         caption = c; 
+         if(IsEdited()) CaptionEditor(this,c);
+     }
+ }
  
+ void VSTPlugin::SetTitle(const char *t)
+ {
+     if(Is()) {
+         title = t; 
+         if(IsEdited()) TitleEditor(this,t);
+     }
+ }
  
  void VSTPlugin::processReplacing( float **inputs, float **outputs, long sampleframes )
  {
  	_pEffect->processReplacing( _pEffect , inputs , outputs , sampleframes );
  }
  

Index: VstHost.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/VstHost.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** VstHost.h	23 Aug 2004 02:42:16 -0000	1.8
--- VstHost.h	25 Aug 2004 02:42:06 -0000	1.9
***************
*** 131,134 ****
--- 131,138 ----
      int GetX() const { return posx; }
      int GetY() const { return posy; }
+     void SetCaption(bool b);
+     bool GetCaption() const { return caption; }
+     void SetTitle(const char *t);
+     const char *GetTitle() const { return title.c_str(); }
  
  protected:
***************
*** 176,180 ****
  	char _midichannel;
  
!     int posx,posy;
  };
  
--- 180,186 ----
  	char _midichannel;
  
!     int posx,posy; // Window position
!     bool caption; // Window border
!     std::string title; // Window title
  };
  

Index: EditorWin.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/EditorWin.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** EditorWin.cpp	24 Feb 2004 03:37:12 -0000	1.3
--- EditorWin.cpp	25 Aug 2004 02:42:06 -0000	1.4
***************
*** 36,42 ****
      LRESULT res = 0;
  
- //    post("Message %x",msg);
      switch(msg) {
- //        case WM_NCREATE: res = TRUE; break;
          case WM_CREATE: 
              // Initialize the window. 
--- 36,40 ----
***************
*** 44,51 ****
              break; 
          case WM_CLOSE:
! 	        plug->StopEditing();
              DestroyWindow(hwnd);
              break; 
          case WM_DESTROY: 
              PostQuitMessage(0); 
              break; 
--- 42,57 ----
              break; 
          case WM_CLOSE:
! #ifdef FLEXT_DEBUG
!             flext::post("WM_CLOSE");
! #endif
!             // plug could already have been unloaded...
!             plug->StopEditing(); // this sets plug->hwnd = NULL
              DestroyWindow(hwnd);
              break; 
          case WM_DESTROY: 
+ #ifdef FLEXT_DEBUG
+             flext::post("WM_DESTROY");
+ #endif
+             // stop editor thread
              PostQuitMessage(0); 
              break; 
***************
*** 57,62 ****
              break; 
          case WM_MOVE: {
!             WORD x = LOWORD(lp),y = HIWORD(lp);
!             plug->SetPos(reinterpret_cast<short &>(x),reinterpret_cast<short &>(y),false);
              break; 
          }
--- 63,76 ----
              break; 
          case WM_MOVE: {
!             // ignore after WM_CLOSE so that x,y positions are preserved
!             if(!plug->IsEdited()) break;
! 
!             WORD wx = LOWORD(lp),wy = HIWORD(lp);
!             short x = reinterpret_cast<short &>(wx),y = reinterpret_cast<short &>(wy);
!             // x and y are the coordinates of the client rect (= actual VST interface)
!             plug->SetPos(x,y,false);
! #ifdef FLEXT_DEBUG
!             flext::post("WM_MOVE x/y=%i/%i",x,y);
! #endif
              break; 
          }
***************
*** 70,78 ****
          }
  */
! /*
!         case WM_SIZE: 
!             // Set the size and position of the window. 
              break; 
! */
          default: 
              res = DefWindowProc(hwnd,msg,wp,lp); 
--- 84,97 ----
          }
  */
! #if 0 //def FLEXT_DEBUG
!         case WM_SIZE: {
!             WORD wx = LOWORD(lp),wy = HIWORD(lp);
!             short x = reinterpret_cast<short &>(wx),y = reinterpret_cast<short &>(wy);
!             // x and y are the coordinates of the client rect (= actual VST interface)
!             flext::post("WM_SIZE x/y=%i/%i",x,y);
              break; 
!         }
! #endif
! 
          default: 
              res = DefWindowProc(hwnd,msg,wp,lp); 
***************
*** 81,84 ****
--- 100,121 ----
  }
  
+ static void windowsize(HWND wnd,int x,int y,int w,int h,bool caption,LONG flags = 0)
+ {
+ 	WINDOWINFO winfo;
+ 	winfo.cbSize = sizeof(winfo);
+ 	GetWindowInfo(wnd,&winfo);
+ 
+     int cy = caption?GetSystemMetrics(SM_CYCAPTION):0;
+ 
+ 	SetWindowPos(wnd,HWND_TOP,
+     	x-(winfo.rcClient.left-winfo.rcWindow.left),
+         y-(winfo.rcClient.top-winfo.rcWindow.top),
+ 		w+winfo.cxWindowBorders*2,
+ 		h+cy+winfo.cyWindowBorders*2, 
+         flags
+ 	);
+ 
+ }
+ 
  static void threadfun(flext::thr_params *p)
  {
***************
*** 99,103 ****
      HWND wnd = CreateWindow( 
          WCLNAME,tmp,
!         WS_BORDER|WS_CAPTION|/*WS_THICKFRAME|*/WS_POPUP|WS_SYSMENU|WS_MINIMIZEBOX,
          CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
          NULL,NULL,
--- 136,140 ----
      HWND wnd = CreateWindow( 
          WCLNAME,tmp,
!         (plug->GetCaption()?WS_BORDER|WS_CAPTION:0)|WS_POPUP|WS_SYSMENU|WS_MINIMIZEBOX,
          CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
          NULL,NULL,
***************
*** 122,143 ****
  	    SetTimer(wnd,0,TIMER_INTERVAL,NULL);
  
- 		WINDOWINFO winfo;
- 		winfo.cbSize = sizeof(winfo);
- 		GetWindowInfo(wnd,&winfo);
- 		TITLEBARINFO tinfo;
- 		tinfo.cbSize = sizeof(tinfo);
- 		GetTitleBarInfo(wnd,&tinfo);
- 
  	    ERect r;
          plug->GetEditorRect(r);
! 	    SetWindowPos(wnd,HWND_TOP,
! 			r.left,
! 			r.top,
! 			(r.right-r.left)+winfo.cxWindowBorders*2,
! 			(r.bottom-r.top)+(tinfo.rcTitleBar.bottom-tinfo.rcTitleBar.top)+winfo.cyWindowBorders*2, 
! 			SWP_SHOWWINDOW
! 		);
  
-     
  	//	SetFocus();
  
--- 159,169 ----
  	    SetTimer(wnd,0,TIMER_INTERVAL,NULL);
  
  	    ERect r;
          plug->GetEditorRect(r);
!         windowsize(wnd,plug->GetX(),plug->GetY(),r.right-r.left,r.bottom-r.top,plug->GetCaption(),SWP_SHOWWINDOW);
! #ifdef FLEXT_DEBUG
!         flext::post("Editor rect left/top=%i/%i, right/bottom=%i/%i",r.left,r.top,r.right,r.bottom);
! #endif
  
  	//	SetFocus();
  
***************
*** 187,197 ****
--- 213,235 ----
  void StartEditor(VSTPlugin *p)
  {
+ #ifdef FLEXT_DEBUG
+     flext::post("Start editor 1");
+ #endif
      flext::LaunchThread(threadfun,reinterpret_cast<flext::thr_params *>(p));
+ #ifdef FLEXT_DEBUG
+     flext::post("Start editor 2");
+ #endif
  }
  
  void StopEditor(VSTPlugin *p) 
  {
+ #ifdef FLEXT_DEBUG
+     flext::post("Stop editor 1");
+ #endif
      PostMessage(p->EditorHandle(),WM_CLOSE,0,0); 
      flext::StopThread(threadfun,reinterpret_cast<flext::thr_params *>(p));
+ #ifdef FLEXT_DEBUG
+     flext::post("Stop editor 2");
+ #endif
  }
  
***************
*** 203,208 ****
  void MoveEditor(VSTPlugin *p,int x,int y) 
  {
!     // the client region must be taken into account
! //    SetWindowPos(p->EditorHandle(),NULL,x,y,0,0,SWP_NOSIZE|SWP_NOZORDER);
  }
  
--- 241,255 ----
  void MoveEditor(VSTPlugin *p,int x,int y) 
  {
!     HWND wnd = p->EditorHandle();
! 
! 	WINDOWINFO winfo;
! 	winfo.cbSize = sizeof(winfo);
! 	GetWindowInfo(wnd,&winfo);
! 
!     SetWindowPos(wnd,NULL,
! 		x-(winfo.rcClient.left-winfo.rcWindow.left),y-(winfo.rcClient.top-winfo.rcWindow.top),
!         0,0,
! 		SWP_NOSIZE|SWP_NOZORDER
! 	);
  }
  
***************
*** 212,215 ****
--- 259,281 ----
  }
  
+ void CaptionEditor(VSTPlugin *plug,bool c)
+ {
+     HWND wnd = plug->EditorHandle();
+     LONG ns,style = GetWindowLong(wnd,GWL_STYLE);
+     if(c) ns = style|WS_BORDER|WS_CAPTION;
+     else ns = style&~(WS_BORDER|WS_CAPTION);
+     if(ns != style) {
+         SetWindowLong(wnd,GWL_STYLE,ns);
+ 
+         ERect r; plug->GetEditorRect(r);
+         windowsize(wnd,plug->GetX(),plug->GetY(),r.right-r.left,r.bottom-r.top,c,SWP_FRAMECHANGED);
+     }
+ }
+ 
+ void TitleEditor(VSTPlugin *p,const char *t) 
+ {
+     SetWindowText(p->EditorHandle(),t);
+ }
+ 
  bool IsEditorShown(const VSTPlugin *p) 
  {





More information about the Pd-cvs mailing list