aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/api/skin/widgets/svolbar.cpp
blob: 5152224a9a0ca5c936e685b752c76057473f5556 (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
#include <precomp.h>
#include "svolbar.h"
#include <api/core/api_core.h>

const wchar_t volBarXuiStr[] = L"VolBar"; // This is the xml tag
char volBarXuiSvcName[] = "VolBar xui object"; // this is the name of the xuiservice


#define SVOLBAR_NOTIFY_MSG NUM_NOTIFY_MESSAGES+0x1000

SVolBar::SVolBar() {
	setDrawOnBorders(TRUE);
	setEnable(TRUE);
	locked = 0;
	setLimits(0,255);
}

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

int SVolBar::onInit() {
	SVOLBAR_PARENT::onInit();

	corecb_onVolumeChange(WASABI_API_MEDIACORE->core_getVolume(0));
	WASABI_API_MEDIACORE->core_addCallback(0, this);

	return 1;
}

int SVolBar::onSetPosition() {
	SVOLBAR_PARENT::onSetPosition();
	int pos = getSliderPosition();	// get slider pos
	WASABI_API_MEDIACORE->core_setVolume(0,pos);
	return 1;
}

int SVolBar::corecb_onVolumeChange(int newvol) {
	if (getSeekStatus()) return 0;
	setPosition(newvol, 0);
	onPostedPosition(newvol);
	return 0;
}

void SVolBar::lock() {
	if (locked) return;
	locked = 1;
	WASABI_API_MEDIACORE->core_delCallback(0, this);
}

void SVolBar::unlock() {
	if (!locked) return;
	locked = 0;
	WASABI_API_MEDIACORE->core_addCallback(0, this);
}