summaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/global-palettes.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:50:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:50:49 +0000
commitc853ffb5b2f75f5a889ed2e3ef89b818a736e87a (patch)
tree7d13a0883bb7936b84d6ecdd7bc332b41ed04bee /src/ui/dialog/global-palettes.h
parentInitial commit. (diff)
downloadinkscape-c853ffb5b2f75f5a889ed2e3ef89b818a736e87a.tar.xz
inkscape-c853ffb5b2f75f5a889ed2e3ef89b818a736e87a.zip
Adding upstream version 1.3+ds.upstream/1.3+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/ui/dialog/global-palettes.h')
-rw-r--r--src/ui/dialog/global-palettes.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/ui/dialog/global-palettes.h b/src/ui/dialog/global-palettes.h
new file mode 100644
index 0000000..f0a1fe0
--- /dev/null
+++ b/src/ui/dialog/global-palettes.h
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/** @file
+ * @brief Global color palette information.
+ */
+/* Authors: PBS <pbs3141@gmail.com>
+ * Copyright (C) 2022 PBS
+ * Released under GNU GPL v2+, read the file 'COPYING' for more information.
+ */
+
+#ifndef INKSCAPE_UI_DIALOG_GLOBAL_PALETTES_H
+#define INKSCAPE_UI_DIALOG_GLOBAL_PALETTES_H
+
+#include <array>
+#include <vector>
+#include <glibmm/ustring.h>
+
+namespace Inkscape {
+namespace UI {
+namespace Dialog {
+
+/**
+ * The data loaded from a palette file.
+ */
+struct PaletteFileData
+{
+ /// Name of the palette, either specified in the file or taken from the filename.
+ Glib::ustring name;
+
+ /// The preferred number of columns (unused).
+ int columns;
+
+ /// Whether this is a user or system palette.
+ bool user;
+
+ struct Color
+ {
+ /// RGB color.
+ std::array<unsigned, 3> rgb;
+
+ /// Name of the color, either specified in the file or generated from the rgb.
+ Glib::ustring name;
+ };
+
+ /// The list of colors in the palette.
+ std::vector<Color> colors;
+
+ /// Load from the given file, throwing std::runtime_error on fail.
+ PaletteFileData(Glib::ustring const &path);
+};
+
+/**
+ * Singleton class that manages the static list of global palettes.
+ */
+class GlobalPalettes
+{
+ GlobalPalettes();
+public:
+ static GlobalPalettes const &get();
+ std::vector<PaletteFileData> palettes;
+};
+
+} // namespace Dialog
+} // namespace UI
+} // namespace Inkscape
+
+#endif // INKSCAPE_UI_DIALOG_GLOBAL_PALETTES_H