[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[E-devel] Engrave patch



Hi,

here's the first of a series of patches for engrave to once again update it
with edje.
This adds the spectrum parts.

I intend to continue updating all aspects of engrave, so I ask for
permission to commit the changes directly (I already have dev access under
the username "leviathan")

Regards and Merry Christmas to all,

--
Chady 'Leviathan' Kassouf
http://chady.net/
Index: src/lib/Engrave.h
===================================================================
RCS file: /cvs/e/e17/libs/engrave/src/lib/Engrave.h,v
retrieving revision 1.14
diff -u -r1.14 Engrave.h
--- src/lib/Engrave.h	6 Sep 2006 07:31:31 -0000	1.14
+++ src/lib/Engrave.h	25 Dec 2006 17:19:42 -0000
@@ -101,6 +101,7 @@
 #include <engrave_data.h>
 #include <engrave_image.h>
 #include <engrave_font.h>
+#include <engrave_spectrum.h>
 #include <engrave_program.h>
 #include <engrave_part_state.h>
 #include <engrave_part.h>
Index: src/lib/Makefile.am
===================================================================
RCS file: /cvs/e/e17/libs/engrave/src/lib/Makefile.am,v
retrieving revision 1.12
diff -u -r1.12 Makefile.am
--- src/lib/Makefile.am	8 Feb 2006 04:38:47 -0000	1.12
+++ src/lib/Makefile.am	25 Dec 2006 17:19:42 -0000
@@ -23,6 +23,7 @@
 	engrave_enums.h \
 	engrave_file.h \
 	engrave_font.h \
+	engrave_spectrum.h \
 	engrave_style.h \
 	engrave_group.h \
 	engrave_image.h \
@@ -42,6 +43,7 @@
 	engrave_data.c \
 	engrave_file.c \
 	engrave_font.c \
+	engrave_spectrum.c \
 	engrave_style.c \
 	engrave_group.c \
 	engrave_image.c \
Index: src/lib/engrave.l
===================================================================
RCS file: /cvs/e/e17/libs/engrave/src/lib/engrave.l,v
retrieving revision 1.9
diff -u -r1.9 engrave.l
--- src/lib/engrave.l	8 Feb 2006 04:38:47 -0000	1.9
+++ src/lib/engrave.l	25 Dec 2006 17:20:16 -0000
@@ -116,6 +116,8 @@
 fit					{ KEYWORD_RETURN(FIT); }
 font				{ KEYWORD_RETURN(FONT); }
 fonts				{ KEYWORD_RETURN(FONTS); }
+spectra				{ KEYWORD_RETURN(SPECTRA); }
+spectrum			{ KEYWORD_RETURN(SPECTRUM); }
 styles				{ KEYWORD_RETURN(STYLES); }
 style				{ KEYWORD_RETURN(STYLE); }
 base				{ KEYWORD_RETURN(SBASE); }
Index: src/lib/engrave.y
===================================================================
RCS file: /cvs/e/e17/libs/engrave/src/lib/engrave.y,v
retrieving revision 1.15
diff -u -r1.15 engrave.y
--- src/lib/engrave.y	8 Feb 2006 04:38:47 -0000	1.15
+++ src/lib/engrave.y	25 Dec 2006 17:20:34 -0000
@@ -46,6 +46,7 @@
 %token SINUSOIDAL ACCELERATE DECELERATE IMAGE RECT SWALLOW
 %token NONE PLAIN OUTLINE SOFT_OUTLINE SHADOW SOFT_SHADOW 
 %token OUTLINE_SHADOW OUTLINE_SOFT_SHADOW VERTICAL HORIZONTAL BOTH
+%token SPECTRA SPECTRUM
 %left MINUS PLUS
 %left TIMES DIVIDE
 %left NEG     /* negation--unary minus */
@@ -70,6 +71,7 @@
 edjes: /* blank */
 	| images edjes 
 	| fonts edjes
+	| spectra edjes
 	| collections edjes
 	| data edjes
 	| error {
@@ -81,6 +83,30 @@
 
 collections:  COLLECTIONS OPEN_BRACE {section = GROUPS; } collection_statement CLOSE_BRACE semicolon_maybe { section = BASE; }
 	;
+
+spectra: SPECTRA OPEN_BRACE { section = SPECTRA; } spectra_statement CLOSE_BRACE semicolon_maybe { section = BASE; }
+	;
+
+spectra_statement: /* empty */
+	| spectra_statement spectrum
+	;
+
+spectrum: SPECTRUM OPEN_BRACE { section = SPECTRUM; } spectrum_statement CLOSE_BRACE semicolon_maybe { section = SPECTRA; }
+	;
+
+spectrum_statement: /* blank */
+	| spectrum_name spectrum_statement 
+	| spectrum_color spectrum_statement
+	;
+
+spectrum_name: NAME COLON STRING SEMICOLON {
+		engrave_parse_spectrum_name($3);
+	}
+	;
+
+spectrum_color: COLOR COLON exp exp exp exp exp SEMICOLON {
+                engrave_parse_spectrum_color((int)$3, (int)$4, (int)$5, (int)$6, (int)$7);
+	}
 
 fonts:  FONTS OPEN_BRACE { section = FONTS; } font_statement CLOSE_BRACE semicolon_maybe { section = BASE; }
 	;
Index: src/lib/engrave_file.c
===================================================================
RCS file: /cvs/e/e17/libs/engrave/src/lib/engrave_file.c,v
retrieving revision 1.20
diff -u -r1.20 engrave_file.c
--- src/lib/engrave_file.c	6 Sep 2006 07:31:31 -0000	1.20
+++ src/lib/engrave_file.c	25 Dec 2006 17:23:01 -0000
@@ -128,6 +128,22 @@
 }
 
 /**
+ * engrave_file_spectrum_add - add the spectrum to the engrave file.
+ * @param e: The Engrave_File to add the font too.
+ * @param es: The Engrave_Spectrum to add to the file.
+ *
+ * @return Returns no value.
+ */
+EAPI void
+engrave_file_spectrum_add(Engrave_File *e, Engrave_Spectrum *es)
+{
+  if (!e || !es) return;
+  e->spectra = evas_list_append(e->spectra, es);
+  engrave_spectrum_parent_set(es, e);
+}
+
+
+/**
  * engrave_file_style_add - add the style to the engrave file.
  * @param e: The Engrave_File to add the style too.
  * @param ef: The Engrave_Style to add to the file.
@@ -188,6 +204,20 @@
 }
 
 /**
+ * engrave_file_spectrum_last_get - returns the last spectrum in the file
+ * @param ef: The Engrave_File from which to retrieve the group
+ *
+ * @return Returns the last Engrave_Spectrum in the engrave file @a ef or NULL
+ */
+EAPI Engrave_Spectrum *
+engrave_file_spectrum_last_get(Engrave_File *ef)
+{
+  if (!ef) return NULL;
+  return evas_list_data(evas_list_last(ef->spectra));
+}
+
+
+/**
  * engrave_file_style_last_get - returns the last style in the file
  * @param ef: The Engrave_File from which to retrieve the group
  *
@@ -323,6 +353,19 @@
 }
 
 /**
+ * engrave_file_spectra_count - count the spectra in the file
+ * @param ef: The Engrave_File to check for spectra
+ * 
+ * @return Returns the number of spectra in the file, 0 otherwise
+ */
+EAPI int
+engrave_file_spectra_count(Engrave_File *ef)
+{
+  if (!ef) return 0;
+  return evas_list_count(ef->spectra);
+}
+
+/**
  * engrave_file_image_foreach - call the given function for each image object
  * @param ef: The Engrave_File for which the images should be iterated over
  * @param func: The function to call for each image
@@ -410,7 +453,6 @@
   }
 }
 
-
 /**
  * engrave_file_font_foreach - call the given function for each font object
  * @param ef: The Engrave_File for which the fonts should be iterated over
@@ -430,6 +472,29 @@
   for (l = ef->fonts; l; l = l->next) {
     Engrave_Font *font = l->data;
     if (font) func(font, data);
+  }
+}
+
+/**
+ * engrave_file_spectrum_foreach - call the given function for each spectrum object
+ * @param ef: The Engrave_File for which the spectra should be iterated over
+ * @param func: The function to call for each spectrum
+ * @param data: Any user data to pass to the given function.
+ *
+ * @return Returns no value.
+ */
+EAPI void
+engrave_file_spectrum_foreach(Engrave_File *ef, 
+                            void (*func)(Engrave_Spectrum *, void *data), 
+                            void *data)
+{
+  Evas_List *l;
+
+  if (!engrave_file_spectra_count(ef)) return;
+
+  for (l = ef->spectra; l; l = l->next) {
+    Engrave_Spectrum *es = l->data;
+    if (es) func(es, data);
   }
 }
 
Index: src/lib/engrave_file.h
===================================================================
RCS file: /cvs/e/e17/libs/engrave/src/lib/engrave_file.h,v
retrieving revision 1.13
diff -u -r1.13 engrave_file.h
--- src/lib/engrave_file.h	6 Sep 2006 07:31:31 -0000	1.13
+++ src/lib/engrave_file.h	25 Dec 2006 17:23:01 -0000
@@ -27,6 +27,7 @@
 
   Evas_List *images; /**< The list of images in the file */
   Evas_List *fonts;  /**< The list of fonts in the file  */
+  Evas_List *spectra;  /**< The list of spectra in the file  */
   Evas_List *styles;  /**< The list of styles in the file  */
   Evas_List *data;   /**< The list of data items in the file */
   Evas_List *groups; /**< The list of groups in the file */
@@ -42,12 +43,14 @@
 EAPI const char *engrave_file_font_dir_get(Engrave_File *ef);
 
 EAPI void engrave_file_font_add(Engrave_File *e, Engrave_Font *ef);
+EAPI void engrave_file_spectrum_add(Engrave_File *e, Engrave_Spectrum *es);
 EAPI void engrave_file_style_add(Engrave_File *e, Engrave_Style *es);
 EAPI void engrave_file_image_add(Engrave_File *ef, Engrave_Image *ei);
 EAPI void engrave_file_data_add(Engrave_File *ef, Engrave_Data *ed);
 EAPI void engrave_file_group_add(Engrave_File *ef, Engrave_Group *eg);
 
 EAPI Engrave_Style *engrave_file_style_last_get(Engrave_File *ef);
+EAPI Engrave_Spectrum *engrave_file_spectrum_last_get(Engrave_File *ef);
 
 EAPI Engrave_Group *engrave_file_group_last_get(Engrave_File *ef);
 EAPI Engrave_Group *engrave_file_group_by_name_find(Engrave_File *ef,
@@ -62,6 +65,7 @@
 EAPI int engrave_file_data_count(Engrave_File *ef);
 EAPI int engrave_file_groups_count(Engrave_File *ef);
 EAPI int engrave_file_fonts_count(Engrave_File *ef);
+EAPI int engrave_file_spectra_count(Engrave_File *ef);
 EAPI int engrave_file_styles_count(Engrave_File *ef);
 
 EAPI void engrave_file_image_foreach(Engrave_File *ef,
@@ -75,6 +79,9 @@
                                      void *data);
 EAPI void engrave_file_font_foreach(Engrave_File *ef,
                                     void (*func)(Engrave_Font *, void *),
+                                    void *data);
+EAPI void engrave_file_spectrum_foreach(Engrave_File *ef,
+                                    void (*func)(Engrave_Spectrum *, void *),
                                     void *data);
 EAPI void engrave_file_style_foreach(Engrave_File *ef,
                                      void (*func)(Engrave_Style *, void *),
Index: src/lib/engrave_out.c
===================================================================
RCS file: /cvs/e/e17/libs/engrave/src/lib/engrave_out.c,v
retrieving revision 1.34
diff -u -r1.34 engrave_out.c
--- src/lib/engrave_out.c	6 Sep 2006 07:31:31 -0000	1.34
+++ src/lib/engrave_out.c	25 Dec 2006 17:23:58 -0000
@@ -12,6 +12,7 @@
 static void _engrave_output_state(Engrave_Part_State *state, Engrave_Part *part, void *data);
 static void _engrave_output_image(Engrave_Image *image, void *data);
 static void _engrave_output_font(Engrave_Font *font, void *data);
+static void _engrave_output_spectrum(Engrave_Spectrum *es, void *data);
 static void _engrave_output_style(Engrave_Style *style, void *data);
 static void _engrave_output_data(Engrave_Data *data, void *udata);
 static void _engrave_output_group(Engrave_Group *group, void *data);
@@ -188,6 +189,11 @@
   engrave_out_start(out, "fonts");
   engrave_file_font_foreach(engrave_file, _engrave_output_font, out);
   engrave_out_end(out);
+  
+  /* spectra */
+  engrave_out_start(out, "spectra");
+  engrave_file_spectrum_foreach(engrave_file, _engrave_output_spectrum, out);
+  engrave_out_end(out);
 
   /* images */
   engrave_out_start(out, "images");
@@ -648,6 +654,32 @@
   engrave_out_data(out, "font", "\"%s\" \"%s\"",
           engrave_font_path_get(font), engrave_font_name_get(font));
 }
+
+static void
+_engrave_output_spectrum(Engrave_Spectrum *es, void *data)
+{
+  FILE *out;
+  int colors;
+  int i;
+
+  out = data;
+  engrave_out_start(out, "spectrum");
+  engrave_out_data(out, "name", "\"%s\"", engrave_spectrum_name_get(es));
+  
+  colors = engrave_spectrum_color_count(es);
+  for (i=0; i<colors; i++) {
+	  Engrave_Spectrum_Color *esc;
+	  esc = engrave_spectrum_color_nth(es, i);
+	  if (esc)
+		  engrave_out_data(out, "color", "%d %d %d %d %d",
+				  esc->r, esc->g, esc->b, esc->a, esc->d);
+  }
+
+  engrave_out_end(out);
+
+  
+}
+
 
 static void
 _engrave_output_style(Engrave_Style *style, void *data)
Index: src/lib/engrave_parse.c
===================================================================
RCS file: /cvs/e/e17/libs/engrave/src/lib/engrave_parse.c,v
retrieving revision 1.14
diff -u -r1.14 engrave_parse.c
--- src/lib/engrave_parse.c	8 Feb 2006 04:38:47 -0000	1.14
+++ src/lib/engrave_parse.c	25 Dec 2006 17:23:58 -0000
@@ -86,6 +86,28 @@
 }
 
 void
+engrave_parse_spectrum_name(char *name)
+{
+  Engrave_Spectrum *es;
+  es = engrave_spectrum_new(name);
+  engrave_file_spectrum_add(engrave_file, es);
+  engrave_spectrum_parent_set(es, engrave_file);
+}
+
+void
+engrave_parse_spectrum_color(int r, int g, int b, int a, int d)
+{
+  Engrave_Spectrum *es;
+  Engrave_Spectrum_Color *esc;
+
+  esc = engrave_spectrum_color_new(r, g, b, a, d);
+  es = engrave_file_spectrum_last_get(engrave_file);
+  
+  engrave_spectrum_color_add(es, esc);
+  
+}
+
+void
 engrave_parse_group_min(int w, int h)
 {
   Engrave_Group *group;
@@ -383,6 +405,7 @@
   state = engrave_part_state_last_get(part);
   engrave_part_state_min_size_set(state, w, h);
 }
+
 
 void
 engrave_parse_state_fixed(double w, double h)
Index: src/lib/engrave_parse.h
===================================================================
RCS file: /cvs/e/e17/libs/engrave/src/lib/engrave_parse.h,v
retrieving revision 1.6
diff -u -r1.6 engrave_parse.h
--- src/lib/engrave_parse.h	6 Sep 2006 07:31:31 -0000	1.6
+++ src/lib/engrave_parse.h	25 Dec 2006 17:23:58 -0000
@@ -21,6 +21,9 @@
 void engrave_parse_style_base(char * base);
 void engrave_parse_style_tag(char * key, char * val);
 
+void engrave_parse_spectrum_name(char * name);
+void engrave_parse_spectrum_color(int r, int g, int b, int a, int d);
+
 void engrave_parse_base(char *base);
 
 void engrave_parse_part();

Attachment: engrave_spectrum.tar.gz
Description: GNU Zip compressed data