Commit Graph

80 Commits

Author SHA1 Message Date
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
N00byEdge
00596296c4 LibDraw: Add support for parsing #RGBA colors
This was the nicest way of making this happen, I think.
Fitting it into the 4 length function ended up becoming too hard to read.

Closes #1027
2020-01-07 11:03:35 +01:00
0xtechnobabble
123dcada05 Themes: Support rubberband selection theming 2020-01-07 11:02:43 +01:00
Andreas Kling
fc86460134 AK: Move the userspace SharedBuffer from LibC to AK
This always felt out-of-place in LibC.
2020-01-01 18:53:34 +01:00
Tibor Nagy
edc3580756 LibDraw: Store glyph spacing information in the fonts headers 2019-12-30 14:02:12 +01:00
Andreas Kling
f8f2b8b520 LibDraw: Fix text rendering in progress bars 2019-12-29 15:53:28 +01:00
Andreas Kling
7b2dd7e116 LibDraw+LibGUI: Allow changing individual colors in a Palette
Palette is now a value wrapper around a NonnullRefPtr<PaletteImpl>.
A new function, set_color(ColorRole, Color) implements a simple
copy-on-write mechanism so that we're sharing the PaletteImpl in the
common case, but allowing you to create custom palettes if you like,
by getting a GWidget's palette, modifying it, and then assigning the
modified palette to the widget via GWidget::set_palette().

Use this to make PaintBrush show its palette colors once again.

Fixes #943.
2019-12-29 00:47:49 +01:00
Andreas Kling
cbdd65e4d9 LibDraw: Remove redundant Rect copy constructor 2019-12-27 16:55:10 +01:00
Shannon Booth
123b5c9d34 LibDraw: Add draw_ellipse_intersecting function
This functon will draw an ellipse which is intersecting the corners of
the rect given. It is a very naive implementation, taking 200 samples of
points around the ellipse, and drawing straight lines between each of
these points.

The ellipses look good enough to me though!
2019-12-27 00:52:17 +01:00
Shannon Booth
b830639912 PaintBrush: Add a "rectangle tool"
Fill, line, and gradient modes initially supported :^)
2019-12-26 21:22:29 +01:00
Shannon Booth
70a2355963 LibDraw: Add dx/dy_relative_to() helper functions for Points 2019-12-26 21:22:29 +01:00
Andreas Kling
5be6a43860 LibDraw: Add MenuBaseText and MenuSelectionText color roles
This allows the very aesthetic "Hotdog Stand" theme to have quite
reasonable looking menus.
2019-12-26 00:58:46 +01:00
Andreas Kling
b5bcecef09 LibDraw: Remove bogus LibC/ prefix on SharedBuffer.h include
This class really doesn't belong in LibC anyway, does it? Mehh.
2019-12-25 22:50:17 +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
aae54bdbde LibDraw: Add ColorRole::BaseText (to be painted on ColorRole::Base) 2019-12-24 22:01:32 +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
b6eba388e3 LibDraw: Add Selection and SelectionText system theme colors 2019-12-24 12:13:49 +01:00
Andreas Kling
c1e8590a40 LibDraw: Use SystemColor::ThreedHighlight everywhere in StylePainter 2019-12-24 02:38:30 +01:00
Andreas Kling
8ae826f5c3 LibDraw: Give Color::lightened() an amount argument 2019-12-24 02:25:50 +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
9171aef724 LibGUI: Use SystemColor::Text in more places 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
Shannon Booth
456a4bc108 LibDraw: Parse all CSS standardised color keywords 2019-12-23 10:56:59 +01:00
joshua stein
ac25438d54 Build: clean up build system, use one shared Makefile
Allow everything to be built from the top level directory with just
'make', cleaned with 'make clean', and installed with 'make
install'.  Also support these in any particular subdirectory.

Specifying 'make VERBOSE=1' will print each ld/g++/etc. command as
it runs.

Kernel and early host tools (IPCCompiler, etc.) are built as
object.host.o so that they don't conflict with other things built
with the cross-compiler.
2019-12-20 20:20:54 +01:00
Andreas Kling
7cc4b90b16 LibDraw: Create purgeable GraphicsBitmap in the PNG decoder
Also add ImageDecoder APIs for controlling the volatile flag.
2019-12-18 20:50:58 +01:00
Andreas Kling
77ae98a9b6 LibDraw: Add GraphicsBitmap::create_purgeable()
This allows you to create a process-private purgeable GraphicsBitmap.
The volatile flag is controlled via set_volatile() / set_nonvolatile().
2019-12-18 20:50:05 +01:00
Andreas Kling
a32cae4c3b LibDraw: Parse the color name "pink" to #ffc0cb 2019-12-16 19:45:21 +01:00
Andreas Kling
b909d991f1 LibDraw: Add a way to check for horizontal/vertical Rect intersections 2019-12-13 23:36:17 +01:00
Andreas Kling
6f4c380d95 AK: Use size_t for the length of strings
Using int was a mistake. This patch changes String, StringImpl,
StringView and StringBuilder to use size_t instead of int for lengths.
Obviously a lot of code needs to change as a result of this.
2019-12-09 17:51:21 +01:00
Andreas Kling
183ee5847c LibDraw: Add GraphicsBitmap::to_shareable_bitmap()
This function returns the bitmap itself if it's already backed by a
SharedBuffer object, otherwise it creates a shareable copy of itself
and returns that.
2019-12-08 17:07:44 +01:00
Andreas Kling
b780dcf353 LibDraw: Remove convenience functions for the old WindowServer IPC 2019-12-02 11:11:05 +01:00
Andreas Kling
f04394b9f3 LibDraw: Painter::draw_pixel() with thickness>1 was doubly translating
Callers of draw_pixel() are not expecting it to apply translation since
they will have already done that themselves.

