2008/06/19

Plugins



KnobMan has a interface to plug-in modules that expand the functionality.

Plugins should be placed in the 'Plugin' directory under the KnobMan.exe.

HorzVert

Horizontal/Vertical exchange for Sliders.

HorzVert will try convert horizontal slider <=> vertical slider
BY

May not work properly if you use...


But probably help you if need Horizontal/Vertical Sliders

Plugin I/F

The Plugins are windows executable that have ".exe" extension. The exe files placed in 'Plugins' directory will be listed to 'Plugins' menu.

Plugins can communicate with KnobMan using just only WM_SETTEXT and WM_GETTEXT messages. The target window handle is passed by commandline. Followings are a code fragment for getting target window handle.

int APIENTRY _tWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpCmdLine,int nCmdShow) {
	HWND hwndTarget=(HWND)atoi(lpCmdLine);

After get the window handle, the plugins can control KnobMan by special format WM_SETTEXT that set the text of "KnobManCtl:xxxx". For example,...

char *str="KnobManCtl:SetValue Layer1.OffsetX1=0.0";
SendMessage(hwndTarget,WM_SETTEXT,0,(LPARAM)str);
will set a value of Layer1 OffsetX1 to 0.0 Available params:
Prefs. instead of LayerX. for each layers: ex) Layer1.Primitive
// HorzVert.cpp : KnobMan Plugin
//
// Usage:
//   Place the .exe file to 'Plugins' directory
//   You can run plugin from 'Plugins' menu.
//
//    HorzVert will try convert horizontal slider <=> vertical slider
//     BY
//       OutputSizeX / OutputSizeY exchange
//       Primitive H-Lines/V-Lines change
//       Primitive Aspect change
//       OffsetX/Y exchange
//       RotCenterX/Y exchange
//		 MaskType Horizontal/Vertical change
//
//  May not work properly if you use...
//    * non-square image primitives
//    * triangle / line primitives
//    * angles / mask rotations effects
//  But probably help you if need Horizontal/Vertical Sliders

#include "stdafx.h"
#include <windows.h>
#include <stdio.h>


float GetValue(HWND hwnd,int iLayer,char *strKey) {
static char str[100];
if(iLayer)
sprintf(str,"KnobManCtl:GetValue Layer%d.%s",iLayer,strKey);
else
sprintf(str,"KnobManCtl:GetValue Prefs.%s",strKey);
SendMessage(hwnd,WM_SETTEXT,0,(LPARAM)str);
SendMessage(hwnd,WM_GETTEXT,100,(LPARAM)str);
return atof(str);
}
char *GetValueText(HWND hwnd,int iLayer,char *strKey) {
static char str[100];
if(iLayer)
sprintf(str,"KnobManCtl:GetValue Layer%d.%s",iLayer,strKey);
else
sprintf(str,"KnobManCtl:GetValue Prefs.%s",strKey);
SendMessage(hwnd,WM_SETTEXT,0,(LPARAM)str);
SendMessage(hwnd,WM_GETTEXT,100,(LPARAM)str);
return str;
}
void SetValue(HWND hwnd,int iLayer,char *strKey,float fVal) {
char str[100];
if(iLayer)
sprintf(str,"KnobManCtl:SetValue Layer%d.%s=%f",iLayer,strKey,fVal);
else
sprintf(str,"KnobManCtl:SetValue Prefs.%s=%f",strKey,fVal);
SendMessage(hwnd,WM_SETTEXT,0,(LPARAM)str);
}
void SetValue(HWND hwnd,int iLayer,char *strKey,char *strVal) {
char str[256];
if(iLayer)
sprintf(str,"KnobManCtl:SetValue Layer%d.%s=%s",iLayer,strKey,strVal);
else
sprintf(str,"KnobManCtl:SetValue Prefs.%s=%s",strKey,strVal);
SendMessage(hwnd,WM_SETTEXT,0,(LPARAM)str);
}
void ExitPlugin(HWND hwnd) {
SendMessage(hwnd,WM_SETTEXT,0,(LPARAM)"KnobManCtl:Exit");
}

int APIENTRY _tWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpCmdLine,int nCmdShow) {
int i,iMaxLayer;
float f,fX,fY;
char str[100];
char *p;
int r;
r=MessageBox(NULL,"HorzVert: Horizontal/Vertical exchange for Sliders.\n\n"
"HorzVert will try convert horizontal slider <=> vertical slider\n"
" BY\n"
" OutputSizeX / OutputSizeY exchange\n"
" Primitive H-Lines/V-Lines change\n"
" Primitive Aspect change\n"
" OffsetX/Y exchange\n"
" RotCenterX/Y exchange\n"
" MaskType Horizontal/Vertical change\n"
"\n"
"May not work properly if you use...\n"
" * non-square image primitives\n"
" * triangle / line primitives\n"
" * angles / mask rotations effects\n"
"But probably help you if need Horizontal/Vertical Sliders\n"
,"HorzVert",MB_OKCANCEL);
if(r==IDCANCEL)
return 0;
HWND hwndTarget=(HWND)atoi(lpCmdLine);
iMaxLayer=(int)GetValue(hwndTarget,0,"Layers");
fX=GetValue(hwndTarget,0,"OutputSizeX");
fY=GetValue(hwndTarget,0,"OutputSizeY");
SetValue(hwndTarget,0,"OutputSizeX",fY);
SetValue(hwndTarget,0,"OutputSizeY",fX);
for(i=1;i<=iMaxLayer;++i) {
p=GetValueText(hwndTarget,i,"Primitive");
if(strcmp(p,"H-Lines")==0)
SetValue(hwndTarget,i,"Primitive","V-Lines");
else if(strcmp(p,"V-Lines")==0)
SetValue(hwndTarget,i,"Primitive","H-Lines");
f=GetValue(hwndTarget,i,"Aspect");
SetValue(hwndTarget,i,"Aspect",-f);
fX=GetValue(hwndTarget,i,"OffsetX1");
fY=GetValue(hwndTarget,i,"OffsetY1");
SetValue(hwndTarget,i,"OffsetX1",fY);
SetValue(hwndTarget,i,"OffsetY1",fX);
fX=GetValue(hwndTarget,i,"OffsetX2");
fY=GetValue(hwndTarget,i,"OffsetY2");
SetValue(hwndTarget,i,"OffsetX2",fY);
SetValue(hwndTarget,i,"OffsetY2",fX);
fX=GetValue(hwndTarget,i,"OffsetXAnim");
fY=GetValue(hwndTarget,i,"OffsetYAnim");
SetValue(hwndTarget,i,"OffsetXAnim",fY);
SetValue(hwndTarget,i,"OffsetYAnim",fX);
fX=GetValue(hwndTarget,i,"RotCenterX");
fY=GetValue(hwndTarget,i,"RotCenterY");
SetValue(hwndTarget,i,"RotCenterX",fY);
SetValue(hwndTarget,i,"RotCenterY",fX);
p=GetValueText(hwndTarget,i,"MaskType");
if(strcmp(p,"Horizontal")==0)
SetValue(hwndTarget,i,"MaskType","Vertical");
else if(strcmp(p,"Vertical")==0)
SetValue(hwndTarget,i,"MaskType","Horizontal");
}
ExitPlugin(hwndTarget);
MessageBox(NULL,"Finished","HorzVert",MB_OK);
return 0;
}




Return


g200kg