[goffice] fixed unicolor gradients brightness
- From: Jean Bréfort <jbrefort src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [goffice] fixed unicolor gradients brightness
- Date: Sun, 27 Sep 2009 06:41:17 +0000 (UTC)
commit cc3480ed960d0d613a29e0c5c6e442e6543bb46a
Author: Jean Brefort <jean brefort normalesup org>
Date: Sun Sep 27 08:41:05 2009 +0200
fixed unicolor gradients brightness
ChangeLog | 6 ++++++
NEWS | 3 +++
goffice/utils/go-style-prefs.ui | 6 +++++-
goffice/utils/go-style.c | 12 +++++++++---
4 files changed, 23 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 251f526..50666d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-09-27 Jean Brefort <jean brefort normalesup org>
+
+ * goffice/utils/go-style-prefs.ui: fixed unicolor gradients brightness.
+ * goffice/utils/go-style.c (fill_gradient_init),
+ (cb_fill_type_changed), (go_style_set_fill_brightness): ditto.
+
2009-09-25 Jean Brefort <jean brefort normalesup org>
* docs/reference/goffice-0.8-sections.txt: added a few more entries.
diff --git a/NEWS b/NEWS
index dd822a6..a965d8b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
goffice 0.7.14:
+Jean:
+ * Fix unicolor gradient brightness.
+
--------------------------------------------------------------------------
goffice 0.7.13:
diff --git a/goffice/utils/go-style-prefs.ui b/goffice/utils/go-style-prefs.ui
index bbbaced..e41ba75 100644
--- a/goffice/utils/go-style-prefs.ui
+++ b/goffice/utils/go-style-prefs.ui
@@ -1,5 +1,6 @@
<?xml version="1.0"?>
<interface>
+ <!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkAdjustment" id="adjustment1">
<property name="upper">30</property>
@@ -542,7 +543,10 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">adjustment3</property>
- <property name="inverted">True</property>
+ <property name="upper_stepper_sensitivity">off</property>
+ <property name="show_fill_level">True</property>
+ <property name="restrict_to_fill_level">False</property>
+ <property name="fill_level">0</property>
<property name="draw_value">False</property>
</object>
<packing>
diff --git a/goffice/utils/go-style.c b/goffice/utils/go-style.c
index 9ba7d91..5748f88 100644
--- a/goffice/utils/go-style.c
+++ b/goffice/utils/go-style.c
@@ -414,6 +414,7 @@ fill_gradient_init (StylePrefState *state)
state->fill.gradient.brightness = brightness =
go_gtk_builder_get_widget (state->gui, "fill_brightness_scale");
+ gtk_range_set_value (GTK_RANGE (brightness), state->style->fill.gradient.brightness);
label = go_gtk_builder_get_widget (state->gui, "fill_brightness_label");
gtk_size_group_add_widget (state->fill.size_group, label);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), brightness);
@@ -595,6 +596,9 @@ cb_fill_type_changed (GtkWidget *menu, StylePrefState *state)
index = CLAMP (gtk_combo_box_get_active (GTK_COMBO_BOX (menu)), 0, (int) G_N_ELEMENTS (fill_infos) - 1);
+ if (state->style->fill.type == GO_STYLE_FILL_GRADIENT)
+ /* we need to set brightness to 0 because of unicolor gradients recognition */
+ gtk_range_set_value (GTK_RANGE (state->fill.gradient.brightness), 0.);
state->style->fill.type = fill_infos[index].type;
state->style->fill.auto_type = FALSE;
set_style (state);
@@ -1996,15 +2000,17 @@ go_style_set_font (GOStyle *style, GOFont const *font)
void
go_style_set_fill_brightness (GOStyle *style, float brightness)
{
+ double limit;
g_return_if_fail (GO_IS_STYLE (style));
g_return_if_fail (style->fill.type == GO_STYLE_FILL_GRADIENT);
brightness = CLAMP (brightness, 0, 100.0);
+ limit = (GO_COLOR_UINT_R (style->fill.pattern.back) + GO_COLOR_UINT_G (style->fill.pattern.back) + GO_COLOR_UINT_B (style->fill.pattern.back)) / 7.65;
style->fill.gradient.brightness = brightness;
- style->fill.pattern.fore = (brightness < 50.)
- ? GO_COLOR_INTERPOLATE(style->fill.pattern.back, GO_COLOR_WHITE, 1. - brightness / 50.)
- : GO_COLOR_INTERPOLATE(style->fill.pattern.back, GO_COLOR_BLACK, brightness / 50. - 1.);
+ style->fill.pattern.fore = (brightness <= limit && limit > 0.)
+ ? GO_COLOR_INTERPOLATE(style->fill.pattern.back, GO_COLOR_BLACK, 1. - brightness / limit)
+ : GO_COLOR_INTERPOLATE(style->fill.pattern.back, GO_COLOR_WHITE, (brightness - limit) / (100. - limit));
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]