mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-31 02:00:27 +02:00
Update to v094r27 release.
byuu says: Added AWJ's fixes for alt/cpu (Tetris Attack framelines issue) and alt/dsp (Thread::clock reset) Added fix so that the taskbar entry appears when the application first starts on Windows. Fixed checkbox toggling inside of list views on Windows. Updated nall/image to properly protect variables that should not be written externally. New Object syntax for hiro is in. Fixed the backwards-typing on Windows with the state manager. NOTE: the list view isn't redrawing when you change the description text. It does so on the cheat editor because of the resizeColumns call; but that shouldn't be necessary. I'll try and fix this for the next WIP.
This commit is contained in:
@@ -27,7 +27,7 @@ auto pMenuItem::_createBitmap() -> void {
|
||||
if(hbitmap) { DeleteObject(hbitmap); hbitmap = nullptr; }
|
||||
|
||||
if(auto icon = state().icon) {
|
||||
icon.transform(0, 32, 255u << 24, 255u << 16, 255u << 8, 255u << 0);
|
||||
icon.transform();
|
||||
icon.alphaBlend(GetSysColor(COLOR_MENU)); //Windows does not alpha blend menu icons properly (leaves black outline)
|
||||
icon.scale(GetSystemMetrics(SM_CXMENUCHECK), GetSystemMetrics(SM_CYMENUCHECK), Interpolation::Linear);
|
||||
hbitmap = CreateBitmap(icon);
|
||||
|
@@ -32,7 +32,7 @@ auto pMenu::_createBitmap() -> void {
|
||||
if(hbitmap) { DeleteObject(hbitmap); hbitmap = 0; }
|
||||
|
||||
if(auto icon = state().icon) {
|
||||
icon.transform(0, 32, 255u << 24, 255u << 16, 255u << 8, 255u << 0);
|
||||
icon.transform();
|
||||
icon.alphaBlend(GetSysColor(COLOR_MENU)); //Windows does not alpha blend menu icons properly (leaves black outline)
|
||||
icon.scale(GetSystemMetrics(SM_CXMENUCHECK), GetSystemMetrics(SM_CYMENUCHECK), Interpolation::Linear);
|
||||
hbitmap = CreateBitmap(icon);
|
||||
|
@@ -12,20 +12,20 @@ static auto OsVersion() -> unsigned {
|
||||
return (versionInfo.dwMajorVersion << 8) + (versionInfo.dwMajorVersion << 0);
|
||||
}
|
||||
|
||||
static auto CreateBitmap(const image& image) -> HBITMAP {
|
||||
static auto CreateBitmap(const image& icon) -> HBITMAP {
|
||||
HDC hdc = GetDC(0);
|
||||
BITMAPINFO bitmapInfo;
|
||||
memset(&bitmapInfo, 0, sizeof(BITMAPINFO));
|
||||
bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bitmapInfo.bmiHeader.biWidth = image.width;
|
||||
bitmapInfo.bmiHeader.biHeight = -image.height; //bitmaps are stored upside down unless we negate height
|
||||
bitmapInfo.bmiHeader.biWidth = icon.width();
|
||||
bitmapInfo.bmiHeader.biHeight = -(signed)icon.height(); //bitmaps are stored upside down unless we negate height
|
||||
bitmapInfo.bmiHeader.biPlanes = 1;
|
||||
bitmapInfo.bmiHeader.biBitCount = 32;
|
||||
bitmapInfo.bmiHeader.biCompression = BI_RGB;
|
||||
bitmapInfo.bmiHeader.biSizeImage = image.width * image.height * 4;
|
||||
bitmapInfo.bmiHeader.biSizeImage = icon.size();
|
||||
void* bits = nullptr;
|
||||
HBITMAP hbitmap = CreateDIBSection(hdc, &bitmapInfo, DIB_RGB_COLORS, &bits, NULL, 0);
|
||||
if(bits) memcpy(bits, image.data, image.width * image.height * 4);
|
||||
if(bits) memory::copy(bits, icon.data(), icon.size());
|
||||
ReleaseDC(0, hdc);
|
||||
return hbitmap;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ static auto ImageList_Append(HIMAGELIST imageList, const image& source, unsigned
|
||||
image.allocate(scale, scale);
|
||||
image.fill(GetSysColor(COLOR_WINDOW));
|
||||
}
|
||||
image.transform(0, 32, 255u << 24, 255u << 16, 255u << 8, 255u << 0);
|
||||
image.transform();
|
||||
image.scale(scale, scale);
|
||||
HBITMAP bitmap = CreateBitmap(image);
|
||||
ImageList_Add(imageList, bitmap, NULL);
|
||||
|
@@ -24,13 +24,13 @@ auto pButton::minimumSize() const -> Size {
|
||||
auto size = pFont::size(hfont, state().text);
|
||||
|
||||
if(state().orientation == Orientation::Horizontal) {
|
||||
size.setWidth(size.width() + state().icon.width);
|
||||
size.setHeight(max(size.height(), state().icon.height));
|
||||
size.setWidth(size.width() + state().icon.width());
|
||||
size.setHeight(max(size.height(), state().icon.height()));
|
||||
}
|
||||
|
||||
if(state().orientation == Orientation::Vertical) {
|
||||
size.setWidth(max(size.width(), state().icon.width));
|
||||
size.setHeight(size.height() + state().icon.height);
|
||||
size.setWidth(max(size.width(), state().icon.width()));
|
||||
size.setHeight(size.height() + state().icon.height());
|
||||
}
|
||||
|
||||
return {size.width() + (state().text ? 20 : 13), size.height() + 10};
|
||||
@@ -58,7 +58,7 @@ auto pButton::onActivate() -> void {
|
||||
//performs setIcon, setOrientation, setText
|
||||
auto pButton::_setState() -> void {
|
||||
image icon = state().icon;
|
||||
icon.transform(0, 32, 255u << 24, 255u << 16, 255u << 8, 255u << 0);
|
||||
icon.transform();
|
||||
|
||||
if(hbitmap) { DeleteObject(hbitmap); hbitmap = 0; }
|
||||
if(himagelist) { ImageList_Destroy(himagelist); himagelist = 0; }
|
||||
@@ -68,7 +68,7 @@ auto pButton::_setState() -> void {
|
||||
if(OsVersion() < WindowsVista) icon.alphaBlend(GetSysColor(COLOR_BTNFACE));
|
||||
|
||||
hbitmap = CreateBitmap(icon);
|
||||
himagelist = ImageList_Create(icon.width, icon.height, ILC_COLOR32, 1, 0);
|
||||
himagelist = ImageList_Create(icon.width(), icon.height(), ILC_COLOR32, 1, 0);
|
||||
ImageList_Add(himagelist, hbitmap, NULL);
|
||||
BUTTON_IMAGELIST list;
|
||||
list.himl = himagelist;
|
||||
|
@@ -162,14 +162,14 @@ auto pCanvas::_rasterize() -> void {
|
||||
state().gradient[0].value(), state().gradient[1].value(),
|
||||
state().gradient[2].value(), state().gradient[3].value()
|
||||
);
|
||||
memory::copy(pixels.data(), fill.data, fill.size);
|
||||
memory::copy(pixels.data(), fill.data(), fill.size());
|
||||
}
|
||||
|
||||
if(mode == Mode::Icon) {
|
||||
auto icon = state().icon;
|
||||
icon.scale(width, height);
|
||||
icon.transform(0, 32, 255u << 24, 255u << 16, 255u << 8, 255u << 0);
|
||||
memory::copy(pixels.data(), icon.data, icon.size);
|
||||
icon.transform();
|
||||
memory::copy(pixels.data(), icon.data(), icon.size());
|
||||
}
|
||||
|
||||
if(mode == Mode::Data) {
|
||||
|
@@ -23,13 +23,13 @@ auto pCheckButton::minimumSize() -> Size {
|
||||
auto size = pFont::size(hfont, state().text);
|
||||
|
||||
if(state().orientation == Orientation::Horizontal) {
|
||||
size.setWidth(size.width() + state().icon.width);
|
||||
size.setHeight(max(size.height(), state().icon.height));
|
||||
size.setWidth(size.width() + state().icon.width());
|
||||
size.setHeight(max(size.height(), state().icon.height()));
|
||||
}
|
||||
|
||||
if(state().orientation == Orientation::Vertical) {
|
||||
size.setWidth(max(size.width(), state().icon.width));
|
||||
size.setHeight(size.height() + state().icon.height);
|
||||
size.setWidth(max(size.width(), state().icon.width()));
|
||||
size.setHeight(size.height() + state().icon.height());
|
||||
}
|
||||
|
||||
return {size.width() + (state().text ? 20 : 10), size.height() + 10};
|
||||
@@ -62,16 +62,16 @@ auto pCheckButton::onToggle() -> void {
|
||||
|
||||
auto pCheckButton::_setState() -> void {
|
||||
image icon = state().icon;
|
||||
icon.transform(0, 32, 255u << 24, 255u << 16, 255u << 8, 255u << 0);
|
||||
icon.transform();
|
||||
|
||||
if(hbitmap) { DeleteObject(hbitmap); hbitmap = 0; }
|
||||
if(himagelist) { ImageList_Destroy(himagelist); himagelist = 0; }
|
||||
if(hbitmap) { DeleteObject(hbitmap); hbitmap = nullptr; }
|
||||
if(himagelist) { ImageList_Destroy(himagelist); himagelist = nullptr; }
|
||||
|
||||
if(OsVersion() < WindowsVista) icon.alphaBlend(GetSysColor(COLOR_BTNFACE));
|
||||
|
||||
hbitmap = CreateBitmap(icon);
|
||||
himagelist = ImageList_Create(icon.width, icon.height, ILC_COLOR32, 1, 0);
|
||||
ImageList_Add(himagelist, hbitmap, NULL);
|
||||
himagelist = ImageList_Create(icon.width(), icon.height(), ILC_COLOR32, 1, 0);
|
||||
ImageList_Add(himagelist, hbitmap, nullptr);
|
||||
BUTTON_IMAGELIST list;
|
||||
list.himl = himagelist;
|
||||
switch(state().orientation) {
|
||||
|
@@ -232,12 +232,17 @@ auto pListView::onChange(LPARAM lparam) -> void {
|
||||
PostMessageOnce(_parentHandle(), AppMessage::ListView_onChange, 0, (LPARAM)&reference);
|
||||
}
|
||||
|
||||
unsigned row = nmlistview->iItem;
|
||||
unsigned mask = ((nmlistview->uNewState & LVIS_STATEIMAGEMASK) >> 12) - 1;
|
||||
if((mask == 0 || mask == 1) && !locked()) {
|
||||
if(auto item = self().item(row)) {
|
||||
item->state.checked = !item->state.checked;
|
||||
self().doToggle(item);
|
||||
if(!locked()) {
|
||||
unsigned row = nmlistview->iItem;
|
||||
unsigned mask = nmlistview->uNewState & LVIS_STATEIMAGEMASK;
|
||||
if(mask == 0x1000 || mask == 0x2000) {
|
||||
bool checked = mask == 0x2000;
|
||||
if(auto item = self().item(row)) {
|
||||
if(checked != item->state.checked) { //WC_LISTVIEW sends this message twice
|
||||
item->state.checked = checked;
|
||||
self().doToggle(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -288,7 +293,7 @@ auto pListView::onCustomDraw(LPARAM lparam) -> LRESULT {
|
||||
if(!cell) continue;
|
||||
if(auto icon = cell->state.icon) {
|
||||
icon.scale(iconSize, iconSize);
|
||||
icon.transform(0, 32, 255u << 24, 255u << 16, 255u << 8, 255u << 0);
|
||||
icon.transform();
|
||||
auto bitmap = CreateBitmap(icon);
|
||||
SelectBitmap(hdcSource, bitmap);
|
||||
BLENDFUNCTION blend{AC_SRC_OVER, 0, (BYTE)(selected ? 128 : 255), AC_SRC_ALPHA};
|
||||
@@ -413,7 +418,7 @@ auto pListView::_setIcons() -> void {
|
||||
auto icon = state().columns(column)->state.icon;
|
||||
if(icon) {
|
||||
icon.scale(16, 16);
|
||||
icon.transform(0, 32, 255u << 24, 255u << 16, 255u << 8, 255u << 0);
|
||||
icon.transform();
|
||||
} else {
|
||||
icon.allocate(16, 16);
|
||||
icon.fill(0x00ffffff);
|
||||
|
@@ -23,13 +23,13 @@ auto pRadioButton::minimumSize() -> Size {
|
||||
auto size = pFont::size(hfont, state().text);
|
||||
|
||||
if(state().orientation == Orientation::Horizontal) {
|
||||
size.setWidth(size.width() + state().icon.width);
|
||||
size.setHeight(max(size.height(), state().icon.height));
|
||||
size.setWidth(size.width() + state().icon.width());
|
||||
size.setHeight(max(size.height(), state().icon.height()));
|
||||
}
|
||||
|
||||
if(state().orientation == Orientation::Vertical) {
|
||||
size.setWidth(max(size.width(), state().icon.width));
|
||||
size.setHeight(size.height() + state().icon.height);
|
||||
size.setWidth(max(size.width(), state().icon.width()));
|
||||
size.setHeight(size.height() + state().icon.height());
|
||||
}
|
||||
|
||||
return {size.width() + (state().text ? 20 : 10), size.height() + 10};
|
||||
@@ -75,16 +75,16 @@ void pRadioButton::onActivate() {
|
||||
|
||||
auto pRadioButton::_setState() -> void {
|
||||
image icon = state().icon;
|
||||
icon.transform(0, 32, 255u << 24, 255u << 16, 255u << 8, 255u << 0);
|
||||
icon.transform();
|
||||
|
||||
if(hbitmap) { DeleteObject(hbitmap); hbitmap = 0; }
|
||||
if(himagelist) { ImageList_Destroy(himagelist); himagelist = 0; }
|
||||
if(hbitmap) { DeleteObject(hbitmap); hbitmap = nullptr; }
|
||||
if(himagelist) { ImageList_Destroy(himagelist); himagelist = nullptr; }
|
||||
|
||||
if(OsVersion() < WindowsVista) icon.alphaBlend(GetSysColor(COLOR_BTNFACE));
|
||||
|
||||
hbitmap = CreateBitmap(icon);
|
||||
himagelist = ImageList_Create(icon.width, icon.height, ILC_COLOR32, 1, 0);
|
||||
ImageList_Add(himagelist, hbitmap, NULL);
|
||||
himagelist = ImageList_Create(icon.width(), icon.height(), ILC_COLOR32, 1, 0);
|
||||
ImageList_Add(himagelist, hbitmap, nullptr);
|
||||
BUTTON_IMAGELIST list;
|
||||
list.himl = himagelist;
|
||||
switch(state().orientation) {
|
||||
|
@@ -89,9 +89,10 @@ auto pWindow::setFont(const string& font) -> void {
|
||||
}
|
||||
|
||||
auto pWindow::setFullScreen(bool fullScreen) -> void {
|
||||
auto style = GetWindowLongPtr(hwnd, GWL_STYLE) & WS_VISIBLE;
|
||||
lock();
|
||||
if(fullScreen == false) {
|
||||
SetWindowLongPtr(hwnd, GWL_STYLE, WS_VISIBLE | (state().resizable ? ResizableStyle : FixedStyle));
|
||||
SetWindowLongPtr(hwnd, GWL_STYLE, style | (state().resizable ? ResizableStyle : FixedStyle));
|
||||
setGeometry(state().geometry);
|
||||
} else {
|
||||
HMONITOR monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
|
||||
@@ -101,7 +102,7 @@ auto pWindow::setFullScreen(bool fullScreen) -> void {
|
||||
GetMonitorInfo(monitor, &info);
|
||||
RECT rc = info.rcMonitor;
|
||||
Geometry geometry = {rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top};
|
||||
SetWindowLongPtr(hwnd, GWL_STYLE, WS_VISIBLE | WS_POPUP);
|
||||
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_POPUP);
|
||||
Geometry margin = frameMargin();
|
||||
setGeometry({
|
||||
geometry.x() + margin.x(), geometry.y() + margin.y(),
|
||||
@@ -147,7 +148,8 @@ auto pWindow::setModal(bool modality) -> void {
|
||||
}
|
||||
|
||||
auto pWindow::setResizable(bool resizable) -> void {
|
||||
SetWindowLongPtr(hwnd, GWL_STYLE, WS_VISIBLE | (state().resizable ? ResizableStyle : FixedStyle));
|
||||
auto style = GetWindowLongPtr(hwnd, GWL_STYLE) & WS_VISIBLE;
|
||||
SetWindowLongPtr(hwnd, GWL_STYLE, style | (state().resizable ? ResizableStyle : FixedStyle));
|
||||
setGeometry(state().geometry);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user