aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/api/skin/widgets/seqband.cpp
blob: 2d813fd21ff0bfd89256efb24b23c24652b7e6ec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include <precomp.h>
#include "seqband.h"
#include <api/core/api_core.h>

#define NOTIFYMSG_EQ_HELLO 0x3003

const wchar_t eqBandXuiStr[] = L"EqBand"; // This is the xml tag
char eqBandXuiSvcName[] = "EqBand xui object"; // this is the name of the xuiservice

XMLParamPair SEQBand::params[] = {
	{SEQBAND_SETPARAM, L"BAND"},
	{SEQBAND_SETPARAM, L"PARAM"},
};

SEQBand::SEQBand() {
	band = 0;
	setDrawOnBorders(TRUE);
	setEnable(TRUE);
	setHotPosition(0);
	isactive=0;
	discard_next_event = 0;
	xuihandle = newXuiHandle();
	CreateXMLParameters(xuihandle);

	setLimits(-127,127);
}

void SEQBand::CreateXMLParameters(int master_handle)
{
	//SEQBAND_PARENT::CreateXMLParameters(master_handle);
	int numParams = sizeof(params) / sizeof(params[0]);
	hintNumberOfParams(xuihandle, numParams);
	for (int i = 0;i < numParams;i++)
		addParam(xuihandle, params[i], XUI_ATTRIBUTE_IMPLIED);
}

SEQBand::~SEQBand() {
	WASABI_API_MEDIACORE->core_delCallback(0, this);
}

int SEQBand::setXuiParam(int _xuihandle, int attrid, const wchar_t *name, const wchar_t *strval) {
	if (_xuihandle != xuihandle) return SEQBAND_PARENT::setXuiParam(_xuihandle, attrid, name, strval);
	switch (attrid) {
		case SEQBAND_SETPARAM:
		case SEQBAND_SETBAND:
			setBand(WTOI(strval)-1);
			break;
		default:
			return 0;
	}
	return 1;
}

void SEQBand::setBand(int b) {
	band = b;
}

int SEQBand::onInit() {
	SEQBAND_PARENT::onInit();

	corecb_onEQBandChange(band, WASABI_API_MEDIACORE->core_getEqBand(0, band));
	WASABI_API_MEDIACORE->core_addCallback(0, this);

	return 1;
}

int SEQBand::onSetPosition() {
	setHotPosition((Std::keyDown(VK_SHIFT) ? -1 : 0));
	SEQBAND_PARENT::onSetPosition();
	int pos = getSliderPosition();	// get slider pos
	discard_next_event = 1;
	WASABI_API_MEDIACORE->core_setEqBand(0,band,pos);
	return 1;
}

int SEQBand::onResize() {
	SEQBAND_PARENT::onResize();
	invalidate();
	return 1;
}

int SEQBand::corecb_onEQBandChange(int b, int newval) {
	if(b!=band) return 0;
	if (discard_next_event) {
		discard_next_event = 0;
		return 0;
	}
	setPosition(newval,0);
	return 0;
}

int SEQBand::onLeftButtonDown(int x, int y) { 
	isactive=1; 
	return SEQBAND_PARENT::onLeftButtonDown(x,y); 
}

int SEQBand::onMouseMove(int x, int y) {
	if(isactive) {
		ifc_window *parent=getParent();
		if(parent) {
			ifc_window *wnd=parent->findRootWndChild(x,y);
			if(wnd && wnd!=this) {
				if(wnd->childNotify(this,NOTIFYMSG_EQ_HELLO,0,0)) { // will return 1 if it's another EQBand
					onLeftButtonUp(x,y);
					wnd->onLeftButtonDown(x,y);
				}
			}
		}
	}
	return SEQBAND_PARENT::onMouseMove(x,y);
}

int SEQBand::onLeftButtonUp(int x, int y) { 
	isactive=0; 
	return SEQBAND_PARENT::onLeftButtonUp(x,y); 
}

int SEQBand::childNotify(ifc_window *child, int msg, intptr_t param1, intptr_t param2) {
	if(msg==NOTIFYMSG_EQ_HELLO) return 1;
	return SEQBAND_PARENT::childNotify(child,msg,param1,param2);
}