Commit Graph

14 Commits

Author SHA1 Message Date
Andreas Kling
11580babbf LibDraw: Put all classes in the Gfx namespace
I started adding things to a Draw namespace, but it somehow felt really
wrong seeing Draw::Rect and Draw::Bitmap, etc. So instead, let's rename
the library to LibGfx. :^)
2020-02-06 11:56:38 +01:00
Andreas Kling
94ca55cefd Meta: Add license header to source files
As suggested by Joshua, this commit adds the 2-clause BSD license as a
comment block to the top of every source file.

For the first pass, I've just added myself for simplicity. I encourage
everyone to add themselves as copyright holders of any file they've
added or modified in some significant way. If I've added myself in
error somewhere, feel free to replace it with the appropriate copyright
holder instead.

Going forward, all new source files should include a license header.
2020-01-18 09:45:54 +01:00
Andreas Kling
cc8c26c39b LibDraw+LibGUI: Move radio button painting into StylePainter
This will allow WindowServer to draw radio buttons :^)
2020-01-08 21:12:40 +01:00
Andreas Kling
f8f2b8b520 LibDraw: Fix text rendering in progress bars 2019-12-29 15:53:28 +01:00
Andreas Kling
d3b40547f7 LibDraw: Fix 1px wide glitch in progress bar painting at some widths
Make sure we always line up the "hole" in the progress bar with the
right side of the paint rect. This fixes a 1px wide glitch seen when
using a darker system theme.
2019-12-25 21:59:37 +01:00
Andreas Kling
7ca7595012 LibDraw: Teach progress bar painting about palettes 2019-12-24 22:17:11 +01:00
Andreas Kling
a79bac428b LibGUI+LibDraw: Add "Palette" concept for scoped color theming
GApplication now has a palette. This palette contains all the system
theme colors by default, and is inherited by a new top-level GWidget.
New child widgets inherit their parents palette.

It is possible to override the GApplication palette, and the palette
of any GWidget.

The Palette object contains a bunch of colors, each corresponding to
a ColorRole. Each role has a convenience getter as well.

Each GWidget now has a background_role() and foreground_role(), which
are then looked up in their current palette when painting. This means
that you no longer alter the background color of a widget by setting
it directly, rather you alter either its background role, or the
widget's palette.
2019-12-24 21:27:16 +01:00
Andreas Kling
c1e8590a40 LibDraw: Use SystemColor::ThreedHighlight everywhere in StylePainter 2019-12-24 02:38:30 +01:00
Andreas Kling
df3a2dba43 LibDraw: Add Button and ButtonText system theme colors
These are now separate from the Window and WindowText colors.
2019-12-24 02:25:50 +01:00
Andreas Kling
411058b2a3 WindowServer+LibGUI: Implement basic color theming
Color themes are loaded from .ini files in /res/themes/
The theme can be switched from the "Themes" section in the system menu.

The basic mechanism is that WindowServer broadcasts a SharedBuffer with
all of the color values of the current theme. Clients receive this with
the response to their initial WindowServer::Greet handshake.

When the theme is changed, WindowServer tells everyone by sending out
an UpdateSystemTheme message with a new SharedBuffer to use.

This does feel somewhat bloated somehow, but I'm sure we can iterate on
it over time and improve things.

To get one of the theme colors, use the Color(SystemColor) constructor:

    painter.fill_rect(rect, SystemColor::HoverHighlight);

Some things don't work 100% right without a reboot. Specifically, when
constructing a GWidget, it will set its own background and foreground
colors based on the current SystemColor::Window and SystemColor::Text.
The widget is then stuck with these values, and they don't update on
system theme change, only on app restart.

All in all though, this is pretty cool. Merry Christmas! :^)
2019-12-23 20:33:01 +01:00
Andreas Kling
b777f740a4 StylePainter: Move progress bar painting from GProgressBar to here
We need to be able to paint progress bars without having a widget. :^)
2019-08-14 20:31:46 +02:00
Andreas Kling
7cd2e739f2 LibDraw: Tweak the hover highlight color.
It was a tad too bright. Also make sure we're using the same color in
all the different places. At some point it would be nice to improve global
color settings, etc.
2019-07-27 11:16:10 +02:00
Andreas Kling
23d45532fc StylePainter: Tweak surface highlight color to match the system warm gray. 2019-07-18 21:30:18 +02:00
Andreas Kling
1c0669f010 LibDraw: Introduce (formerly known as SharedGraphics.)
Instead of LibGUI and WindowServer building their own copies of the drawing
and graphics code, let's it in a separate LibDraw library.

This avoids building the code twice, and will encourage better separation
of concerns. :^)
2019-07-18 10:18:16 +02:00