mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 00:55:48 +00:00
[SNDVOL32] Set the ranges, pagesize and ticks for the balance and volume trackbars and fix the conversion between trackbar position and volume value
This commit is contained in:
parent
25cacdedb7
commit
ad3bda1c8d
3 changed files with 103 additions and 63 deletions
|
@ -79,6 +79,7 @@ AddDialogControl(
|
||||||
LPWSTR ClassName, WindowName = NULL;
|
LPWSTR ClassName, WindowName = NULL;
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
DWORD wID;
|
DWORD wID;
|
||||||
|
INT nSteps, i;
|
||||||
|
|
||||||
/* initialize client rectangle */
|
/* initialize client rectangle */
|
||||||
rect.left = DialogItem->x;
|
rect.left = DialogItem->x;
|
||||||
|
@ -145,6 +146,11 @@ AddDialogControl(
|
||||||
wID = DialogItem->id * (DialogIdMultiplier + 1);
|
wID = DialogItem->id * (DialogIdMultiplier + 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Hack: Disable TBS_AUTOTICKS because it looks ugly */
|
||||||
|
if (!wcsicmp(ClassName, L"msctls_trackbar32"))
|
||||||
|
DialogItem->style &= ~TBS_AUTOTICKS;
|
||||||
|
|
||||||
/* now create the window */
|
/* now create the window */
|
||||||
hwnd = CreateWindowExW(DialogItem->dwExtendedStyle,
|
hwnd = CreateWindowExW(DialogItem->dwExtendedStyle,
|
||||||
ClassName,
|
ClassName,
|
||||||
|
@ -168,18 +174,46 @@ AddDialogControl(
|
||||||
/* check if this the track bar */
|
/* check if this the track bar */
|
||||||
if (!wcsicmp(ClassName, L"msctls_trackbar32"))
|
if (!wcsicmp(ClassName, L"msctls_trackbar32"))
|
||||||
{
|
{
|
||||||
/* set up range */
|
if (DialogItem->style & TBS_VERT)
|
||||||
SendMessage(hwnd, TBM_SETRANGE, (WPARAM) TRUE, (LPARAM) MAKELONG(0, 5));
|
{
|
||||||
|
/* Vertical trackbar: Volume */
|
||||||
|
|
||||||
/* set up page size */
|
/* set up range */
|
||||||
SendMessage(hwnd, TBM_SETPAGESIZE, 0, (LPARAM) 1);
|
SendMessage(hwnd, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(0, VOLUME_STEPS));
|
||||||
|
|
||||||
/* set available range */
|
/* set up page size */
|
||||||
//SendMessage(hwnd, TBM_SETSEL, (WPARAM) FALSE, (LPARAM) MAKELONG(0, 5));
|
SendMessage(hwnd, TBM_SETPAGESIZE, 0, (LPARAM)VOLUME_PAGE_SIZE);
|
||||||
|
|
||||||
/* set position */
|
/* set position */
|
||||||
SendMessage(hwnd, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) 0);
|
SendMessage(hwnd, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)0);
|
||||||
|
|
||||||
|
/* Calculate and set ticks */
|
||||||
|
nSteps = (VOLUME_STEPS / (VOLUME_TICKS + 1));
|
||||||
|
if (VOLUME_STEPS % (VOLUME_TICKS + 1) != 0)
|
||||||
|
nSteps++;
|
||||||
|
for (i = nSteps; i < VOLUME_STEPS; i += nSteps)
|
||||||
|
SendMessage(hwnd, TBM_SETTIC, 0, (LPARAM)i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Horizontal trackbar: Balance */
|
||||||
|
|
||||||
|
/* set up range */
|
||||||
|
SendMessage(hwnd, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(0, BALANCE_STEPS));
|
||||||
|
|
||||||
|
/* set up page size */
|
||||||
|
SendMessage(hwnd, TBM_SETPAGESIZE, 0, (LPARAM)BALANCE_PAGE_SIZE);
|
||||||
|
|
||||||
|
/* set position */
|
||||||
|
SendMessage(hwnd, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)BALANCE_STEPS / 2);
|
||||||
|
|
||||||
|
/* Calculate and set ticks */
|
||||||
|
nSteps = (BALANCE_STEPS / (BALANCE_TICKS + 1));
|
||||||
|
if (BALANCE_STEPS % (BALANCE_TICKS + 1) != 0)
|
||||||
|
nSteps++;
|
||||||
|
for (i = nSteps; i < BALANCE_STEPS; i += nSteps)
|
||||||
|
SendMessage(hwnd, TBM_SETTIC, 0, (LPARAM)i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!wcsicmp(ClassName, L"static") || !wcsicmp(ClassName, L"button"))
|
else if (!wcsicmp(ClassName, L"static") || !wcsicmp(ClassName, L"button"))
|
||||||
{
|
{
|
||||||
|
@ -419,64 +453,64 @@ EnumConnectionsCallback(
|
||||||
if (SndMixerQueryControls(Mixer, &ControlCount, Line, &Control) != FALSE)
|
if (SndMixerQueryControls(Mixer, &ControlCount, Line, &Control) != FALSE)
|
||||||
{
|
{
|
||||||
/* now go through all controls and update their states */
|
/* now go through all controls and update their states */
|
||||||
for(Index = 0; Index < ControlCount; Index++)
|
for(Index = 0; Index < Line->cControls; Index++)
|
||||||
{
|
{
|
||||||
if ((Control[Index].dwControlType & MIXERCONTROL_CT_CLASS_MASK) == MIXERCONTROL_CT_CLASS_SWITCH)
|
if ((Control[Index].dwControlType & MIXERCONTROL_CT_CLASS_MASK) == MIXERCONTROL_CT_CLASS_SWITCH)
|
||||||
{
|
{
|
||||||
MIXERCONTROLDETAILS_BOOLEAN Details;
|
MIXERCONTROLDETAILS_BOOLEAN Details;
|
||||||
|
|
||||||
/* get volume control details */
|
/* get volume control details */
|
||||||
if (SndMixerGetVolumeControlDetails(Mixer, Control[Index].dwControlID, sizeof(MIXERCONTROLDETAILS_BOOLEAN), (LPVOID)&Details) != -1)
|
if (SndMixerGetVolumeControlDetails(Mixer, Control[Index].dwControlID, sizeof(MIXERCONTROLDETAILS_BOOLEAN), (LPVOID)&Details) != -1)
|
||||||
{
|
{
|
||||||
/* update dialog control */
|
/* update dialog control */
|
||||||
wID = (PrefContext->Count + 1) * IDC_LINE_SWITCH;
|
wID = (PrefContext->Count + 1) * IDC_LINE_SWITCH;
|
||||||
|
|
||||||
/* get dialog control */
|
/* get dialog control */
|
||||||
hDlgCtrl = GetDlgItem(PrefContext->MixerWindow->hWnd, wID);
|
hDlgCtrl = GetDlgItem(PrefContext->MixerWindow->hWnd, wID);
|
||||||
|
|
||||||
if (hDlgCtrl != NULL)
|
if (hDlgCtrl != NULL)
|
||||||
{
|
{
|
||||||
/* check state */
|
/* check state */
|
||||||
if (SendMessageW(hDlgCtrl, BM_GETCHECK, 0, 0) != Details.fValue)
|
if (SendMessageW(hDlgCtrl, BM_GETCHECK, 0, 0) != Details.fValue)
|
||||||
{
|
{
|
||||||
/* update control state */
|
/* update control state */
|
||||||
SendMessageW(hDlgCtrl, BM_SETCHECK, (WPARAM)Details.fValue, 0);
|
SendMessageW(hDlgCtrl, BM_SETCHECK, (WPARAM)Details.fValue, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((Control[Index].dwControlType & MIXERCONTROL_CT_CLASS_MASK) == MIXERCONTROL_CT_CLASS_FADER)
|
else if ((Control[Index].dwControlType & MIXERCONTROL_CT_CLASS_MASK) == MIXERCONTROL_CT_CLASS_FADER)
|
||||||
{
|
{
|
||||||
MIXERCONTROLDETAILS_UNSIGNED Details;
|
MIXERCONTROLDETAILS_UNSIGNED Details;
|
||||||
|
|
||||||
/* get volume control details */
|
/* get volume control details */
|
||||||
if (SndMixerGetVolumeControlDetails(Mixer, Control[Index].dwControlID, sizeof(MIXERCONTROLDETAILS_UNSIGNED), (LPVOID)&Details) != -1)
|
if (SndMixerGetVolumeControlDetails(Mixer, Control[Index].dwControlID, sizeof(MIXERCONTROLDETAILS_UNSIGNED), (LPVOID)&Details) != -1)
|
||||||
{
|
{
|
||||||
/* update dialog control */
|
/* update dialog control */
|
||||||
DWORD Position;
|
DWORD Position;
|
||||||
DWORD Step = 0x10000 / 5;
|
DWORD Step = 0x10000 / VOLUME_STEPS;
|
||||||
|
|
||||||
/* FIXME: give me granularity */
|
/* FIXME: give me granularity */
|
||||||
Position = 5 - (Details.dwValue / Step);
|
Position = VOLUME_STEPS - (Details.dwValue / Step);
|
||||||
|
|
||||||
/* FIXME support left - right slider */
|
/* FIXME support left - right slider */
|
||||||
wID = (PrefContext->Count + 1) * IDC_LINE_SLIDER_VERT;
|
wID = (PrefContext->Count + 1) * IDC_LINE_SLIDER_VERT;
|
||||||
|
|
||||||
/* get dialog control */
|
/* get dialog control */
|
||||||
hDlgCtrl = GetDlgItem(PrefContext->MixerWindow->hWnd, wID);
|
hDlgCtrl = GetDlgItem(PrefContext->MixerWindow->hWnd, wID);
|
||||||
|
|
||||||
if (hDlgCtrl != NULL)
|
if (hDlgCtrl != NULL)
|
||||||
{
|
{
|
||||||
/* check state */
|
/* check state */
|
||||||
LRESULT OldPosition = SendMessageW(hDlgCtrl, TBM_GETPOS, 0, 0);
|
LRESULT OldPosition = SendMessageW(hDlgCtrl, TBM_GETPOS, 0, 0);
|
||||||
if (OldPosition != Position)
|
if (OldPosition != Position)
|
||||||
{
|
{
|
||||||
/* update control state */
|
/* update control state */
|
||||||
SendMessageW(hDlgCtrl, TBM_SETPOS, (WPARAM)TRUE, Position + Index);
|
SendMessageW(hDlgCtrl, TBM_SETPOS, (WPARAM)TRUE, Position + Index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free controls */
|
/* free controls */
|
||||||
|
|
|
@ -651,14 +651,14 @@ SetVolumeCallback(PSND_MIXER Mixer, DWORD LineID, LPMIXERLINE Line, PVOID Ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now go through all controls and compare control ids */
|
/* now go through all controls and compare control ids */
|
||||||
for(Index = 0; Index < ControlCount; Index++)
|
for (Index = 0; Index < ControlCount; Index++)
|
||||||
{
|
{
|
||||||
if (Context->bVertical)
|
if (Context->bVertical)
|
||||||
{
|
{
|
||||||
if ((Control[Index].dwControlType & MIXERCONTROL_CT_CLASS_MASK) == MIXERCONTROL_CT_CLASS_FADER)
|
if ((Control[Index].dwControlType & MIXERCONTROL_CT_CLASS_MASK) == MIXERCONTROL_CT_CLASS_FADER)
|
||||||
{
|
{
|
||||||
/* FIXME: give me granularity */
|
/* FIXME: give me granularity */
|
||||||
DWORD Step = 0x10000 / 5;
|
DWORD Step = 0x10000 / VOLUME_STEPS;
|
||||||
|
|
||||||
/* set up details */
|
/* set up details */
|
||||||
uDetails.dwValue = 0x10000 - Step * Context->SliderPos;
|
uDetails.dwValue = 0x10000 - Step * Context->SliderPos;
|
||||||
|
@ -722,7 +722,7 @@ MixerControlChangeCallback(PSND_MIXER Mixer, DWORD LineID, LPMIXERLINE Line, PVO
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now go through all controls and compare control ids */
|
/* now go through all controls and compare control ids */
|
||||||
for(Index = 0; Index < ControlCount; Index++)
|
for (Index = 0; Index < ControlCount; Index++)
|
||||||
{
|
{
|
||||||
if (Control[Index].dwControlID == PtrToUlong(Context))
|
if (Control[Index].dwControlID == PtrToUlong(Context))
|
||||||
{
|
{
|
||||||
|
@ -746,10 +746,10 @@ MixerControlChangeCallback(PSND_MIXER Mixer, DWORD LineID, LPMIXERLINE Line, PVO
|
||||||
{
|
{
|
||||||
/* update dialog control */
|
/* update dialog control */
|
||||||
DWORD Position;
|
DWORD Position;
|
||||||
DWORD Step = 0x10000 / 5;
|
DWORD Step = 0x10000 / VOLUME_STEPS;
|
||||||
|
|
||||||
/* FIXME: give me granularity */
|
/* FIXME: give me granularity */
|
||||||
Position = 5 - (Details.dwValue / Step);
|
Position = VOLUME_STEPS - (Details.dwValue / Step);
|
||||||
|
|
||||||
/* update volume control slider */
|
/* update volume control slider */
|
||||||
UpdateDialogLineSliderControl(&Preferences, Line, Control[Index].dwControlID, IDC_LINE_SLIDER_VERT, Position);
|
UpdateDialogLineSliderControl(&Preferences, Line, Control[Index].dwControlID, IDC_LINE_SLIDER_VERT, Position);
|
||||||
|
@ -762,7 +762,6 @@ MixerControlChangeCallback(PSND_MIXER Mixer, DWORD LineID, LPMIXERLINE Line, PVO
|
||||||
/* free controls */
|
/* free controls */
|
||||||
HeapFree(GetProcessHeap(), 0, Control);
|
HeapFree(GetProcessHeap(), 0, Control);
|
||||||
|
|
||||||
|
|
||||||
/* done */
|
/* done */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,13 @@
|
||||||
|
|
||||||
#include "resources.h"
|
#include "resources.h"
|
||||||
|
|
||||||
|
#define VOLUME_STEPS 500
|
||||||
|
#define VOLUME_TICKS 5
|
||||||
|
#define VOLUME_PAGE_SIZE 100
|
||||||
|
#define BALANCE_STEPS 64
|
||||||
|
#define BALANCE_TICKS 1
|
||||||
|
#define BALANCE_PAGE_SIZE 12
|
||||||
|
|
||||||
typedef enum _WINDOW_MODE
|
typedef enum _WINDOW_MODE
|
||||||
{
|
{
|
||||||
NORMAL_MODE,
|
NORMAL_MODE,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue