bsnes/hiro/gtk/widget
Tim Allen 427bac3011 Update to v101r06 release.
byuu says:

I reworked the video sizing code. Ended up wasting five fucking hours
fighting GTK. When you call `gtk_widget_set_size_request`, it doesn't
actually happen then. This is kind of a big deal because when I then go
to draw onto the viewport, the actual viewport child window is still the
old size, so the image gets distorted. It recovers in a frame or so with
emulation, but if we were to put a still image on there, it would stay
distorted.

The first thought is, `while(gtk_events_pending())
gtk_main_iteration_do(false);` right after the `set_size_request`. But
nope, it tells you there's no events pending. So then you think, go
deeper, use `XPending()` instead. Same thing, GTK hasn't actually issued
the command to Xlib yet. So then you think, if the widget is realized,
just call a blocking `gtk_main_iteration`. One call does nothing, two
calls results in a deadlock on the second one ... do it before program
startup, and the main window will never appear. Great.

Oh, and it's not just the viewport. It's also the widget container area
of the windows, as well as the window itself, as well as the fullscreen
mode toggle effect. They all do this.

For the latter three, I couldn't find anything that worked, so I just
added 20ms loops of constantly calling `gtk_main_iteration_do(false)`
after each one of those things. The downside here is toggling the status
bar takes 40ms, so you'll see it and it'll feel a tiny bit sluggish.

But I can't have a 20ms wait on each widget resize, that would be
catastrophic to performance on windows with lots of widgets.

I tried hooking configure-event and size-allocate, but they were very
unreliable. So instead I ended up with a loop that waits up to a maximm
of 20ms that inspects the `widget->allocation.(width,height)` values
directly and waits for them to be what we asked for with
`set_size_request`.

There was some extreme ugliness in GTK with calling
`gtk_main_iteration_do` recursively (`hiro::Widget::setGeometry` is
called recursively), so I had to lock it to only happen on the top level
widgets (the child ones should get resized while waiting on the
top-level ones, so it should be fine in practice), and also only run it
on realized widgets.

Even still, I'm getting ~3 timeouts when opening the settings dialog in
higan, but no other windows. But, this is the best I can do for now.

And the reason for all of this pain? Yeah, updated the video code.

So the Emulator::Interface now has this:

    struct VideoSize { uint width, height; };  //or requiem for a tuple
    auto videoSize() -> VideoSize;
    auto videoSize(uint width, uint height, bool arc) -> VideoSize;

The first function, for now, is just returning the literal surface size.
I may remove this ... one thing I want to allow for is cores that send
different texture sizes based on interlace/hires/overscan/etc settings.

The second function is more interesting. Instead of having the UI trying
to figure out sizing, I figure the emulation cores can do a better job
and we can customize it per-core now. So it gets the window's width and
height, and whether the user asked for aspect correction, and then
computes the best width/height ratio possible. For now they're all just
doing multiples of a 1x scale to the UI 2x,3x,4x modes.

We still need a third function, which will probably be what I repurpose
videoSize() for: to return the 'effective' size for pixel shaders, to
then feed into ruby, to then feed into quark, to then feed into our
shaders. Since shaders use normalized coordinates for pixel fetching,
this should work out just fine. The real texture size will be exposed to
quark shaders as well, of course.

Now for the main window ... it's just hard-coded to be 640x480, 960x720,
1280x960 for now. It works nicely for some cores on some modes, not so
much for others. Work in progress I guess.

I also took the opportunity to draw the about dialog box logo on the
main window. Got a bit fancy and used the old spherical gradient and
impose functionality of nall/image on it. Very minor highlight, nothing
garish. Just something nicer than a solid black window.

If you guys want to mess around with sizes, placements, and gradient
styles/colors/shapes ... feel free. If you come up with something nicer,
do share.

That's what led to all the GTK hell ... the logo wasn't drawing right as
you resized the window. But now it is, though I am not at all happy with
the hacking I had to do.

I also had to improve the video update code as a result of this:

  - when you unload a game, it blacks out the screen
      - if you are not quitting the emulator, it'll draw the logo; if
        you are, it won't
  - when you load a game, it black out the logo

These options prevent any unsightliness from resizing the viewport with
image data on it already

