[monet] Add MnPalette type
- From: Thomas Wood <thos src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [monet] Add MnPalette type
- Date: Sat, 7 Nov 2009 12:07:12 +0000 (UTC)
commit 61b6453ea751b6d85054d58270d8113e8f27be79
Author: Thomas Wood <thos gnome org>
Date: Sat Nov 7 12:07:05 2009 +0000
Add MnPalette type
An MnPalette represents a collection of colours used to draw a widget.
monet/Makefile.am | 2 +
monet/mn-palette.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++
monet/mn-palette.h | 50 +++++++++++++++++++++++++
3 files changed, 154 insertions(+), 0 deletions(-)
---
diff --git a/monet/Makefile.am b/monet/Makefile.am
index 34dbe22..be23e80 100644
--- a/monet/Makefile.am
+++ b/monet/Makefile.am
@@ -13,6 +13,7 @@ STAMP_FILES = \
source_h = \
mn-color.h \
+ mn-palette.h \
mn-parts.h \
mn-types.h \
monet.h
@@ -69,6 +70,7 @@ libmonet_la_SOURCES = \
$(source_h) \
$(source_h_priv) \
mn-color.c \
+ mn-palette.c \
monet.c
libmonet_la_LIBADD = $(MONET_LIBS)
diff --git a/monet/mn-palette.c b/monet/mn-palette.c
new file mode 100644
index 0000000..62a70df
--- /dev/null
+++ b/monet/mn-palette.c
@@ -0,0 +1,102 @@
+/*
+ * mn-palette.h: collection of colors
+ *
+ * Copyright 2009 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ *
+ * Author: Thomas Wood <thos gnome org>
+ */
+
+#include "mn-palette.h"
+
+struct _MnPalette
+{
+ MnColor bg_colors[4];
+ MnColor fg_colors[4];
+ MnColor highlight_fg_colors[4];
+ MnColor highlight_bg_colors[4];
+ MnColor border_colors[4];
+};
+
+MnPalette *
+mn_palette_new (void)
+{
+ return g_slice_new0 (MnPalette);
+}
+
+void
+mn_palette_free (MnPalette *palette)
+{
+ g_slice_free (MnPalette, palette);
+}
+
+const MnColor *
+mn_palette_get_color (MnPalette *palette,
+ MnPaletteIndex index,
+ MnState state)
+{
+ switch (index)
+ {
+ case MN_FG_COLOR:
+ return &palette->fg_colors[state];
+
+ case MN_BG_COLOR:
+ return &palette->bg_colors[state];
+
+ case MN_HIGHLIGHT_BG_COLOR:
+ return &palette->highlight_bg_colors[state];
+
+ case MN_HIGHLIGHT_FG_COLOR:
+ return &palette->highlight_fg_colors[state];
+
+ case MN_BORDER_COLOR:
+ return &palette->border_colors[state];
+
+ default:
+ return NULL;
+ }
+}
+
+void
+mn_palette_set_color (MnPalette *palette,
+ MnPaletteIndex index,
+ MnState state,
+ const MnColor *color)
+{
+ switch (index)
+ {
+ case MN_FG_COLOR:
+ palette->fg_colors[state] = *color;
+ break;
+
+ case MN_BG_COLOR:
+ palette->bg_colors[state] = *color;
+ break;
+
+ case MN_HIGHLIGHT_BG_COLOR:
+ palette->highlight_bg_colors[state] = *color;
+ break;
+
+ case MN_HIGHLIGHT_FG_COLOR:
+ palette->highlight_fg_colors[state] = *color;
+ break;
+
+ case MN_BORDER_COLOR:
+ palette->border_colors[state] = *color;
+ break;
+ }
+}
diff --git a/monet/mn-palette.h b/monet/mn-palette.h
new file mode 100644
index 0000000..ef77d03
--- /dev/null
+++ b/monet/mn-palette.h
@@ -0,0 +1,50 @@
+/*
+ * mn-palette.h: collection of colors
+ *
+ * Copyright 2009 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ *
+ * Author: Thomas Wood <thos gnome org>
+ */
+
+#include "mn-color.h"
+#include "mn-types.h"
+
+typedef struct _MnPalette MnPalette;
+typedef enum _MnPaletteIndex MnPaletteIndex;
+
+enum _MnPaletteIndex
+{
+ MN_BG_COLOR,
+ MN_FG_COLOR,
+ MN_HIGHLIGHT_BG_COLOR,
+ MN_HIGHLIGHT_FG_COLOR,
+ MN_BORDER_COLOR
+};
+
+
+MnPalette* mn_palette_new (void);
+void mn_palette_free (MnPalette *palette);
+
+const MnColor* mn_palette_get_color (MnPalette *palette,
+ MnPaletteIndex index,
+ MnState state);
+
+void mn_palette_set_color (MnPalette *palette,
+ MnPaletteIndex index,
+ MnState state,
+ const MnColor *color);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]