aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2018-10-27 23:29:14 +0200
committerThomas White <taw@bitwiz.me.uk>2018-10-27 23:29:14 +0200
commit7e36b2a0fc2180d8d319b54159a6680801247ba4 (patch)
tree560421b93e8372aebda2b48c68a0712a41e2fee7
parent7d585a94af8d021c6d0df0cfd0fe25b6aab367ae (diff)
Allow alpha values for stylesheet colours
Get rid of GRAD_NOBG, because it's now handled by transparency
-rw-r--r--data/stylesheeteditor.ui10
-rw-r--r--src/frame.h3
-rw-r--r--src/render.c5
-rw-r--r--src/sc_interp.c2
-rw-r--r--src/stylesheet_editor.c34
5 files changed, 24 insertions, 30 deletions
diff --git a/data/stylesheeteditor.ui b/data/stylesheeteditor.ui
index 3e64d3d..19723bb 100644
--- a/data/stylesheeteditor.ui
+++ b/data/stylesheeteditor.ui
@@ -210,6 +210,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="use_alpha">True</property>
<signal name="color-set" handler="narrative_fgcol_sig" swapped="no"/>
</object>
<packing>
@@ -251,7 +252,6 @@
<item id="flat" translatable="yes">Flat colour</item>
<item id="horiz" translatable="yes">Horizontal gradient</item>
<item id="vert" translatable="yes">Vertical gradient</item>
- <item id="none" translatable="yes">None</item>
</items>
<signal name="changed" handler="narrative_bg_sig" swapped="no"/>
</object>
@@ -266,6 +266,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="use_alpha">True</property>
<signal name="color-set" handler="narrative_bg_sig" swapped="no"/>
</object>
<packing>
@@ -279,6 +280,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="use_alpha">True</property>
<signal name="color-set" handler="narrative_bg_sig" swapped="no"/>
</object>
<packing>
@@ -717,6 +719,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="use_alpha">True</property>
<signal name="color-set" handler="slide_bg_sig" swapped="no"/>
</object>
<packing>
@@ -730,6 +733,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="use_alpha">True</property>
<signal name="color-set" handler="slide_bg_sig" swapped="no"/>
</object>
<packing>
@@ -822,6 +826,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="use_alpha">True</property>
<signal name="color-set" handler="frame_fgcol_sig" swapped="no"/>
</object>
<packing>
@@ -863,7 +868,6 @@
<item id="flat" translatable="yes">Flat colour</item>
<item id="horiz" translatable="yes">Horizontal gradient</item>
<item id="vert" translatable="yes">Vertical gradient</item>
- <item id="none" translatable="yes">None</item>
</items>
<signal name="changed" handler="frame_bg_sig" swapped="no"/>
</object>
@@ -878,6 +882,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="use_alpha">True</property>
<signal name="color-set" handler="frame_bg_sig" swapped="no"/>
</object>
<packing>
@@ -891,6 +896,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="use_alpha">True</property>
<signal name="color-set" handler="frame_bg_sig" swapped="no"/>
</object>
<packing>
diff --git a/src/frame.h b/src/frame.h
index b786065..f52c6e6 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -42,8 +42,7 @@ typedef enum
{
GRAD_NONE,
GRAD_HORIZ,
- GRAD_VERT,
- GRAD_NOBG
+ GRAD_VERT
} GradientType;
enum para_type
diff --git a/src/render.c b/src/render.c
index 8aa7dbe..f9f4cca 100644
--- a/src/render.c
+++ b/src/render.c
@@ -48,8 +48,6 @@ static void do_background(cairo_t *cr, struct frame *fr)
{
cairo_pattern_t *patt = NULL;
- if ( fr->grad == GRAD_NOBG ) return; /* Should not end up here */
-
cairo_new_path(cr);
cairo_rectangle(cr, 0.0, 0.0, fr->w, fr->h);
@@ -86,9 +84,6 @@ static void do_background(cairo_t *cr, struct frame *fr)
cairo_set_source(cr, patt);
break;
- case GRAD_NOBG:
- break;
-
}
cairo_fill(cr);
diff --git a/src/sc_interp.c b/src/sc_interp.c
index 91775f5..7bbfeeb 100644
--- a/src/sc_interp.c
+++ b/src/sc_interp.c
@@ -584,7 +584,7 @@ SCInterpreter *sc_interp_new(PangoContext *pc, PangoLanguage *lang,
st->bgcol2[1] = 1.0;
st->bgcol2[2] = 1.0;
st->bgcol2[3] = 1.0;
- st->bggrad = GRAD_NOBG;
+ st->bggrad = GRAD_NONE;
scin->lang = lang;
/* The "ultimate" default font */
diff --git a/src/stylesheet_editor.c b/src/stylesheet_editor.c
index bab784a..753918a 100644
--- a/src/stylesheet_editor.c
+++ b/src/stylesheet_editor.c
@@ -117,16 +117,10 @@ static void set_bg_from_ss(Stylesheet *ss, const char *path, GtkWidget *wcol,
GdkRGBA rgba;
found = 1;
if ( gdk_rgba_parse(&rgba, result) == TRUE ) {
- if ( rgba.alpha == 0.0 ) {
- gtk_combo_box_set_active_id(GTK_COMBO_BOX(wgrad), "none");
- gtk_widget_set_sensitive(wcol, FALSE);
- gtk_widget_set_sensitive(wcol2, FALSE);
- } else {
- gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(wcol), &rgba);
- gtk_combo_box_set_active_id(GTK_COMBO_BOX(wgrad), "flat");
- gtk_widget_set_sensitive(wcol, TRUE);
- gtk_widget_set_sensitive(wcol2, FALSE);
- }
+ gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(wcol), &rgba);
+ gtk_combo_box_set_active_id(GTK_COMBO_BOX(wgrad), "flat");
+ gtk_widget_set_sensitive(wcol, TRUE);
+ gtk_widget_set_sensitive(wcol2, FALSE);
} else {
fprintf(stderr, _("Failed to parse colour: %s\n"), result);
}
@@ -159,8 +153,14 @@ static void set_bg_from_ss(Stylesheet *ss, const char *path, GtkWidget *wcol,
}
if ( !found ) {
- gtk_combo_box_set_active_id(GTK_COMBO_BOX(wgrad), "none");
- gtk_widget_set_sensitive(wcol, FALSE);
+ GdkRGBA rgba;
+ rgba.red = 1.0;
+ rgba.green = 1.0;
+ rgba.blue = 1.0;
+ rgba.alpha = 0.0;
+ gtk_combo_box_set_active_id(GTK_COMBO_BOX(wgrad), "flat");
+ gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(wcol), &rgba);
+ gtk_widget_set_sensitive(wcol, TRUE);
gtk_widget_set_sensitive(wcol2, FALSE);
}
}
@@ -215,7 +215,6 @@ static GradientType id_to_gradtype(const gchar *id)
if ( strcmp(id, "flat") == 0 ) return GRAD_NONE;
if ( strcmp(id, "horiz") == 0 ) return GRAD_HORIZ;
if ( strcmp(id, "vert") == 0 ) return GRAD_VERT;
- if ( strcmp(id, "none") == 0 ) return GRAD_NOBG;
return GRAD_NONE;
}
@@ -234,7 +233,9 @@ static void update_bg(struct presentation *p, const char *style_name,
g = id_to_gradtype(id);
gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(col1w), &rgba);
+ if ( rgba.alpha < 0.000001 ) rgba.alpha = 0.0;
col1 = gdk_rgba_to_string(&rgba);
+ printf("got colour %s\n", col1);
gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(col2w), &rgba);
col2 = gdk_rgba_to_string(&rgba);
@@ -243,13 +244,6 @@ static void update_bg(struct presentation *p, const char *style_name,
switch ( g ) {
- case GRAD_NOBG :
- stylesheet_set(p->stylesheet, style_name, "bgcol",
- "rgba(0,0,0,0)");
- stylesheet_delete(p->stylesheet, style_name, "bggradv");
- stylesheet_delete(p->stylesheet, style_name, "bggradh");
- break;
-
case GRAD_NONE :
stylesheet_set(p->stylesheet, style_name, "bgcol",
col1);