murrine r144 - in trunk: . src
- From: acimitan svn gnome org
- To: svn-commits-list gnome org
- Subject: murrine r144 - in trunk: . src
- Date: Tue, 10 Mar 2009 18:17:11 +0000 (UTC)
Author: acimitan
Date: Tue Mar 10 18:17:11 2009
New Revision: 144
URL: http://svn.gnome.org/viewvc/murrine?rev=144&view=rev
Log:
2009-03-10 Andrea Cimitan <andrea cimitan gmail com
* src/cairo-support.c (murrine_set_gradient),
(murrine_set_border_gradient):
* src/cairo-support.h:
* src/murrine_draw.c (murrine_draw_button), (murrine_draw_entry),
(murrine_draw_entry_progress), (murrine_register_style_murrine):
* src/murrine_style.c (murrine_style_draw_box):
* src/murrine_types.h:
Two interesting things:
1) Added set_border_gradient, useful in the future but not enabled yet
2) Draw the entry progressbar, since GTK+ 2.16.0
Modified:
trunk/ChangeLog
trunk/src/cairo-support.c
trunk/src/cairo-support.h
trunk/src/murrine_draw.c
trunk/src/murrine_style.c
trunk/src/murrine_types.h
Modified: trunk/src/cairo-support.c
==============================================================================
--- trunk/src/cairo-support.c (original)
+++ trunk/src/cairo-support.c Tue Mar 10 18:17:11 2009
@@ -763,7 +763,7 @@
murrine_set_gradient (cairo_t *cr,
const MurrineRGB *color,
MurrineGradients mrn_gradient,
- double x, double y, int width, int height,
+ int x, int y, int width, int height,
boolean gradients, boolean alpha)
{
double alpha_value = 1.0;
@@ -803,6 +803,26 @@
}
void
+murrine_set_border_gradient (cairo_t *cr,
+ const MurrineRGB *color,
+ double highlight,
+ int x, int y, int width, int height)
+{
+ cairo_pattern_t *pat;
+
+ MurrineRGB top_shade, bottom_shade;
+ murrine_shade (color, highlight, &top_shade);
+ murrine_shade (color, 1.0/highlight, &bottom_shade);
+
+ pat = cairo_pattern_create_linear (x, y, width+x, height+y);
+ murrine_pattern_add_color_stop_rgb (pat, 0.0, &top_shade);
+ murrine_pattern_add_color_stop_rgb (pat, 1.0, &bottom_shade);
+
+ cairo_set_source (cr, pat);
+ cairo_pattern_destroy (pat);
+}
+
+void
rotate_mirror_translate (cairo_t *cr,
double radius, double x, double y,
boolean mirror_horizontally, boolean mirror_vertically)
Modified: trunk/src/cairo-support.h
==============================================================================
--- trunk/src/cairo-support.h (original)
+++ trunk/src/cairo-support.h Tue Mar 10 18:17:11 2009
@@ -88,9 +88,14 @@
G_GNUC_INTERNAL void murrine_set_gradient (cairo_t *cr,
const MurrineRGB *color,
MurrineGradients mrn_gradient,
- double x, double y, int width, int height,
+ int x, int y, int width, int height,
boolean gradients, boolean alpha);
+G_GNUC_INTERNAL void murrine_set_border_gradient (cairo_t *cr,
+ const MurrineRGB *color,
+ double highlight,
+ int x, int y, int width, int height);
+
G_GNUC_INTERNAL void murrine_draw_glaze (cairo_t *cr,
const MurrineRGB *fill,
double glow_shade,
Modified: trunk/src/murrine_draw.c
==============================================================================
--- trunk/src/murrine_draw.c (original)
+++ trunk/src/murrine_draw.c Tue Mar 10 18:17:11 2009
@@ -239,6 +239,7 @@
/* Draw the border */
murrine_set_color_rgb (cr, &border);
+ //murrine_set_border_gradient (cr, &border, widget->disabled ? 1.0 : widget->active ? 0.9 : 1.1, 0, yos+0.5, 0, height-(yos*2)-1);
murrine_rounded_rectangle (cr, xos+0.5, yos+0.5, width-(xos*2)-1, height-(yos*2)-1, widget->roundness, widget->corners);
cairo_stroke (cr);
}
@@ -285,11 +286,86 @@
/* Draw the border */
murrine_set_color_rgb (cr, widget->focus ? &colors->spot[2] : border);
+ //murrine_set_border_gradient (cr, widget->focus ? &colors->spot[2] : border, widget->disabled ? 1.0 : 0.9, 0, 1, 0, height-3);
murrine_rounded_rectangle (cr, 1, 1, width-3, height-3, radius, widget->corners);
cairo_stroke (cr);
}
static void
+murrine_draw_entry_progress (cairo_t *cr,
+ const MurrineColors *colors,
+ const WidgetParameters *widget,
+ const EntryProgressParameters *progress,
+ int x, int y, int width, int height)
+{
+ MurrineRGB border;
+ MurrineRGB fill;
+ gint entry_width, entry_height;
+ double entry_radius;
+ double radius;
+
+ cairo_save (cr);
+
+ fill = colors->bg[widget->state_type];
+ murrine_shade (&fill, 0.9, &border);
+
+ if (progress->max_size_known)
+ {
+ entry_width = progress->max_size.width+progress->border.left+progress->border.right;
+ entry_height = progress->max_size.height+progress->border.top+progress->border.bottom;
+ entry_radius = MIN (widget->roundness, MIN ((entry_width-4.0)/2.0, (entry_height-4.0)/2.0));
+ }
+ else
+ {
+ entry_radius = widget->roundness;
+ }
+
+ radius = MAX (0, entry_radius+1.0-MAX (MAX (progress->border.left, progress->border.right),
+ MAX (progress->border.top, progress->border.bottom)));
+
+ if (progress->max_size_known)
+ {
+ /* Clip to the max size, and then draw a (larger) rectangle ... */
+ clearlooks_rounded_rectangle (cr, progress->max_size.x,
+ progress->max_size.y,
+ progress->max_size.width,
+ progress->max_size.height,
+ radius,
+ MRN_CORNER_ALL);
+ cairo_clip (cr);
+
+ /* We just draw wider by one pixel ... */
+ murrine_set_color_rgb (cr, &fill);
+ cairo_rectangle (cr, x, y+1, width, height-2);
+ cairo_fill (cr);
+
+ cairo_set_line_width (cr, 1.0);
+ murrine_set_color_rgb (cr, &border);
+ cairo_rectangle (cr, x-0.5, y+0.5, width+1, height-1);
+ cairo_stroke (cr);
+ }
+ else
+ {
+ clearlooks_rounded_rectangle (cr, x, y, width+10, height+10, radius, MRN_CORNER_ALL);
+ cairo_clip (cr);
+ clearlooks_rounded_rectangle (cr, x-10, y-10, width+10, height+10, radius, MRN_CORNER_ALL);
+ cairo_clip (cr);
+
+
+ murrine_set_color_rgb (cr, &fill);
+ clearlooks_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, MRN_CORNER_ALL);
+ cairo_fill (cr);
+
+ cairo_set_line_width (cr, 1.0);
+ murrine_set_color_rgb (cr, &border);
+ clearlooks_rounded_rectangle (cr, x+0.5, y+0.5, width-1.0, height-1.0, radius, MRN_CORNER_ALL);
+ cairo_stroke (cr);
+ }
+
+ cairo_restore (cr);
+}
+
+static void
murrine_draw_spinbutton_down (cairo_t *cr,
const MurrineColors *colors,
const WidgetParameters *widget,
@@ -2221,6 +2297,7 @@
functions->draw_progressbar_trough = murrine_draw_progressbar_trough;
functions->draw_progressbar_fill = murrine_draw_progressbar_fill;
functions->draw_entry = murrine_draw_entry;
+ functions->draw_entry_progress = murrine_draw_entry_progress;
functions->draw_slider_handle = murrine_draw_slider_handle;
functions->draw_spinbutton_down = murrine_draw_spinbutton_down;
functions->draw_optionmenu = murrine_draw_optionmenu;
Modified: trunk/src/murrine_style.c
==============================================================================
--- trunk/src/murrine_style.c (original)
+++ trunk/src/murrine_style.c Tue Mar 10 18:17:11 2009
@@ -1029,6 +1029,128 @@
10+(int)(elapsed*10.0) % 10);
#endif
}
+ else if (DETAIL ("entry-progress"))
+ {
+ WidgetParameters params;
+ EntryProgressParameters progress;
+
+ murrine_set_widget_parameters (widget, style, state_type, ¶ms);
+
+ progress.max_size_known = FALSE;
+ progress.max_size.x = 0;
+ progress.max_size.y = 0;
+ progress.max_size.width = 0;
+ progress.max_size.height = 0;
+ progress.border.left = style->xthickness;
+ progress.border.right = style->xthickness;
+ progress.border.top = style->ythickness;
+ progress.border.bottom = style->ythickness;
+
+ if (MRN_IS_ENTRY (widget))
+ {
+ GtkBorder *border;
+ /* Try to retrieve the style property. */
+ gtk_widget_style_get (widget,
+ "progress-border", &border,
+ NULL);
+
+ if (border)
+ {
+ progress.border = *border;
+ gtk_border_free (border);
+ }
+
+ /* We got an entry, but well, we may not be drawing to
+ * this particular widget ... it may not even be realized.
+ * Also, we need to be drawing on a window obviously ... */
+ if (GTK_WIDGET_REALIZED (widget) &&
+ GDK_IS_WINDOW (window) &&
+ gdk_window_is_visible (widget->window))
+ {
+ /* Assumptions done by this code:
+ * - GtkEntry has some nested windows.
+ * - widget->window is the entries window
+ * - widget->window is the size of the entry part
+ * (and not larger)
+ * - only one layer of subwindows
+ * These should be true with any GTK+ 2.x version.
+ */
+
+ if (widget->window == window)
+ {
+ progress.max_size_known = TRUE;
+ gdk_drawable_get_size (widget->window,
+ &progress.max_size.width,
+ &progress.max_size.height);
+
+ }
+ else
+ {
+ GdkWindow *parent;
+ parent = gdk_window_get_parent (window);
+ if (widget->window == parent)
+ {
+ gint pos_x, pos_y;
+ /* widget->window is the parent window
+ * of the current one. This means we can
+ * calculate the correct offsets. */
+ gdk_window_get_position (window, &pos_x, &pos_y);
+ progress.max_size.x = -pos_x;
+ progress.max_size.y = -pos_y;
+
+ progress.max_size_known = TRUE;
+ gdk_drawable_get_size (widget->window,
+ &progress.max_size.width,
+ &progress.max_size.height);
+ } /* Nothing we can do in this case ... */
+ }
+
+ /* Now, one more thing needs to be done. If interior-focus
+ * is off, then the entry may be a bit smaller. */
+ if (progress.max_size_known && GTK_WIDGET_HAS_FOCUS (widget))
+ {
+ gboolean interior_focus = TRUE;
+ gint focus_line_width = 1;
+
+ gtk_widget_style_get (widget,
+ "interior-focus", &interior_focus,
+ "focus-line-width", &focus_line_width,
+ NULL);
+
+ if (!interior_focus)
+ {
+ progress.max_size.x += focus_line_width;
+ progress.max_size.y += focus_line_width;
+ progress.max_size.width -= 2*focus_line_width;
+ progress.max_size.height -= 2*focus_line_width;
+ }
+ }
+
+ if (progress.max_size_known)
+ {
+ progress.max_size.x += progress.border.left;
+ progress.max_size.y += progress.border.top;
+ progress.max_size.width -= progress.border.left + progress.border.right;
+ progress.max_size.height -= progress.border.top + progress.border.bottom;
+
+ /* Now test that max_size.height == height, if that
+ * fails, something has gone wrong ... so then throw away
+ * the max_size information. */
+ if (progress.max_size.height != height)
+ {
+ progress.max_size_known = FALSE;
+ progress.max_size.x = 0;
+ progress.max_size.y = 0;
+ progress.max_size.width = 0;
+ progress.max_size.height = 0;
+ }
+ }
+ }
+ }
+
+ STYLE_FUNCTION(draw_entry_progress) (cr, colors, ¶ms, &progress,
+ x, y, width, height);
+ }
else if (DETAIL ("hscale") || DETAIL ("vscale"))
{
WidgetParameters params;
Modified: trunk/src/murrine_types.h
==============================================================================
--- trunk/src/murrine_types.h (original)
+++ trunk/src/murrine_types.h Tue Mar 10 18:17:11 2009
@@ -255,6 +255,18 @@
typedef struct
{
+ /* The maximum size of the fill. Calcualted from the entries allocation,
+ * and other information. Relative to the drawn position.
+ */
+ GdkRectangle max_size;
+ gboolean max_size_known;
+ /* The border around the bar. This can be used for radius calculations.
+ */
+ GtkBorder border;
+} EntryProgressParameters;
+
+typedef struct
+{
int linepos;
} OptionMenuParameters;
@@ -374,6 +386,12 @@
const WidgetParameters *widget,
int x, int y, int width, int height);
+ void (*draw_entry_progress) (cairo_t *cr,
+ const MurrineColors *colors,
+ const WidgetParameters *widget,
+ const EntryProgressParameters *progress,
+ int x, int y, int width, int height);
+
void (*draw_spinbutton) (cairo_t *cr,
const MurrineColors *colors,
const WidgetParameters *widget,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]