gtk-css-engine r114 - in trunk: . libccd/ccd
- From: robsta svn gnome org
- To: svn-commits-list gnome org
- Subject: gtk-css-engine r114 - in trunk: . libccd/ccd
- Date: Thu, 18 Sep 2008 10:57:25 +0000 (UTC)
Author: robsta
Date: Thu Sep 18 10:57:25 2008
New Revision: 114
URL: http://svn.gnome.org/viewvc/gtk-css-engine?rev=114&view=rev
Log:
* TODO: link screenshots of inspirational themes/mockups.
* configure.in: tweak configuration summary output.
* libccd/ccd/Makefile.am:
* libccd/ccd/ccd-background.c:
* libccd/ccd/ccd-background.h:
* libccd/ccd/ccd-position.c:
* libccd/ccd/ccd-position.h:
Generic position parsing infrastructure. Parse background image
settings.
Added:
trunk/libccd/ccd/ccd-position.c
trunk/libccd/ccd/ccd-position.h
Modified:
trunk/ (props changed)
trunk/ChangeLog
trunk/TODO
trunk/configure.in
trunk/libccd/ccd/Makefile.am
trunk/libccd/ccd/ccd-background.c
trunk/libccd/ccd/ccd-background.h
Modified: trunk/TODO
==============================================================================
--- trunk/TODO (original)
+++ trunk/TODO Thu Sep 18 10:57:25 2008
@@ -95,6 +95,10 @@
* Investigate a helper app for widget matching, like
http://testbit.eu/~timj/historic/gle/ .
+Inspirations for themes
+* http://www.flickr.com/photos/andyfitz/2706976226/
+* http://ux.suse.de/~garrett/public/hackweek/oneclick/mockups/oneclick-mockup-trust%20and%20install.png
+* http://cypohirogen.deviantart.com/art/Mail-Scrollbar-for-Leopard-79257200
RELEASES
========
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Thu Sep 18 10:57:25 2008
@@ -57,7 +57,6 @@
AM_CONDITIONAL([CCD_STANDALONE], test "$enable_libccd" == "yes")
-AC_MSG_CHECKING([whether to built debug code])
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug], [enable debug code])],
[
@@ -65,7 +64,7 @@
],[
enable_debug="no"
])
-AC_MSG_RESULT([$enable_debug])
+
if test "$enable_debug" == "yes"; then
AC_DEFINE([CCD_DEBUG], [1], [enable debug code])
CFLAGS="-g -O0 ${CFLAGS}"
@@ -206,10 +205,10 @@
echo "
Configuration
- CFLAGS ${CFLAGS}
- Build debugging code $enable_debug
- Standalone libccd $enable_libccd
- Support for SVG images $with_rsvg
- Support for SVG image parts $with_soup (requires libsoup)
+ CFLAGS ${CFLAGS}
+ Build debugging code $enable_debug
+ Standalone libccd $enable_libccd
+ Support for SVG images $with_rsvg (requires librsvg)
+WIP Support for SVG fragments $with_soup (requires libsoup)
"
Modified: trunk/libccd/ccd/Makefile.am
==============================================================================
--- trunk/libccd/ccd/Makefile.am (original)
+++ trunk/libccd/ccd/Makefile.am Thu Sep 18 10:57:25 2008
@@ -22,6 +22,7 @@
ccd.h \
ccd-image.h \
ccd-node.h \
+ ccd-position.h \
ccd-property.h \
ccd-selector-group.h \
ccd-selector.h \
@@ -55,6 +56,8 @@
ccd-node.h \
ccd-parser.c \
ccd-parser.h \
+ ccd-position.c \
+ ccd-position.h \
ccd-property.c \
ccd-property.h \
ccd-selector-group.c \
Modified: trunk/libccd/ccd/ccd-background.c
==============================================================================
--- trunk/libccd/ccd/ccd-background.c (original)
+++ trunk/libccd/ccd/ccd-background.c Thu Sep 18 10:57:25 2008
@@ -20,6 +20,16 @@
#include <string.h>
#include "ccd-background.h"
+static const struct {
+ char const *name;
+ const enum ccd_background_repeat repeat;
+} _repeat_map[] = {
+ { "repeat", CCD_BACKGROUND_REPEAT },
+ { "repeat-x", CCD_BACKGROUND_REPEAT_X },
+ { "repeat-y", CCD_BACKGROUND_REPEAT_Y },
+ { "no-repeat", CCD_BACKGROUND_NO_REPEAT }
+};
+
ccd_background_t *
ccd_background_new (void)
{
@@ -33,6 +43,41 @@
}
static bool
+bg_attachment_parse (ccd_background_attachment_t *self,
+ CRTerm const **values)
+{
+ ccd_property_spec_t spec;
+
+ if (!*values) {
+ return false;
+ }
+
+ spec = ccd_property_parse_spec (values);
+ if (CCD_PROPERTY_SPEC_INHERIT == spec) {
+ self->spec = spec;
+ return true;
+ }
+
+ if (TERM_IDENT == (*values)->type) {
+ char const *attachment;
+ attachment = cr_string_peek_raw_str ((*values)->content.str);
+ if (0 == g_ascii_strcasecmp ("scroll", attachment)) {
+ self->attachment = CCD_BACKGROUND_SCROLL;
+ self->spec = CCD_PROPERTY_SPEC_SET;
+ *values = (*values)->next;
+ return true;
+ } else if (0 == g_ascii_strcasecmp ("fixed", attachment)) {
+ self->attachment = CCD_BACKGROUND_FIXED;
+ self->spec = CCD_PROPERTY_SPEC_SET;
+ *values = (*values)->next;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+static bool
bg_color_parse (ccd_background_color_t *self,
CRTerm const **values)
{
@@ -56,6 +101,126 @@
return self->spec == CCD_PROPERTY_SPEC_SET;
}
+static bool
+bg_position_parse (ccd_background_position_t *self,
+ CRTerm const **values)
+{
+ ccd_property_spec_t spec;
+ uint32_t flags;
+ bool have_hpos;
+ bool have_vpos;
+
+ if (!*values) {
+ return false;
+ }
+
+ spec = ccd_property_parse_spec (values);
+ if (CCD_PROPERTY_SPEC_INHERIT == spec) {
+ /* Not implemented yet. */
+ g_assert_not_reached ();
+ self->spec = CCD_PROPERTY_SPEC_UNSET;
+ return false;
+ }
+
+ flags = CCD_POSITION_MASK_NUMERIC | CCD_POSITION_MASK_HORIZONTAL;
+ have_hpos = ccd_position_parse (&self->hpos, flags, values);
+ if (!have_hpos) {
+ self->spec = CCD_PROPERTY_SPEC_UNSET;
+ return false;
+ }
+
+ flags = CCD_POSITION_MASK_NUMERIC | CCD_POSITION_MASK_VERTICAL;
+ have_vpos = ccd_position_parse (&self->vpos, flags, values);
+ if (have_hpos && !have_vpos) {
+ /* Fall back to `center' for vpos.
+ * http://www.w3.org/TR/CSS21/colors.html#propdef-background-position */
+ self->vpos.type = CCD_POSITION_PERCENTAGE;
+ self->vpos.value = 50;
+ }
+
+ /* A bit fuzzy, but let's say we're satisfied with `hpos' only. */
+ if (have_hpos) {
+ self->spec = CCD_PROPERTY_SPEC_SET;
+ return true;
+ }
+
+ return false;
+}
+
+static bool
+bg_repeat_parse (ccd_background_repeat_t *self,
+ CRTerm const **values)
+{
+ char const *repeat;
+ ccd_property_spec_t spec;
+
+ if (!*values || (*values)->type != TERM_IDENT) {
+ return false;
+ }
+
+ repeat = cr_string_peek_raw_str ((*values)->content.str);
+ for (unsigned int i = 0; i < G_N_ELEMENTS (_repeat_map); i++) {
+ if (0 == g_ascii_strcasecmp (_repeat_map[i].name, repeat)) {
+ self->repeat = _repeat_map[i].repeat;
+ self->spec = CCD_PROPERTY_SPEC_SET;
+ *values = (*values)->next;
+ return true;
+ }
+ }
+
+ /* Not found, maybe a generic property?
+ * Only `inherit' is allowed anyway. */
+ spec = ccd_property_parse_spec (values);
+ if (spec == CCD_PROPERTY_SPEC_INHERIT) {
+ self->spec = spec;
+ return true;
+ } else {
+ self->spec = CCD_PROPERTY_SPEC_UNSET;
+ return false;
+ }
+}
+
+static bool
+bg_size_parse (ccd_background_size_t *self,
+ CRTerm const **values)
+{
+ uint32_t flags;
+ bool ret;
+
+ if (!*values) {
+ return false;
+ }
+
+ flags = CCD_POSITION_MASK_NUMERIC | CCD_POSITION_MASK_AUTO;
+ ret = ccd_position_parse (&self->width, flags, values);
+ if (!ret) {
+ return false;
+ }
+
+ if (CCD_POSITION_CONTAIN == self->width.type ||
+ CCD_POSITION_COVER == self->width.type) {
+ self->height.type = self->width.type;
+ self->spec = CCD_PROPERTY_SPEC_SET;
+ return true;
+ }
+
+ if (CCD_POSITION_MASK_NUMERIC & self->width.type ||
+ CCD_POSITION_AUTO == self->width.type) {
+ flags = CCD_POSITION_MASK_NUMERIC | CCD_POSITION_MASK_AUTO;
+ ret = ccd_position_parse (&self->height, flags, values);
+ if (ret) {
+ self->spec = CCD_PROPERTY_SPEC_SET;
+ return true;
+ } else {
+ self->height.type = CCD_POSITION_AUTO;
+ self->spec = CCD_PROPERTY_SPEC_SET;
+ return true;
+ }
+ }
+
+ return false;
+}
+
bool
ccd_background_parse (ccd_background_t *self,
char const *property,
@@ -67,11 +232,17 @@
if (0 == strcmp ("background", property)) {
+ /* TODO: also support `background-size' here. */
ret |= bg_color_parse (&self->bg_color, &values);
ret |= bg_image_parse (&self->bg_image, &values);
return ret;
}
+ if (0 == strcmp ("background-attachment", property)) {
+
+ return bg_attachment_parse (&self->bg_attachment, &values);
+ }
+
if (0 == strcmp ("background-color", property)) {
return bg_color_parse (&self->bg_color, &values);
@@ -82,6 +253,21 @@
return bg_image_parse (&self->bg_image, &values);
}
+ if (0 == strcmp ("background-position", property)) {
+
+ return bg_position_parse (&self->bg_position, &values);
+ }
+
+ if (0 == strcmp ("background-repeat", property)) {
+
+ return bg_repeat_parse (&self->bg_repeat, &values);
+ }
+
+ if (0 == strcmp ("background-size", property)) {
+
+ return bg_size_parse (&self->bg_size, &values);
+ }
+
return false;
}
Modified: trunk/libccd/ccd/ccd-background.h
==============================================================================
--- trunk/libccd/ccd/ccd-background.h (original)
+++ trunk/libccd/ccd/ccd-background.h Thu Sep 18 10:57:25 2008
@@ -28,11 +28,30 @@
#include <ccd/ccd-features.h>
#include <ccd/ccd-color.h>
#include <ccd/ccd-image.h>
+#include <ccd/ccd-position.h>
#include <ccd/ccd-property.h>
G_BEGIN_DECLS
typedef struct {
+ enum ccd_background_repeat {
+ CCD_BACKGROUND_REPEAT = 0,
+ CCD_BACKGROUND_REPEAT_X,
+ CCD_BACKGROUND_REPEAT_Y,
+ CCD_BACKGROUND_NO_REPEAT
+ } repeat;
+ ccd_property_spec_t spec;
+} ccd_background_repeat_t;
+
+typedef struct {
+ enum ccd_background_attachment {
+ CCD_BACKGROUND_SCROLL,
+ CCD_BACKGROUND_FIXED
+ } attachment;
+ ccd_property_spec_t spec;
+} ccd_background_attachment_t;
+
+typedef struct {
ccd_color_t color;
ccd_property_spec_t spec;
} ccd_background_color_t;
@@ -43,8 +62,24 @@
} ccd_background_image_t;
typedef struct {
- ccd_background_color_t bg_color;
- ccd_background_image_t bg_image;
+ ccd_position_t hpos;
+ ccd_position_t vpos;
+ ccd_property_spec_t spec;
+} ccd_background_position_t;
+
+typedef struct {
+ ccd_position_t width;
+ ccd_position_t height;
+ ccd_property_spec_t spec;
+} ccd_background_size_t;
+
+typedef struct {
+ ccd_background_attachment_t bg_attachment;
+ ccd_background_color_t bg_color;
+ ccd_background_image_t bg_image;
+ ccd_background_position_t bg_position;
+ ccd_background_repeat_t bg_repeat;
+ ccd_background_size_t bg_size;
} ccd_background_t;
ccd_background_t * ccd_background_new (void);
Added: trunk/libccd/ccd/ccd-position.c
==============================================================================
--- (empty file)
+++ trunk/libccd/ccd/ccd-position.c Thu Sep 18 10:57:25 2008
@@ -0,0 +1,119 @@
+/* The Cairo CSS Drawing Library.
+ * Copyright (C) 2008 Robert Staudinger
+ *
+ * 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 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 St, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+#include "ccd-position.h"
+
+static const struct {
+ char const *name;
+ ccd_position_flags_t match;
+ const double percentage;
+} _position_map[] = {
+ { "left", CCD_POSITION_LEFT, 0 },
+ { "top", CCD_POSITION_TOP, 0 },
+ { "right", CCD_POSITION_RIGHT, 100 },
+ { "bottom", CCD_POSITION_BOTTOM, 100 },
+ { "center", CCD_POSITION_CENTER, 50 },
+
+ { "auto", CCD_POSITION_AUTO, -1 },
+ { "contain", CCD_POSITION_CONTAIN, -1 },
+ { "cover", CCD_POSITION_COVER, -1 }
+};
+
+bool
+ccd_position_parse (ccd_position_t *self,
+ uint32_t flags,
+ CRTerm const **value)
+{
+ char const *name;
+
+ switch ((*value)->type) {
+ case TERM_IDENT:
+ name = (char const *) cr_string_peek_raw_str ((*value)->content.str);
+ for (int i = 0; i < G_N_ELEMENTS (_position_map); i++) {
+ if (_position_map[i].match & flags &&
+ 0 == g_ascii_strcasecmp (_position_map[i].name, name)) {
+ self->type = CCD_POSITION_PERCENTAGE;
+ self->value = _position_map[i].percentage;
+ *value = (*value)->next;
+ return true;
+ }
+ }
+ break;
+ case TERM_NUMBER:
+ if (CCD_POSITION_FLAG_PERCENTAGE & flags &&
+ NUM_PERCENTAGE == (*value)->content.num->type) {
+ self->type = CCD_POSITION_PERCENTAGE;
+ self->value = (*value)->content.num->val;
+ *value = (*value)->next;
+ return true;
+ } else if (CCD_POSITION_FLAG_LENGTH & flags &&
+ NUM_GENERIC == (*value)->content.num->type) {
+ self->type = CCD_POSITION_LENGTH;
+ self->value = (*value)->content.num->val;
+ *value = (*value)->next;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+ default:
+ g_assert_not_reached ();
+ /* Need some code here when building w/o assertions. */
+ return false;
+ }
+
+ return false;
+}
+
+double
+ccd_position_get_offset (ccd_position_t *self,
+ double extent,
+ double size)
+{
+ double ret;
+
+ g_return_val_if_fail (self, 0);
+
+ ret = 0;
+ switch (self->type) {
+ case CCD_POSITION_PERCENTAGE:
+ ret = (extent - size) * self->value / 100.;
+ break;
+ case CCD_POSITION_LENGTH:
+ ret = size;
+ break;
+ default:
+ g_assert_not_reached ();
+ /* Need some code here when building w/o assertions. */
+ return 0;
+ }
+
+ return ret;
+}
+
+#ifdef CCD_DEBUG
+
+void
+ccd_position_dump (ccd_position_t const *self)
+{
+
+}
+
+#endif /* CCD_DEBUG */
+
Added: trunk/libccd/ccd/ccd-position.h
==============================================================================
--- (empty file)
+++ trunk/libccd/ccd/ccd-position.h Thu Sep 18 10:57:25 2008
@@ -0,0 +1,84 @@
+/* The Cairo CSS Drawing Library.
+ * Copyright (C) 2008 Robert Staudinger
+ *
+ * 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 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 St, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+#ifndef CCD_POSITION_H
+#define CCD_POSITION_H
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <glib.h>
+#include <libcroco/libcroco.h>
+#include <ccd/ccd-features.h>
+
+G_BEGIN_DECLS
+
+typedef enum {
+ /* Remember to revisit all locations where a mask is used when it's
+ * being extended. */
+ CCD_POSITION_FLAG_LENGTH = 1 << 0,
+ CCD_POSITION_FLAG_PERCENTAGE = 1 << 1,
+
+ CCD_POSITION_MASK_NUMERIC = CCD_POSITION_FLAG_LENGTH |
+ CCD_POSITION_FLAG_PERCENTAGE,
+
+ CCD_POSITION_LEFT = 1 << 2,
+ CCD_POSITION_TOP = 1 << 3,
+ CCD_POSITION_RIGHT = 1 << 4,
+ CCD_POSITION_BOTTOM = 1 << 5,
+ CCD_POSITION_CENTER = 1 << 6,
+
+ CCD_POSITION_MASK_HORIZONTAL = CCD_POSITION_LEFT |
+ CCD_POSITION_RIGHT |
+ CCD_POSITION_CENTER,
+
+ CCD_POSITION_MASK_VERTICAL = CCD_POSITION_TOP |
+ CCD_POSITION_BOTTOM |
+ CCD_POSITION_CENTER,
+
+ CCD_POSITION_AUTO = 1 << 7,
+ CCD_POSITION_CONTAIN = 1 << 8,
+ CCD_POSITION_COVER = 1 << 9,
+ CCD_POSITION_MASK_AUTO = CCD_POSITION_AUTO |
+ CCD_POSITION_CONTAIN |
+ CCD_POSITION_COVER
+} ccd_position_flags_t;
+
+typedef enum {
+ CCD_POSITION_PERCENTAGE = 0,
+ CCD_POSITION_LENGTH
+} ccd_position_type_t;
+
+typedef struct {
+ ccd_position_type_t type;
+ double value;
+} ccd_position_t;
+
+bool ccd_position_parse (ccd_position_t *self, uint32_t flags, CRTerm const **value);
+
+double ccd_position_get_offset (ccd_position_t *self,
+ double extent, double size);
+
+#ifdef CCD_DEBUG
+void ccd_position_dump (ccd_position_t const *self);
+#endif
+
+G_END_DECLS
+
+#endif /* CCD_POSITION_H */
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]