This was causing draw_line() with thickness>1 to have an offset applied
in case the painter was already translated.
2019-11-29 22:31:45 +01:00
Andreas Kling
478cfae7c8 LibDraw: Support dotted lines in Painter::draw_line()
Painter::draw_line() now has an optional "bool dotted" parameter that
causes it to only render every other pixel.

Note that this only works with horizontal and vertical lines at the
moment and we'll assert if called with dotted=true for a diagonal line.
2019-11-27 20:52:11 +01:00
Andreas Kling
c645d9fe4a LibDraw: Add Painter::clear_rect() for filling a rect without blending
Sometimes you want to fill a rect with a specific color without alpha
blending it with whatever's already there.
2019-11-25 11:34:55 +01:00
Andreas Kling
35c26a06fc LibCore: Move puff() from LibDraw to LibCore
Since it's used both by CGzip and PNGLoader, it seems most appropriate
to keep this in LibCore.
2019-11-23 23:43:37 +01:00
Andreas Kling
00ab9488ad LibDraw: Start work on a GIF decoder (not yet functional!)
Here comes the first part of a GIF decoder. It decodes up to the point
of gathering all the LZW-compressed data. The next step is to implement
decompression, and then turn the decompressed data into a bitmap using
the color maps, etc.
2019-11-23 16:50:21 +01:00
Andreas Kling
5f7f97355e LibDraw: Add named colors "MidCyan" and "DarkCyan"
I need these for .. a thing. :^)
2019-11-18 19:02:10 +01:00
Andreas Kling
6685be36a0 LibDraw: Add Rect::from_two_points(Point, Point)
This returns the rectangle between two given Points. Thanks Owlinator
for suggesting this much easier way of doing it :^)
2019-11-17 16:37:42 +01:00
Andreas Kling
89c0b158da LibDraw: Add support for colors with alpha in Painter::fill_rect()
This code is naive, but it works and looks okay. :^)
2019-11-16 19:26:17 +01:00
masi456
7e7451c427 WindowServer: Don't de-maximize windows immediately (#756)
At least 5 pixels of dragging in some direction needed until a window
gets de-maximized.
2019-11-10 18:28:01 +01:00
George Pickering
704f48d7f3 POSIX compliance: (most) shell scripts converted to generic shell
Ports/.port_include.sh, Toolchain/BuildIt.sh, Toolchain/UseIt.sh
have been left largely untouched due to use of Bash-exclusive
functions and variables such as $BASH_SOURCE, pushd and popd.
2019-11-03 09:26:22 +01:00
Andreas Kling
14c8446ea4 LibDraw: Add FloatPoint, FloatSize and FloatRect
These are floating point varians of Point, Size and Rect.
2019-10-20 12:55:55 +02:00
Andreas Kling
f970578cd4 LibDraw: Rename ImageLoader => ImageDecoder
ImageLoader was not the right name for this, as there is no loading
happening, only decoding. :^)
2019-10-19 20:54:47 +02:00
Andreas Kling
0d8aaaaa44 LibDraw: Store emojis in a HashMap<u32, RefPtr<GraphicsBitmap>>
Get rid of the dedicated Emoji class to make it easier to store a null
value signifying a failed lookup.

This allows us to remember failed lookups, making subsequent failures
for the same codepoint much faster. :^)
2019-10-19 18:36:45 +02:00
Andreas Kling
8acc61f19a LibDraw: Have the PNGImageLoaderPlugin remember if it failed to decode
Instead of trying again when asked repeatedly, just remember if it
didn't work out the first time.
2019-10-19 17:43:47 +02:00
Andreas Kling
96f10c8de2 LibDraw: Rename Painter::blit_tiled() => draw_tiled_bitmap()
Also change the API to take a destination rect instead of a source rect
since internally it was basically creating a destination rect from the
source rect anyway. It was a little confusing.
2019-10-19 11:05:21 +02:00
Andreas Kling
2366c330e3 LibDraw: Teach PNGLoader to only decode enough of learn the image size 2019-10-16 20:02:24 +02:00
Andreas Kling
1bd2941467 LibDraw: Add ImageLoader, a simple abstraction for image loading
An ImageLoader is a generic interface for loading encoded image data of
any supported format. It has an ImageLoaderPlugin internally that does
all the work.

This patch adds an initial PNGImageLoaderPlugin that knows how to
retrieve the size of a PNG, and the bitmap. The API is divided into
size() and bitmap() to facilitate geometry-only decoding.
This will be useful in places like LibHTML where we need dimensions for
layout purposes but can wait with the bitmap until later.
2019-10-15 21:48:08 +02:00
Andreas Kling
122d12e617 LibDraw: Parse some more color string formats found on the web
This patch adds the 17 color names from CSS2.1, as well as support for
the "#rgb" shorthand where each component is a hex digit that gets
multiplied by 17.
2019-10-06 21:40:14 +02:00