Commit Graph

19 Commits

Author SHA1 Message Date
Andreas Kling
db98327bdc Plumb menu item activation events from WindowServer to clients.
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. :^)
2019-02-12 10:08:35 +01:00
Andreas Kling
08322ab8e1 LibGUI: Coalesce update rects at the GWindow level. 2019-02-10 14:46:43 +01:00
Andreas Kling
53d34a0885 Port Terminal to LibGUI.
To facilitate listening for action on arbitrary file descriptors,
I've added a GNotifier class. It's quite simple but very useful:

GNotifier notifier(fd, GNotifier::Read);
notifier.on_ready_to_read = [this] (GNotifier& fd) {
    // read from fd or whatever else you like :^)
};

The callback will get invoked by GEventLoop when select() says we
have something to read on the fd.
2019-02-10 14:28:39 +01:00
Andreas Kling
2def3d8d3f LibGUI: Start adding an automatic widget layout system.
My needs are really quite simple, so I'm just going to add what I need
as I go along. The first thing I needed was a simple box layout with
widgets being able to say whether they prefer fixed or fill for both
their vertical and horizontal sizes.

I also made a simple GStatusBar so FileManager can show how many bytes
worth of files are in the current directory.
2019-02-10 11:07:13 +01:00
Andreas Kling
5bd363c4bb LibGUI: Widget updates should invalidate their window-relative rect. 2019-02-09 14:30:05 +01:00
Andreas Kling
1f355f2a79 LibGUI: Start working on a GScrollBar.
This widget is far from finished, but it's off to a good start.
Also added a GResizeEvent and GWidget::resize_event() so that widgets
can react to being resized.
2019-02-09 11:19:38 +01:00
Andreas Kling
7fe600f250 LibGUI: Use LightGray as the base UI color.
This feels nicely reminiscent of the gap in time between Win3.11 and Win95,
one of my favorite eras in UI look-and-feel.
2019-02-04 11:53:26 +01:00
Andreas Kling
bc6ff35428 LibGUI: GTextBox should only run a caret blink timer when focused. 2019-02-04 10:34:56 +01:00
Andreas Kling
6fc3c38324 Start working on a simple graphical font editor.
Editing fonts by editing text files is really slow and boring.
A simple font editor seems like a good way to take LibGUI for a spin.
2019-02-02 08:07:06 +01:00
Andreas Kling
069d21ed7f Make buttons unpress when the cursor leaves the button rect.
Implement this functionality by adding global cursor tracking.
It's currently only possible for one GWidget per GWindow to track the cursor.
2019-01-27 08:48:34 +01:00
Andreas Kling
2e370fa4d5 LibGUI: Don't consider a GWidget focused if the window is inactive. 2019-01-26 21:58:43 +01:00
Andreas Kling
de2423de5f LibGUI: Flesh out focus implementation and more GTextBox work. 2019-01-26 11:24:16 +01:00
Andreas Kling
7cf3c7461c Refactor GUI rendering model to be two-phased.
Instead of clients painting whenever they feel like it, we now ask that they
paint in response to a paint message.

After finishing painting, clients notify the WindowServer about the rect(s)
they painted into and then flush eventually happens, etc.

This stuff leaves us with a lot of badly named things. Need to fix that.
2019-01-26 05:20:32 +01:00
Andreas Kling
86eae0f8df Let userland retain the window backing store while drawing into it.
To start painting, call:
gui$get_window_backing_store()

Then finish up with:
gui$release_window_backing_store()

Process will retain the underlying GraphicsBitmap behind the scenes.
This fixes racing between the WindowServer and GUI clients.

This patch also adds a WSWindowLocker that is exactly what it sounds like.
2019-01-24 23:44:19 +01:00
Andreas Kling
d66b0f7dd8 LibGUI: Mass coding style fixes. 2019-01-21 00:54:35 +01:00
Andreas Kling
a9e60fc800 LibGUI: Only redraw the dirty rect in GWidget.
There is some trouble here with the asynchronous nature of WindowServer
and the single per-window backing store we're drawing into. If we start
repainting a widget with a pending invalidation, that invalidation might
get flushed by the WindowServer mid-paint.
2019-01-20 07:59:19 +01:00
Andreas Kling
ea6678b7b3 LibGUI: Hook up GWindow event dispatch for paint and mouse events. 2019-01-20 07:03:38 +01:00
Andreas Kling
8eae89a405 Start bringing up LibGUI properly (formerly Widgets.) 2019-01-20 05:48:43 +01:00
Andreas Kling
b91479d9b9 Rename all the LibGUI classes to GClassName. 2019-01-20 04:49:48 +01:00