1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 12:57:35 +00:00

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.
This commit is contained in:
Andreas Kling 2019-12-29 00:47:49 +01:00
parent 19d4f4c7b5
commit 7b2dd7e116
18 changed files with 98 additions and 40 deletions

View file

@ -3,6 +3,7 @@
#include <AK/Badge.h>
#include <AK/HashMap.h>
#include <AK/OwnPtr.h>
#include <LibDraw/Palette.h>
#include <LibGUI/GShortcut.h>
class CEventLoop;
@ -42,7 +43,7 @@ public:
const String& invoked_as() const { return m_invoked_as; }
const Vector<String>& args() const { return m_args; }
const Palette& palette() const { return *m_palette; }
Palette palette() const { return Palette(*m_palette); }
void set_palette(const Palette&);
void set_system_palette(SharedBuffer&);
@ -50,8 +51,8 @@ public:
private:
OwnPtr<CEventLoop> m_event_loop;
OwnPtr<GMenuBar> m_menubar;
RefPtr<Palette> m_palette;
RefPtr<Palette> m_system_palette;
RefPtr<PaletteImpl> m_palette;
RefPtr<PaletteImpl> m_system_palette;
HashMap<GShortcut, GAction*> m_global_shortcut_actions;
class TooltipWindow;
TooltipWindow* m_tooltip_window { nullptr };