summaryrefslogtreecommitdiff
diff options
-rw-r--r--plugins/unityshell/resources/emblem_apps.svg20
-rw-r--r--unity-shared/IconLoader.cpp88
2 files changed, 61 insertions, 47 deletions
diff --git a/plugins/unityshell/resources/emblem_apps.svg b/plugins/unityshell/resources/emblem_apps.svg
index 53bfec85e..6b3937745 100644
--- a/plugins/unityshell/resources/emblem_apps.svg
+++ b/plugins/unityshell/resources/emblem_apps.svg
@@ -37,20 +37,20 @@
id="namedview21"
showgrid="false"
inkscape:zoom="16.857143"
- inkscape:cx="7.0207627"
- inkscape:cy="7"
+ inkscape:cx="7.0207628"
+ inkscape:cy="7.0000001"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:window-maximized="0"
inkscape:current-layer="Layer_1" />
<path
- d="m 8,5 v 8.000556 C 8,13.5508 7.531,14 6.982,14 H 5.998 C 5.448,14 5,13.5508 5,13.000556 V 5 h 3 z"
+ d="m 9,5 v 8.000556 C 9,13.5508 8.531,14 7.982,14 H 6.998 C 6.448,14 6,13.5508 6,13.000556 V 5 h 3 z"
id="path3"
inkscape:connector-curvature="0"
style="fill:#dc4a26" />
<g
id="g5"
- transform="matrix(1,0,0,1.0003848,-0.5,0.49480569)">
+ transform="matrix(1,0,0,1.0003848,0.5,0.49480569)">
<path
d="m 4.5,4.504 h -2 v -1 h 2 V 1.505 c 0,-0.55 -0.45,-1 -1,-1 H 1.501 c -0.55,0 -1,0.45 -1,1 L 0.5,12.501 c 0,0.55 0.45,0.999 1,0.999 h 1.999 c 0.55,0 1,-0.449 1,-0.999 V 10.5 L 2.5,10.502 v -1 L 4.499,9.5 V 7.503 H 2.5 v -1 h 2"
id="path7"
@@ -58,32 +58,32 @@
style="fill:#dc4a26" />
</g>
<path
- d="m 4,7.003 v -1 l 0,0 v 1 l 0,0 z"
+ d="m 5,7.003 v -1 l 0,0 v 1 l 0,0 z"
id="path9"
inkscape:connector-curvature="0"
style="fill:#dc4a26" />
<path
- d="m 4,10.002 v -1 h 0 l 0,1 0,0 z"
+ d="m 5,10.002 v -1 h 0 l 0,1 0,0 z"
id="path11"
inkscape:connector-curvature="0"
style="fill:#dc4a26" />
<path
- d="m 4,12.999 0,0 0,0 0,0 0,0 z"
+ d="m 5,12.999 0,0 0,0 0,0 0,0 z"
id="path13"
inkscape:connector-curvature="0"
style="fill:#dc4a26" />
<path
- d="m 11.366,1 v 1.234223 c 0.236,0.1107508 0.434,0.3063108 0.434,0.5397855 0,0.3532053 -0.358,0.6385632 -0.8,0.6385632 -0.442,0 -0.8,-0.2853579 -0.8,-0.6385632 0,-0.2334747 0.198,-0.4290347 0.433,-0.5397855 V 1 C 10.16,1.4629583 9,2.8089299 9,3.4035919 9,4.2856074 10.116,5 11,5 11.884,5 13,4.2856074 13,3.4035919 13,2.8089299 11.84,1.4629583 11.366,1 z"
+ d="m 12.366,1 v 1.234223 c 0.236,0.1107508 0.434,0.3063108 0.434,0.5397855 0,0.3532053 -0.358,0.6385632 -0.8,0.6385632 -0.442,0 -0.8,-0.2853579 -0.8,-0.6385632 0,-0.2334747 0.198,-0.4290347 0.433,-0.5397855 V 1 C 11.16,1.4629583 10,2.8089299 10,3.4035919 10,4.2856074 11.116,5 12,5 12.884,5 14,4.2856074 14,3.4035919 14,2.8089299 12.84,1.4629583 12.366,1 z"
id="path15"
inkscape:connector-curvature="0"
style="fill:#dc4a26" />
<path
- d="M 5,4 6.5465155,1 8,4 H 5 z"
+ d="M 6,4 7.5465155,1 9,4 H 6 z"
id="path17"
inkscape:connector-curvature="0"
style="fill:#dc4a26" />
<path
- d="m 13,6 v 7.000625 C 13,13.550832 12.55,14 12,14 H 10 C 9.45,14 9,13.550832 9,13.000625 V 6 h 4 z"
+ d="m 14,6 v 7.000625 C 14,13.550832 13.55,14 13,14 h -2 c -0.55,0 -1,-0.449168 -1,-0.999375 V 6 h 4 z"
id="path19"
inkscape:connector-curvature="0"
style="fill:#dc4a26" />
diff --git a/unity-shared/IconLoader.cpp b/unity-shared/IconLoader.cpp
index 86b7785ae..a5aca60ea 100644
--- a/unity-shared/IconLoader.cpp
+++ b/unity-shared/IconLoader.cpp
@@ -302,6 +302,7 @@ private:
{
const int SHADOW_BOTTOM_PADDING = 2;
const int SHADOW_SIDE_PADDING = 1;
+ const int EMBLEM_PADDING = 2;
int icon_w = gdk_pixbuf_get_width(result);
int icon_h = gdk_pixbuf_get_height(result);
@@ -335,9 +336,16 @@ private:
pango_layout_set_font_description(layout, desc.get());
pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
- // magic constant for the text width based on the white curve
- double max_text_width = has_emblem ?
- pixbuf_width * 0.72 : pixbuf_width;
+ double belt_w = static_cast<double>(pixbuf_width - SHADOW_SIDE_PADDING * 2);
+ double belt_h = static_cast<double>(pixbuf_height - SHADOW_BOTTOM_PADDING);
+
+ double max_text_width = belt_w;
+ if (has_emblem)
+ {
+ const double CURVE_MID_X = 0.4 * (belt_h / 20.0 * 24.0);
+ const int category_pb_w = gdk_pixbuf_get_width(category_pixbuf);
+ max_text_width = belt_w - CURVE_MID_X - category_pb_w - EMBLEM_PADDING;
+ }
pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
@@ -352,7 +360,7 @@ private:
dpi == -1 ? 96.0f : dpi/(float) PANGO_SCALE);
pango_layout_context_changed(layout);
- // find proper font size (can we do this before the rotation?)
+ // find proper font size
int text_width, text_height;
pango_layout_get_pixel_size(layout, &text_width, nullptr);
while (text_width > max_text_width && font_size > MIN_FONT_SIZE)
@@ -374,23 +382,23 @@ private:
const double ORANGE_G = 0.28235;
const double ORANGE_B = 0.07843;
- double belt_w = static_cast<double>(pixbuf_width - SHADOW_SIDE_PADDING * 2);
- double belt_h = static_cast<double>(pixbuf_height - SHADOW_BOTTOM_PADDING);
-
// translate to make space for the shadow
cairo_save(cr.get());
cairo_translate(cr.get(), 1.0, 1.0);
cairo_set_source_rgba(cr.get(), ORANGE_R, ORANGE_G, ORANGE_B, 1.0);
+ // base ribbon
cairo_rectangle(cr.get(), 0.0, 0.0, belt_w, belt_h);
cairo_fill_preserve(cr.get());
+ // hightlight on left edge
std::shared_ptr<cairo_pattern_t> pattern(
cairo_pattern_create_linear(0.0, 0.0, belt_w, 0.0),
cairo_pattern_destroy);
cairo_pattern_add_color_stop_rgba(pattern.get(), 0.0, 1.0, 1.0, 1.0, 0.235294);
cairo_pattern_add_color_stop_rgba(pattern.get(), 0.02, 1.0, 1.0, 1.0, 0.0);
+ // and on right one
if (!has_emblem)
{
cairo_pattern_add_color_stop_rgba(pattern.get(), 0.98, 1.0, 1.0, 1.0, 0.0);
@@ -403,27 +411,38 @@ private:
if (has_emblem)
{
- // paint the curve
- const double CURVE_START_XPOS = 0.631163; // 0.651163
- const double CURVE_CP1_XPOS = CURVE_START_XPOS + 0.068023;
- const double CURVE_CP2_XPOS = CURVE_START_XPOS + 0.07;
- const double CURVE_CP3_XPOS = CURVE_START_XPOS + 0.102965;
- const double CURVE_CP4_XPOS = CURVE_START_XPOS + 0.161511;
- const double CURVE_CP5_XPOS = CURVE_START_XPOS + 0.197093;
- const double CURVE_END_XPOS = CURVE_START_XPOS + 0.265779;
-
- const double CURVE_START_X = CURVE_START_XPOS * belt_w;
+ // size of the emblem
+ const int category_pb_w = gdk_pixbuf_get_width(category_pixbuf);
+ const int category_pb_h = gdk_pixbuf_get_height(category_pixbuf);
+
+ // control and end points for the two bezier curves
+ const double CURVE_X_MULT = belt_h / 20.0 * 24.0;
+ const double CURVE_CP1_X = 0.25 * CURVE_X_MULT;
+ const double CURVE_CP2_X = 0.2521 * CURVE_X_MULT;
+ const double CURVE_CP3_X = 0.36875 * CURVE_X_MULT;
+ const double CURVE_CP4_X = 0.57875 * CURVE_X_MULT;
+ const double CURVE_CP5_X = 0.705417 * CURVE_X_MULT;
+ const double CURVE_CP6_X = 0.723333 * CURVE_X_MULT;
+ const double CURVE_CP7_X = 0.952375 * CURVE_X_MULT;
+
+ const double CURVE_Y1 = 0.9825;
+ const double CURVE_Y2 = 0.72725;
+ const double CURVE_Y3 = 0.27275;
+
+ const double CURVE_START_X = belt_w - category_pb_w - CURVE_CP5_X - EMBLEM_PADDING;
+ //const double CURVE_END_X = CURVE_START_X + CURVE_X_MULT;
cairo_set_source_rgba(cr.get(), 1.0, 1.0, 1.0, 1.0);
- cairo_move_to(cr.get(), CURVE_START_XPOS * belt_w, belt_h);
- cairo_curve_to(cr.get(), CURVE_CP1_XPOS * belt_w, belt_h,
- CURVE_CP2_XPOS * belt_w, 0.9825 * belt_h,
- CURVE_CP3_XPOS * belt_w, 0.72725 * belt_h);
- cairo_line_to(cr.get(), CURVE_CP4_XPOS * belt_w, 0.27275 * belt_h);
- cairo_curve_to(cr.get(), CURVE_CP5_XPOS * belt_w, 0.0,
- CURVE_CP5_XPOS * belt_w, 0.0,
- CURVE_END_XPOS * belt_w, 0.0);
+ // paint the curved area
+ cairo_move_to(cr.get(), CURVE_START_X, belt_h);
+ cairo_curve_to(cr.get(), CURVE_START_X + CURVE_CP1_X, belt_h,
+ CURVE_START_X + CURVE_CP2_X, CURVE_Y1 * belt_h,
+ CURVE_START_X + CURVE_CP3_X, CURVE_Y2 * belt_h);
+ cairo_line_to(cr.get(), CURVE_START_X + CURVE_CP4_X, CURVE_Y3 * belt_h);
+ cairo_curve_to(cr.get(), CURVE_START_X + CURVE_CP5_X, 0.0,
+ CURVE_START_X + CURVE_CP6_X, 0.0,
+ CURVE_START_X + CURVE_CP7_X, 0.0);
cairo_line_to(cr.get(), belt_w, 0.0);
cairo_line_to(cr.get(), belt_w, belt_h);
cairo_close_path(cr.get());
@@ -440,16 +459,13 @@ private:
cairo_fill(cr.get());
// paint the emblem
- int category_pb_w = gdk_pixbuf_get_width(category_pixbuf);
- int category_pb_h = gdk_pixbuf_get_height(category_pixbuf);
- double category_pb_x =
- belt_w - category_pb_w > CURVE_CP4_XPOS * belt_w ?
- CURVE_CP4_XPOS * belt_w + ((1 - CURVE_CP4_XPOS) * belt_w - category_pb_w) / 2 : CURVE_CP4_XPOS * belt_w;
+ double category_pb_x = belt_w - category_pb_w - EMBLEM_PADDING - 1;
gdk_cairo_set_source_pixbuf(cr.get(), category_pixbuf,
category_pb_x, (belt_h - category_pb_h) / 2);
cairo_paint(cr.get());
}
+ // paint the text
cairo_set_source_rgba(cr.get(), 1.0, 1.0, 1.0, 1.0);
cairo_move_to(cr.get(), 0.0, belt_h / 2);
pango_layout_get_pixel_size(layout, nullptr, &text_height);
@@ -463,7 +479,7 @@ private:
pattern.reset(cairo_pattern_create_linear(0.0, belt_h, 0.0, belt_h + SHADOW_BOTTOM_PADDING),
cairo_pattern_destroy);
- cairo_pattern_add_color_stop_rgba(pattern.get(), 0.0, 0.0, 0.0, 0.0, 0.2);
+ cairo_pattern_add_color_stop_rgba(pattern.get(), 0.0, 0.0, 0.0, 0.0, 0.235294);
cairo_pattern_add_color_stop_rgba(pattern.get(), 1.0, 0.0, 0.0, 0.0, 0.0);
cairo_set_source(cr.get(), pattern.get());
@@ -472,13 +488,11 @@ private:
cairo_fill(cr.get());
cairo_set_source_rgba(cr.get(), 0.0, 0.0, 0.0, 0.1);
- cairo_move_to(cr.get(), 0.0, 1.0);
- cairo_line_to(cr.get(), 0.0, belt_h);
- cairo_stroke(cr.get());
+ cairo_rectangle(cr.get(), 0.0, 1.0, 1.0, belt_h);
+ cairo_fill(cr.get());
- cairo_move_to(cr.get(), belt_w, 1.0);
- cairo_line_to(cr.get(), belt_w, belt_h);
- cairo_stroke(cr.get());
+ cairo_rectangle(cr.get(), belt_w, 1.0, 1.0, belt_h);
+ cairo_fill(cr.get());
// FIXME: going from image_surface to pixbuf, and then to texture :(
glib::Object<GdkPixbuf> detail_pb(