bsnes/phoenix/windows/widget/vertical-slider.cpp

47 lines
1.3 KiB
C++
Raw Normal View History

namespace phoenix {
Size pVerticalSlider::minimumSize() {
return {0, 25};
}
void pVerticalSlider::setLength(unsigned length) {
length += (length == 0);
SendMessage(hwnd, TBM_SETRANGE, (WPARAM)true, (LPARAM)MAKELONG(0, length - 1));
SendMessage(hwnd, TBM_SETPAGESIZE, 0, (LPARAM)(length >> 3));
verticalSlider.setPosition(0);
}
void pVerticalSlider::setPosition(unsigned position) {
SendMessage(hwnd, TBM_SETPOS, (WPARAM)true, (LPARAM)position);
}
void pVerticalSlider::constructor() {
hwnd = CreateWindow(
TRACKBAR_CLASS, L"", WS_CHILD | WS_TABSTOP | TBS_NOTICKS | TBS_BOTH | TBS_VERT,
0, 0, 0, 0, parentHwnd, (HMENU)id, GetModuleHandle(0), 0
);
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&verticalSlider);
Update to v080r08 release. byuu says, in a post between the v080r07 release and the v080r08 release: phoenix/Windows: The slider and scrollbar setParent calls setLength+setPosition, but setLength sets position = 0 (due to new length possibly invalidating previous position.) Cache position first to fix this, can now reparent widgets with proper slider/scroll positions. ListView had a workaround where the horizontal scrollbar was always appearing on single-column lists. The workaround was forcing the config settings list in bsnes to only select the text portions of each item in the list, instead of the entire lines. The workaround was needed because without setting a single header text, the header text count was equal to zero, causing autoSizeColumns to have no effect. Made the constructor call setHeaderText("") to guarantee size() >= 1 always. Removes the need for the workaround, and gives a good file browser and configuration setting window. phoenix/Qt: Worked around Qt bugs #258,674+258,675: if you click a list item with your mouse, currentItem()->isSelected() returns false. It does not return true until you select an item with a keyboard key. I forced it to set the selected item upon currentItemChanged() message. It was also not sending a changed message upon clearing the selection and then selecting the same item again. I had to do something undocumented: setCurrentItem(nullptr) so that currentItemChanged works again. phoenix/All: Fonts are now initialized to the platform default settings, Tahoma or Sans 8-point. This lets geometry on widgets not attached to windows work better. Makes the ../... buttons smaller pretty much everywhere. byuu says, announcing the v080r08 release: Fixed all of the above phoenix issues, and improved the auto-disabling of buttons on the input setting and state manager windows. Also manually initiailized lastConfigure for Valgrind in GTK+. Windows and GTK+ ports look a lot nicer now.
2011-08-08 12:04:47 +00:00
unsigned position = verticalSlider.state.position;
setLength(verticalSlider.state.length);
verticalSlider.setPosition(position);
synchronize();
}
void pVerticalSlider::destructor() {
DestroyWindow(hwnd);
}
void pVerticalSlider::orphan() {
destructor();
constructor();
}
void pVerticalSlider::onChange() {
unsigned position = SendMessage(hwnd, TBM_GETPOS, 0, 0);
if(position == verticalSlider.state.position) return;
verticalSlider.state.position = position;
if(verticalSlider.onChange) verticalSlider.onChange();
}
}