I need to redraw the logo when toggling fullscreen with no game loaded
as well for Windows, it seems.
2016-08-15 14:52:05 +10:00
..
button.cpp Update to 20160106 OS X Preview for Developers release. 2016-01-07 19:17:15 +11:00
button.hpp Update to 20160106 OS X Preview for Developers release. 2016-01-07 19:17:15 +11:00
canvas.cpp Update to v099r15 release. 2016-07-04 21:48:17 +10:00
canvas.hpp Update to 20160106 OS X Preview for Developers release. 2016-01-07 19:17:15 +11:00
check-button.cpp Update to 20160106 OS X Preview for Developers release. 2016-01-07 19:17:15 +11:00
check-button.hpp Update to 20160106 OS X Preview for Developers release. 2016-01-07 19:17:15 +11:00
check-label.cpp Update to v094r20 release. 2015-05-23 15:37:08 +10:00
check-label.hpp Update to v094r20 release. 2015-05-23 15:37:08 +10:00
combo-button-item.cpp Update to v098r10 release. 2016-05-16 19:51:12 +10:00
combo-button-item.hpp Update to 20160106 OS X Preview for Developers release. 2016-01-07 19:17:15 +11:00
combo-button.cpp Update to 20160106 OS X Preview for Developers release. 2016-01-07 19:17:15 +11:00
combo-button.hpp Update to v094r43 release. 2015-08-30 12:08:26 +10:00
combo-edit-item.cpp Update to v098r10 release. 2016-05-16 19:51:12 +10:00
combo-edit-item.hpp Update to v098r10 release. 2016-05-16 19:51:12 +10:00
combo-edit.cpp Update to v098r10 release. 2016-05-16 19:51:12 +10:00
combo-edit.hpp Update to v098r10 release. 2016-05-16 19:51:12 +10:00
console.cpp Update to v098r08 release. 2016-05-02 19:57:04 +10:00
console.hpp Update to v099r15 release. 2016-07-04 21:48:17 +10:00
frame.cpp Update to v094r43 release. 2015-08-30 12:08:26 +10:00
frame.hpp Update to v094r43 release. 2015-08-30 12:08:26 +10:00
hex-edit.cpp Update to v094r40 release. 2015-08-18 20:18:00 +10:00
hex-edit.hpp Update to v094r40 release. 2015-08-18 20:18:00 +10:00
horizontal-scroll-bar.cpp Update to v094r41 release (open beta). 2015-08-21 20:57:03 +10:00
horizontal-scroll-bar.hpp Update to v094r41 release (open beta). 2015-08-21 20:57:03 +10:00
horizontal-slider.cpp Update to v094r20 release. 2015-05-23 15:37:08 +10:00
horizontal-slider.hpp Update to v094r20 release. 2015-05-23 15:37:08 +10:00
icon-view-item.cpp Update to 20160106 OS X Preview for Developers release. 2016-01-07 19:17:15 +11:00
icon-view-item.hpp Update to 20160106 OS X Preview for Developers release. 2016-01-07 19:17:15 +11:00
icon-view.cpp Update to v099r14 release. 2016-07-01 21:50:32 +10:00
icon-view.hpp Update to 20160106 OS X Preview for Developers release. 2016-01-07 19:17:15 +11:00
label.cpp Update to v094r40 release. 2015-08-18 20:18:00 +10:00
label.hpp Update to v094r40 release. 2015-08-18 20:18:00 +10:00
line-edit.cpp Update to v094r20 release. 2015-05-23 15:37:08 +10:00
line-edit.hpp Update to v094r20 release. 2015-05-23 15:37:08 +10:00
progress-bar.cpp Update to v094r20 release. 2015-05-23 15:37:08 +10:00
progress-bar.hpp Update to v094r20 release. 2015-05-23 15:37:08 +10:00
radio-button.cpp Update to 20160106 OS X Preview for Developers release. 2016-01-07 19:17:15 +11:00
radio-button.hpp Update to 20160106 OS X Preview for Developers release. 2016-01-07 19:17:15 +11:00
radio-label.cpp Update to v094r43 release. 2015-08-30 12:08:26 +10:00
radio-label.hpp Update to v094r24 release. 2015-06-16 20:30:04 +10:00
source-edit.cpp Update to v094r43 release. 2015-08-30 12:08:26 +10:00
source-edit.hpp Update to v094r43 release. 2015-08-30 12:08:26 +10:00
tab-frame-item.cpp Update to 20160106 OS X Preview for Developers release. 2016-01-07 19:17:15 +11:00
tab-frame-item.hpp Update to 20160106 OS X Preview for Developers release. 2016-01-07 19:17:15 +11:00
tab-frame.cpp Update to 20160106 OS X Preview for Developers release. 2016-01-07 19:17:15 +11:00
tab-frame.hpp Update to 20160106 OS X Preview for Developers release. 2016-01-07 19:17:15 +11:00
table-view-cell.cpp Update to v098r09 release. 2016-05-04 20:07:13 +10:00
table-view-cell.hpp Update to v098r09 release. 2016-05-04 20:07:13 +10:00
table-view-column.cpp Update to v098r09 release. 2016-05-04 20:07:13 +10:00
table-view-column.hpp Update to v098r09 release. 2016-05-04 20:07:13 +10:00
table-view-header.cpp Update to v098r09 release. 2016-05-04 20:07:13 +10:00
table-view-header.hpp Update to v098r09 release. 2016-05-04 20:07:13 +10:00
table-view-item.cpp Update to v098r09 release. 2016-05-04 20:07:13 +10:00
table-view-item.hpp Update to v098r09 release. 2016-05-04 20:07:13 +10:00
table-view.cpp Update to v099r14 release. 2016-07-01 21:50:32 +10:00
table-view.hpp Update to v098r09 release. 2016-05-04 20:07:13 +10:00
text-edit.cpp Update to v094r43 release. 2015-08-30 12:08:26 +10:00
text-edit.hpp Update to v094r43 release. 2015-08-30 12:08:26 +10:00
tree-view-item.cpp Update to 20160106 OS X Preview for Developers release. 2016-01-07 19:17:15 +11:00
tree-view-item.hpp Update to 20160106 OS X Preview for Developers release. 2016-01-07 19:17:15 +11:00
tree-view.cpp Update to v098r08 release. 2016-05-02 19:57:04 +10:00
tree-view.hpp Update to v095r11 release. 2015-12-14 20:41:06 +11:00
vertical-scroll-bar.cpp Update to v094r41 release (open beta). 2015-08-21 20:57:03 +10:00
vertical-scroll-bar.hpp Update to v094r41 release (open beta). 2015-08-21 20:57:03 +10:00
vertical-slider.cpp Update to v094r20 release. 2015-05-23 15:37:08 +10:00
vertical-slider.hpp Update to v094r20 release. 2015-05-23 15:37:08 +10:00
viewport.cpp Update to v099r15 release. 2016-07-04 21:48:17 +10:00
viewport.hpp Update to v094r20 release. 2015-05-23 15:37:08 +10:00
widget.cpp Update to v101r06 release. 2016-08-15 14:52:05 +10:00
widget.hpp Update to v096r01 release. 2015-12-30 17:54:59 +11:00