This is done by dispatching a (synchronous) "EnabledChange" event that can
be picked up in change_event(). Use this event to kick widgets out of their
"being pressed"-type modes if the user is interacting with them while the
state is programmatically changed.
The wheel events will end up in GWidget::mousewheel_event(GMouseEvent&)
on the client-side. This patch also implements basic wheel scrolling in
GScrollableWidget via this mechanism. :^)
This makes it possible for e.g GTextEditor to create a bunch of actions
with popular shortcuts like Ctrl+C, etc, without polluting the global
shortcut namespace. Widget-local actions will only activate while their
corresponding widget has focus. :^)
...and then make GWidget layout invalidation lazy. This way we coalesce
multiple invalidations into a single relayout and we don't have to worry
about child widgets not being fully constructed.
The declarative approach had way too many limitations. This patch adds a
context menu event that can be hooked to prepare a custom context menu on
demand just-in-time. :^)
- child_at(Point)
- move_to_front()
- move_to_back()
- is_frontmost()
- is_backmost()
This patch also makes it possible to receive the mouse event that triggers
a context menu before the context menu is shown. I'm not sure this is the
best design for context menus but it works for now.
That first design was the wrong idea. Instead, have VBWidget instantiate
a GWidget of the appropriate type and parent it to the VBForm.
We then use a new "greedy hit-testing" mechanism in GWidget to prevent any
mouse events from reaching the VBForm's children.
To paint the grabbers above the child widgets, I added a slightly hackish
but kind of neat second_paint_event() that is called after a widget has
painted all of his children. :^)
Any GWidget can have a tooltip and it will automatically pop up below the
center of the widget when hovered. GActions added to GToolBars will use
the action text() as their tooltip automagically. :^)
This code can get a bit confused when the child is destroyed before we
handle the ChildRemoved event. In those cases, the GChildEvent::child()
getter will return nullptr as it's backed by a WeakPtr.
To work around this issue, just always invalidate the layout for now.
This can be made a lot tighter in the future.
In other words, if a surface stretches from the left side of the window
all the way to the right side, skip shading and highlighting the sides.
This makes widgets blend together just slightly with the window. :^)
Windows now learn when the mouse cursor leaves or enters them.
Use this to implement GWidget::{enter,leave}_event() and use that
to implement the CoolBar button effect. :^)
This is a monster patch that required changing a whole bunch of things.
There are performance and stability issues all over the place, but it works.
Pretty cool, I have to admit :^)
GMenu now has an "on_item_activation" callback that fires whenever one
of its items are activated. The menu item identifier is used to distinguish
between items.
Use this to implement font switching in Terminal. :^)