Commit Graph

93 Commits

Author SHA1 Message Date
Andreas Kling
d353c7c3d6 LibGUI: Support different button styles.
I want to try an MS Office 97 "CoolBar" inspired look for my toolbars.
This is only the painting support, we still need hover events to implement
the actual effect.
2019-02-20 09:22:38 +01:00
Andreas Kling
dc753b58a5 LibGUI: Improve GBoxLayout so it can better support GToolBar.
Added spacing and margin concepts to GLayout. Support layout a sequence
of nothing but fixed-size objects in the desired orientation. :^)
2019-02-20 09:04:28 +01:00
Andreas Kling
b704d3d295 LibGUI: Add a GToolBar class that can be populated with GActions.
The same action can be added to both a menu and a toolbar.
Use this to put a toolbar into FileManager. This is pretty neat. :^)
2019-02-20 02:39:46 +01:00
Andreas Kling
9b71307d49 WindowServer: Support windows with alpha channels. And per-WSWindow opacity.
This patch also adds a Format concept to GraphicsBitmap. For now there are
only two formats: RGB32 and RGBA32. Windows with alpha channel have their
backing stores created in the RGBA32 format.

Use this to make Terminal windows semi-transparent for that comfy rice look.
There is one problem here, in that window compositing overdraw incurs
multiple passes of blending of the same pixels. This leads to a mismatch in
opacity which is obviously not good. I will work on this in a later patch.

The alpha blending is currently straight C++. It should be relatively easy
to optimize this using SSE instructions.

For now I'm just happy with the cute effect. :^)
2019-02-19 01:42:53 +01:00
Andreas Kling
8eedbbc9ca Prune compiler flags a bit. Let's go with -march=i686 for now. 2019-02-17 15:17:21 +01:00
Andreas Kling
8321908abe LibGUI: Tweak the scrollbar and button styles a bit. 2019-02-17 12:08:28 +01:00
Andreas Kling
4b15dd2bca LibGUI: Rename GEventLoop::exit() and GApplication::exit() to quit().
These functions don't exit immediately, but rather on the next iteration
of the event loop.

Since exit() is already used by the standard library, let's call it quit()
instead. That way, saying exit() means the same thing here as anywhere else.
2019-02-17 09:59:56 +01:00
Andreas Kling
18062f4ad6 LibGUI: Remove some debugging noise. 2019-02-17 01:05:24 +01:00
Andreas Kling
10d6f9ce31 SharedGraphics: Removed some unused stuff from Font. 2019-02-17 00:36:55 +01:00
Andreas Kling
640360e958 Move WindowServer to userspace.
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 :^)
2019-02-17 00:13:47 +01:00
Andreas Kling
df6aaaeeef Enable -Wimplicit-fallthrough. 2019-02-15 12:39:16 +01:00
Andreas Kling
29c49356e3 WindowServer: Rename GUI_Foo to WSAPI_Foo. 2019-02-15 09:17:18 +01:00
Andreas Kling
a54cd84c59 Move WindowServer API types header into WindowServer/. 2019-02-15 09:14:21 +01:00
Andreas Kling
c7f5213d5b LibGUI: Add some extremely primitive retrying for the server connection. 2019-02-14 17:43:20 +01:00
Andreas Kling
bf58241c11 Port the WindowServer and LibGUI to communicate through local sockets.
This is really cool! :^)

Apps currently refuse to start if the WindowServer isn't listening on the
socket in /wsportal. This makes sense, but I guess it would also be nice
to have some sort of "wait for server on startup" mode.

This has performance issues, and I'll work on those, but this stuff seems
to actually work and I'm very happy with that.
2019-02-14 17:18:35 +01:00
Andreas Kling
427df5f312 LibGUI: Yield (using select()) in GEventLoop::wait_for_specific_event().
This is factored a bit stupidly. It would be nicer to just have the
read() in drain_events_from_server() be blocking, but the fd is opened
with O_NONBLOCK right now.

