diff options
| author | Neil Jagdish Patel <neil.patel@canonical.com> | 2010-08-19 15:58:10 +0100 |
|---|---|---|
| committer | Neil Jagdish Patel <neil.patel@canonical.com> | 2010-08-19 15:58:10 +0100 |
| commit | cfe4b8093814d9f234e8ea1b9c9d906b1b5a1bdb (patch) | |
| tree | ca1ab6b711163e35f53c7e5c489ed8b1b1bf580f /unity-private/launcher | |
| parent | f7dabc6d62508d7ae738f8d3e7c1ca5b1fcb17b5 (diff) | |
| parent | e5cd642a432f85a35d824bd5da40788b7392b96c (diff) | |
[merge] trunk
(bzr r437.2.16)
Diffstat (limited to 'unity-private/launcher')
| -rw-r--r-- | unity-private/launcher/quicklist-check-menu-item.vala | 4 | ||||
| -rw-r--r-- | unity-private/launcher/quicklist-image-menu-item.vala | 4 | ||||
| -rw-r--r-- | unity-private/launcher/quicklist-menu-item.vala | 4 | ||||
| -rw-r--r-- | unity-private/launcher/quicklist-radio-menu-item.vala | 4 | ||||
| -rw-r--r-- | unity-private/launcher/quicklist-view.vala | 1 | ||||
| -rw-r--r-- | unity-private/launcher/scroller-view.vala | 242 | ||||
| -rw-r--r-- | unity-private/launcher/scrollerchild.vala | 55 |
7 files changed, 140 insertions, 174 deletions
diff --git a/unity-private/launcher/quicklist-check-menu-item.vala b/unity-private/launcher/quicklist-check-menu-item.vala index 804958e9e..e503cad05 100644 --- a/unity-private/launcher/quicklist-check-menu-item.vala +++ b/unity-private/launcher/quicklist-check-menu-item.vala @@ -55,7 +55,9 @@ namespace Unity.Launcher this.label, out width, out height); - min_width_p = (float) width + (float) Ctk.em_to_pixel (2 * MARGIN) + 30.0f; + min_width_p = (float) width + + (float) Ctk.em_to_pixel (2 * MARGIN) + + ITEM_INDENT_ABS; natural_width_p = min_width_p; } diff --git a/unity-private/launcher/quicklist-image-menu-item.vala b/unity-private/launcher/quicklist-image-menu-item.vala index feb71f975..806f071b0 100644 --- a/unity-private/launcher/quicklist-image-menu-item.vala +++ b/unity-private/launcher/quicklist-image-menu-item.vala @@ -56,7 +56,9 @@ namespace Unity.Launcher this.label, out width, out height); - min_width_p = (float) width + (float) Ctk.em_to_pixel (2 * MARGIN); + min_width_p = (float) width + + (float) Ctk.em_to_pixel (2 * MARGIN) + + ITEM_INDENT_ABS; natural_width_p = min_width_p; } diff --git a/unity-private/launcher/quicklist-menu-item.vala b/unity-private/launcher/quicklist-menu-item.vala index 1c3b61ebf..0a6b62ee6 100644 --- a/unity-private/launcher/quicklist-menu-item.vala +++ b/unity-private/launcher/quicklist-menu-item.vala @@ -57,7 +57,9 @@ namespace Unity.Launcher this.label, out width, out height); - min_width_p = (float) width + (float) Ctk.em_to_pixel (2 * MARGIN); + min_width_p = (float) width + + (float) Ctk.em_to_pixel (2 * MARGIN) + + 2 * ITEM_INDENT_ABS; natural_width_p = min_width_p; } diff --git a/unity-private/launcher/quicklist-radio-menu-item.vala b/unity-private/launcher/quicklist-radio-menu-item.vala index 5a49319ba..e9b826c31 100644 --- a/unity-private/launcher/quicklist-radio-menu-item.vala +++ b/unity-private/launcher/quicklist-radio-menu-item.vala @@ -55,7 +55,9 @@ namespace Unity.Launcher this.label, out width, out height); - min_width_p = (float) width + (float) Ctk.em_to_pixel (2 * MARGIN) + 30.0f; + min_width_p = (float) width + + (float) Ctk.em_to_pixel (2 * MARGIN) + + ITEM_INDENT_ABS; natural_width_p = min_width_p; } diff --git a/unity-private/launcher/quicklist-view.vala b/unity-private/launcher/quicklist-view.vala index d8b09f89e..ce0675cfc 100644 --- a/unity-private/launcher/quicklist-view.vala +++ b/unity-private/launcher/quicklist-view.vala @@ -34,6 +34,7 @@ namespace Unity.Launcher const float ITEM_HEIGHT = 2.0f; const float ITEM_CORNER_RADIUS = 0.3f; const float ITEM_CORNER_RADIUS_ABS = 4.0f; + const float ITEM_INDENT_ABS = 20.0f; const float ANCHOR_HEIGHT = 1.5f; const float ANCHOR_HEIGHT_ABS = 18.0f; const float ANCHOR_WIDTH = 0.75f; diff --git a/unity-private/launcher/scroller-view.vala b/unity-private/launcher/scroller-view.vala index 3a28b2065..7ace6c0c3 100644 --- a/unity-private/launcher/scroller-view.vala +++ b/unity-private/launcher/scroller-view.vala @@ -102,16 +102,7 @@ namespace Unity.Launcher private Gee.ArrayList<ScrollerChild> draw_btf; /* Key binding indicators */ - private Clutter.Text keyboard_indicator_1; - private Clutter.Text keyboard_indicator_2; - private Clutter.Text keyboard_indicator_3; - private Clutter.Text keyboard_indicator_4; - private Clutter.Text keyboard_indicator_5; - private Clutter.Text keyboard_indicator_6; - private Clutter.Text keyboard_indicator_7; - private Clutter.Text keyboard_indicator_8; - private Clutter.Text keyboard_indicator_9; - private Clutter.Text keyboard_indicator_0; + private Gee.ArrayList<Clutter.CairoTexture> keyboard_indicators; /* * Refrence holders @@ -139,6 +130,7 @@ namespace Unity.Launcher this.padding = mypadding; + keyboard_indicators = new Gee.ArrayList <Clutter.CairoTexture> (); load_textures (); model.child_added.connect (model_child_added); model.child_removed.connect (model_child_removed); @@ -337,44 +329,15 @@ namespace Unity.Launcher last_scroll_position = scroll_position; uint8 new_opacity = (choice) ? 0xff : 0x00; - keyboard_indicator_1.animate (Clutter.AnimationMode.EASE_OUT_SINE, 150, - "opacity", new_opacity); - if (model.size < 2) new_opacity = 0x00; - keyboard_indicator_2.animate (Clutter.AnimationMode.EASE_OUT_SINE, 150, - "opacity", new_opacity); - if (model.size < 3) new_opacity = 0x00; - - keyboard_indicator_3.animate (Clutter.AnimationMode.EASE_OUT_SINE, 150, - "opacity", new_opacity); - if (model.size < 4) new_opacity = 0x00; - - keyboard_indicator_4.animate (Clutter.AnimationMode.EASE_OUT_SINE, 150, - "opacity", new_opacity); - if (model.size < 5) new_opacity = 0x00; - - keyboard_indicator_5.animate (Clutter.AnimationMode.EASE_OUT_SINE, 150, - "opacity", new_opacity); - if (model.size < 6) new_opacity = 0x00; - - keyboard_indicator_6.animate (Clutter.AnimationMode.EASE_OUT_SINE, 150, - "opacity", new_opacity); - if (model.size < 7) new_opacity = 0x00; - - keyboard_indicator_7.animate (Clutter.AnimationMode.EASE_OUT_SINE, 150, - "opacity", new_opacity); - if (model.size < 8) new_opacity = 0x00; - - keyboard_indicator_8.animate (Clutter.AnimationMode.EASE_OUT_SINE, 150, - "opacity", new_opacity); - if (model.size < 9) new_opacity = 0x00; - - keyboard_indicator_9.animate (Clutter.AnimationMode.EASE_OUT_SINE, 150, - "opacity", new_opacity); - if (model.size < 10) new_opacity = 0x00; - - keyboard_indicator_0.animate (Clutter.AnimationMode.EASE_OUT_SINE, 150, - "opacity", new_opacity); + int index = 1; + foreach (Clutter.CairoTexture kb_ind in keyboard_indicators) + { + kb_ind.animate (Clutter.AnimationMode.EASE_OUT_SINE, 150, + "opacity", new_opacity); + if (model.size <= index) new_opacity = 0x00; + index++; + } if (!choice) @@ -483,6 +446,57 @@ namespace Unity.Launcher return ret_val; } + private void draw_keyboard_indicator_cairo (Cairo.Context cr, string text) + { + double x = 0; + double y = 0; + double w = 10; + double h = 10; + double r = Ctk.em_to_pixel (1); + + Gtk.Settings settings = Gtk.Settings.get_default (); + Pango.FontDescription desc = Pango.FontDescription.from_string (settings.gtk_font_name); + + cr.select_font_face (desc.get_family (), + Cairo.FontSlant.NORMAL, + Cairo.FontWeight.NORMAL); + double size; + size = Ctk.em_to_pixel (1) * 0.9; + cr.set_font_size (size); + + + Cairo.TextExtents extents = Cairo.TextExtents (); + cr.text_extents ("2", out extents); + + Cairo.TextExtents real_extents = Cairo.TextExtents (); + cr.text_extents (text, out extents); + + double w_diff = extents.width - real_extents.width; + double h_diff = extents.height - real_extents.height; + + w += extents.width; + h += extents.height; + cr.set_source_rgba (0.07, 0.07, 0.07, 0.8); + + cr.move_to(x+r,y); // Move to A + cr.line_to(x+w-r,y); // Straight line to B + cr.curve_to(x+w,y,x+w,y,x+w,y+r); // Curve to C, Control points are both at Q + cr.line_to(x+w,y+h-r); // Move to D + cr.curve_to(x+w,y+h,x+w,y+h,x+w-r,y+h); // Curve to E + cr.line_to(x+r,y+h); // Line to F + cr.curve_to(x,y+h,x,y+h,x,y+h-r); // Curve to G + cr.line_to(x,y+r); // Line to H + cr.curve_to(x,y,x,y,x+r,y); // Curve to + + cr.fill (); + + //x = (extents.width - real_extents.width) / 2.0; + y = 0;//(extents.height - real_extents.height) / 2.0; + cr.set_source_rgba (1, 1, 1, 1); + cr.move_to (x + 5 - (real_extents.width * 0.5), y+5+extents.height); + cr.show_text (text); + } + /* * private methods */ @@ -503,36 +517,39 @@ namespace Unity.Launcher alpha = 0xff }; - keyboard_indicator_1 = new Clutter.Text.full ("Mono Bold 24px", "1", color); - keyboard_indicator_1.set_parent (this); - keyboard_indicator_1.opacity = 0x00; - keyboard_indicator_2 = new Clutter.Text.full ("Mono Bold 24px", "2", color); - keyboard_indicator_2.set_parent (this); - keyboard_indicator_2.opacity = 0x00; - keyboard_indicator_3 = new Clutter.Text.full ("Mono Bold 24px", "3", color); - keyboard_indicator_3.set_parent (this); - keyboard_indicator_3.opacity = 0x00; - keyboard_indicator_4 = new Clutter.Text.full ("Mono Bold 24px", "4", color); - keyboard_indicator_4.set_parent (this); - keyboard_indicator_4.opacity = 0x00; - keyboard_indicator_5 = new Clutter.Text.full ("Mono Bold 24px", "5", color); - keyboard_indicator_5.set_parent (this); - keyboard_indicator_5.opacity = 0x00; - keyboard_indicator_6 = new Clutter.Text.full ("Mono Bold 24px", "6", color); - keyboard_indicator_6.set_parent (this); - keyboard_indicator_6.opacity = 0x00; - keyboard_indicator_7 = new Clutter.Text.full ("Mono Bold 24px", "7", color); - keyboard_indicator_7.set_parent (this); - keyboard_indicator_7.opacity = 0x00; - keyboard_indicator_8 = new Clutter.Text.full ("Mono Bold 24px", "8", color); - keyboard_indicator_8.set_parent (this); - keyboard_indicator_8.opacity = 0x00; - keyboard_indicator_9 = new Clutter.Text.full ("Mono Bold 24px", "9", color); - keyboard_indicator_9.set_parent (this); - keyboard_indicator_9.opacity = 0x00; - keyboard_indicator_0 = new Clutter.Text.full ("Mono Bold 24px", "0", color); - keyboard_indicator_0.set_parent (this); - keyboard_indicator_0.opacity = 0x00; + //!!FIXME!! these are positioned wrong, needs to know the absolute + // size of the resulting cario surface before creating it =\ + int index = 1; + // indicator size find out activate! + int key_indicator_w, key_indicator_h; + Gtk.Settings settings = Gtk.Settings.get_default (); + + Unity.QuicklistRendering.get_text_extents (settings.gtk_font_name, "2", + out key_indicator_w, out key_indicator_h); + + key_indicator_w += 10; + key_indicator_h += 10; + + for (; index <= 10; index++) + { + var keyboard_indicator = new Clutter.CairoTexture (key_indicator_w, key_indicator_h); + keyboard_indicator.set_parent (this); + keyboard_indicator.opacity = 0x00; + + keyboard_indicator.set_surface_size (key_indicator_w, key_indicator_h); + keyboard_indicator.set_size (key_indicator_w, key_indicator_h); + keyboard_indicator.clear (); + { + Cairo.Context cr = keyboard_indicator.create (); + + string ind_str = index.to_string (); + if (index == 10) + ind_str = "0"; + + draw_keyboard_indicator_cairo (cr, ind_str); + } + keyboard_indicators.add (keyboard_indicator); + } } // will move the scroller by the given pixels @@ -1120,7 +1137,7 @@ namespace Unity.Launcher child.rotation = transitions[index].rotation; if (do_new_position) - child.animate (Clutter.AnimationMode.EASE_IN_OUT_QUAD, + child.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 300, "position", transitions[index].position ); @@ -1136,6 +1153,8 @@ namespace Unity.Launcher float min_height, nat_height; if (!(draw_ftb is Gee.ArrayList)) draw_ftb = new Gee.ArrayList<ScrollerChild> (); + + if (!(draw_ftb is Gee.ArrayList)) draw_btf = new Gee.ArrayList<ScrollerChild> (); foreach (ScrollerChild child in model) @@ -1145,8 +1164,8 @@ namespace Unity.Launcher transition.position = h + scroll_position; transition.rotation = 0.0f; ret_transitions.add (transition); - if (!(child in draw_ftb || child in draw_ftb)) - draw_ftb.add (child); + //if (!(child in draw_ftb || child in draw_ftb)) + //draw_ftb.add (child); h += nat_height + spacing; } return ret_transitions; @@ -1326,23 +1345,16 @@ namespace Unity.Launcher if (index >= 0 && index <= 9) { - Clutter.Actor? keyboard_indicator = null; - if (index == 0) keyboard_indicator = keyboard_indicator_1; - else if (index == 1) keyboard_indicator = keyboard_indicator_2; - else if (index == 2) keyboard_indicator = keyboard_indicator_3; - else if (index == 3) keyboard_indicator = keyboard_indicator_4; - else if (index == 4) keyboard_indicator = keyboard_indicator_5; - else if (index == 5) keyboard_indicator = keyboard_indicator_6; - else if (index == 6) keyboard_indicator = keyboard_indicator_7; - else if (index == 7) keyboard_indicator = keyboard_indicator_8; - else if (index == 8) keyboard_indicator = keyboard_indicator_9; - else if (index == 9) keyboard_indicator = keyboard_indicator_0; + Clutter.CairoTexture? keyboard_indicator = null; + keyboard_indicator = keyboard_indicators[(int)index]; if (keyboard_indicator is Clutter.Actor) { - child_box.x1 = box.get_width () - padding.right - keyboard_indicator.get_width (); + uint surface_width, surface_height; + keyboard_indicator.get_surface_size (out surface_width, out surface_height); + child_box.x1 = box.get_width () - padding.right - surface_width - 6; child_box.x2 = child_box.x1 + keyboard_indicator.get_width (); - child_box.y1 = child.position + padding.top + child_height - keyboard_indicator.get_height (); + child_box.y1 = child.position + padding.top + ((child_box.get_height ()*0.5f) - (surface_height*0.5f)); child_box.y2 = child_box.y1 + keyboard_indicator.get_height (); keyboard_indicator.allocate (child_box, flags); } @@ -1423,16 +1435,11 @@ namespace Unity.Launcher child.paint (); } - keyboard_indicator_1.paint (); - keyboard_indicator_2.paint (); - keyboard_indicator_3.paint (); - keyboard_indicator_4.paint (); - keyboard_indicator_5.paint (); - keyboard_indicator_6.paint (); - keyboard_indicator_7.paint (); - keyboard_indicator_8.paint (); - keyboard_indicator_9.paint (); - keyboard_indicator_0.paint (); + foreach (Clutter.CairoTexture kb_ind in keyboard_indicators) + { + kb_ind.paint (); + } + top_shadow.paint (); } @@ -1441,16 +1448,10 @@ namespace Unity.Launcher base.map (); bgtex.map (); top_shadow.map (); - keyboard_indicator_1.map (); - keyboard_indicator_2.map (); - keyboard_indicator_3.map (); - keyboard_indicator_4.map (); - keyboard_indicator_5.map (); - keyboard_indicator_6.map (); - keyboard_indicator_7.map (); - keyboard_indicator_8.map (); - keyboard_indicator_9.map (); - keyboard_indicator_0.map (); + foreach (Clutter.CairoTexture kb_ind in keyboard_indicators) + { + kb_ind.map (); + } foreach (ScrollerChild child in model) { @@ -1464,16 +1465,11 @@ namespace Unity.Launcher base.unmap (); bgtex.map (); top_shadow.map (); - keyboard_indicator_1.unmap (); - keyboard_indicator_2.unmap (); - keyboard_indicator_3.unmap (); - keyboard_indicator_4.unmap (); - keyboard_indicator_5.unmap (); - keyboard_indicator_6.unmap (); - keyboard_indicator_7.unmap (); - keyboard_indicator_8.unmap (); - keyboard_indicator_9.unmap (); - keyboard_indicator_0.unmap (); + foreach (Clutter.CairoTexture kb_ind in keyboard_indicators) + { + kb_ind.paint (); + } + foreach (ScrollerChild child in model) { child.unmap (); diff --git a/unity-private/launcher/scrollerchild.vala b/unity-private/launcher/scrollerchild.vala index 26bcdc237..62a6288f7 100644 --- a/unity-private/launcher/scrollerchild.vala +++ b/unity-private/launcher/scrollerchild.vala @@ -92,10 +92,8 @@ namespace Unity.Launcher private Clutter.Animation running_indicator_anim; private Clutter.Timeline wiggle_timeline; private Clutter.Timeline glow_timeline; - private Clutter.Timeline rotate_timeline; private AnimState glow_state; private AnimState wiggle_state; - private AnimState rotate_state; private float old_rotate_value = 0.0f; @@ -114,11 +112,9 @@ namespace Unity.Launcher //icon glow glow_timeline = new Clutter.Timeline (1); wiggle_timeline = new Clutter.Timeline (1); - rotate_timeline = new Clutter.Timeline (1); glow_timeline.new_frame.connect (on_glow_timeline_new_frame); wiggle_timeline.new_frame.connect (on_wiggle_timeline_new_frame); - rotate_timeline.new_frame.connect (on_rotate_timeline_new_frame); notify["rotation"].connect (on_rotation_changed); } @@ -186,42 +182,13 @@ namespace Unity.Launcher } /* animation callbacks */ - private void on_rotate_timeline_new_frame () - { - float progress = (float)rotate_timeline.get_progress (); - switch (rotate_state) - { - case AnimState.RISING: - rotate_anim_rising (progress); - break; - - case AnimState.STOPPED: - rotate_timeline.stop (); - break; - } - processed_icon.do_queue_redraw (); - } - - private void rotate_anim_rising (float progress) - { - progress = get_ease_out_sine (progress); - var diff = rotation - old_rotate_value; - float rotate_val = old_rotate_value + (progress * diff); - - processed_icon.rotation = rotate_val; - if (progress >= 1.0) - { - rotate_state = AnimState.STOPPED; - rotate_timeline.stop (); - } - } - public void force_rotation_jump (float degrees) { + if (processed_icon.get_animation () is Clutter.Animation) + processed_icon.get_animation ().completed (); + processed_icon.rotation = degrees; rotation = degrees; - rotate_state = AnimState.STOPPED; - rotate_timeline.stop (); do_queue_redraw (); } @@ -457,18 +424,12 @@ namespace Unity.Launcher { old_rotate_value = processed_icon.rotation; - if (rotate_timeline is Clutter.Timeline == false) - return; - - if (rotate_timeline.is_playing ()) - { - rotate_timeline.stop (); - processed_icon.rotation = old_rotate_value; - } + if (processed_icon.get_animation () is Clutter.Animation) + processed_icon.get_animation ().completed (); - rotate_timeline.set_duration (300); - rotate_state = AnimState.RISING; - rotate_timeline.start (); + processed_icon.rotation = old_rotate_value; + processed_icon.animate (Clutter.AnimationMode.EASE_OUT_QUINT, 300, + "rotation", rotation); } private void on_activating_changed () |
