bsnes/hiro/extension/horizontal-resize-grip.cpp
Tim Allen d87a0f633d Update to bsnes v107r4 beta release.
byuu says:

  - bsnes: added video filters from bsnes v082
  - bsnes: added ZSNES snow effect option when games paused or unloaded
    (no, I'm not joking)
  - bsnes: added 7-zip support (LZMA 19.00 SDK)

[Recent higan WIPs have also mentioned bsnes changes, although the higan code
no longer includes the bsnes code. These changes include:

  - higan, bsnes: added EXLOROM, EXLOROM-RAM, EXHIROM mappings
  - higan, bsnes: focus the viewport after leaving fullscreen exclusive
    mode
  - bsnes: re-added mightymo's cheat code database
  - bsnes: improved make install rules for the game and cheat code
    databases
  - bsnes: delayed construction of hiro::Window objects to properly show
    bsnes window icons

- Ed.]
2019-07-07 19:44:09 +10:00

51 lines
1.6 KiB
C++

#if defined(Hiro_HorizontalResizeGrip)
mHorizontalResizeGrip::mHorizontalResizeGrip() {
image icon;
icon.allocate(5, 15);
for(uint y : range(icon.height())) {
auto data = icon.data() + y * icon.pitch();
icon.write(data, 0x00000000); data += icon.stride();
icon.write(data, 0xff9f9f9f); data += icon.stride();
icon.write(data, 0x00000000); data += icon.stride();
icon.write(data, 0xff9f9f9f); data += icon.stride();
icon.write(data, 0x00000000); data += icon.stride();
}
mCanvas::setIcon(icon);
mCanvas::setMouseCursor(MouseCursor::HorizontalResize);
mCanvas::onMousePress([&](auto button) {
if(button == Mouse::Button::Left && !state.timer.enabled()) {
doActivate();
state.offset = 0;
state.origin = Mouse::position();
state.timer.setEnabled();
}
});
state.timer.setInterval(10).onActivate([&] {
if(!Mouse::pressed(Mouse::Button::Left)) return (void)state.timer.setEnabled(false);
auto position = Mouse::position();
auto offset = position.x() - state.origin.x();
if(offset != state.offset) doResize(offset), offset = state.offset;
});
}
auto mHorizontalResizeGrip::doActivate() const -> void {
if(state.onActivate) state.onActivate();
}
auto mHorizontalResizeGrip::doResize(int offset) const -> void {
if(state.onResize) state.onResize(offset);
}
auto mHorizontalResizeGrip::onActivate(const function<void ()>& callback) -> type& {
state.onActivate = callback;
return *this;
}
auto mHorizontalResizeGrip::onResize(const function<void (int)>& callback) -> type& {
state.onResize = callback;
return *this;
}
#endif