This makes everything run real snappy once again. :^)
2019-02-14 10:06:41 +01:00
Andreas Kling
222a6f7bbc WindowServer: Post error messages to clients on protocol failure. 2019-02-14 09:32:34 +01:00
Andreas Kling
f529b845ec WindowServer: Convert entire API to be message-based.
One big step towards userspace WindowServer. :^)
2019-02-14 01:21:32 +01:00
Andreas Kling
ef4e9860fd WindowServer: Convert the remaining menu APIs into messages. 2019-02-13 21:47:14 +01:00
Andreas Kling
cf432b4c3d WindowServer: Refactor more of the menu APIs to be message-based.
This is all pretty verbose but I can whittle it down later. :^)
2019-02-13 18:49:23 +01:00
Andreas Kling
fbbf57b61c Rename GUI_Event to GUI_ServerMessage.
Now that communication is becoming bidirectional, "event" is no longer right.
2019-02-13 17:59:38 +01:00
Andreas Kling
4f98a35beb WindowServer: Begin refactoring towards a fully asynchronous protocol.
In order to move the WindowServer to userspace, I have to eliminate its
dependence on system call facilities. The communication channel with each
client needs to be message-based in both directions.
2019-02-13 17:54:30 +01:00
Andreas Kling
96352ab735 LibGUI: Pass the computed max_fd(+1) to select(). 2019-02-13 17:08:13 +01:00
Andreas Kling
d74b131c27 Add a little About app and hook it up to the system menu's "About..." entry.
Added icons and customizable text alignment to GLabel.
2019-02-12 15:23:07 +01:00
Andreas Kling
d6326d6c2e LibGUI: Add a GFontDatabase class that lets you enumerate fonts and more.
"More" in this case being also giving you the ability to load a font by name.
Use this as backend for Terminal's font menu. :^)
2019-02-12 14:36:19 +01:00
Andreas Kling
3085e400bc LibGUI: Add GAction class and make GMenu deal in actions rather than strings. 2019-02-12 14:09:48 +01:00
Andreas Kling
4b8133e925 WindowServer: Clean up any menu objects on process exit.
..and now that this works, implement the Quit menu action in Terminal. :^)
2019-02-12 10:41:09 +01:00
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
133706d697 Add API's and plumbing for WindowServer clients to make menus. 2019-02-12 00:52:19 +01:00
Andreas Kling
757429fb55 LibGUI: More work on client-side menus. 2019-02-11 15:37:12 +01:00
Andreas Kling
3351f1ccc1 Port all apps to GApplication. 2019-02-11 14:56:23 +01:00
Andreas Kling
9483b39227 LibGUI: Add GMenu* and GApplication classes. 2019-02-11 14:43:43 +01:00
Andreas Kling
5f288014d4 WindowServer: More work on menus. 2019-02-11 10:08:54 +01:00
Andreas Kling
7abef6ba9e LibGUI: Put some logspam behind debugging macros. 2019-02-11 08:27:13 +01:00
Andreas Kling
1511afc4e2 LibGUI: Add GWindow::move_to(). 2019-02-11 06:09:54 +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
d333013a54 LibGUI: Support horizontal GScrollBars as well. 2019-02-10 12:27:21 +01:00
Andreas Kling
8313ce57dc LibGUI: Improve GScrollBar button look a bit.
The arrows look better when they're sharp. :^)
2019-02-10 11:57:19 +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
29f2a22d34 LibGUI: Minor cleanup in GScrollBar. 2019-02-10 08:23:03 +01:00
Andreas Kling
f7831f8c76 LibGUI: Draw GScrollBar buttons with a disabled look when appropriate. 2019-02-10 07:37:02 +01:00
Andreas Kling
e354c08c98 LibGUI: Share code for widget rendering styles in a GStyle class.
Since GScrollBar wants its internal buttons to look like GButtons,
let's share the painting code between them.
2019-02-10 07:11:01 +01:00
Andreas Kling
9ea2131adf LibGUI: Support dragging the GScrollBar scrubber.
This was pleasantly easy to implement with the global mouse tracking. :^)
2019-02-10 06:51:01 +01:00
Andreas Kling
464873f8b5 LibGUI: Draw some cute arrows on the GScrollBar buttons. 2019-02-10 06:10:27 +01:00
Andreas Kling
5bd363c4bb LibGUI: Widget updates should invalidate their window-relative rect. 2019-02-09 14:30:05 +01:00
Andreas Kling
6a3ff7efc5 GScrollBar: Start looking a bit more like a proper scrollbar.
And hook up FileManager's DirectoryView with its scrollbar so it actually
causes the directory view to shift up and down. Very cool. :^)
2019-02-09 11:29:59 +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
5158bee08c Don't use -mregparm=3 in userspace.
It's pretty comfy having arguments in registers in the kernel for now though.
2019-02-08 01:24:52 +01:00
Andreas Kling
6d7f000ffc Launcher: Factor the app buttons into a LaunchButton class.
Added some LibGUI helpers while I'm at it.
2019-02-08 00:15:04 +01:00