use correct height for sliding transitions, fix weirdnes with replacing confirmations

This commit is contained in:
Tom Beckmann 2014-07-21 03:21:19 +02:00
parent f3868155ca
commit 7757177ffa
4 changed files with 27 additions and 17 deletions

View File

@ -73,10 +73,8 @@ namespace Gala.Plugins.Notify
Granite.Drawing.Utilities.cairo_rounded_rectangle (cr, MARGIN, MARGIN, WIDTH - MARGIN * 2, ICON_SIZE + PADDING * 2, 4);
cr.clip ();
var height_offset = ICON_SIZE + PADDING * 2;
draw_progress_bar (cr, x, y + animation_slide_y_offset, width, old_progress);
draw_progress_bar (cr, x, y + animation_slide_y_offset - height_offset, width, progress);
draw_progress_bar (cr, x, y + animation_slide_y_offset - animation_slide_height, width, progress);
cr.reset_clip ();
}
@ -112,7 +110,8 @@ namespace Gala.Plugins.Notify
this.confirmation_type = confirmation_type;
old_progress = this.progress;
play_update_transition ();
play_update_transition (ICON_SIZE + PADDING * 2);
}
if (this.icon_only != icon_only) {

View File

@ -181,7 +181,18 @@ namespace Gala.Plugins.Notify
content_container.add_child (old_notification_content);
play_update_transition ();
this.summary = summary;
this.body = body;
notification_content.set_values (summary, body);
float content_height, old_content_height;
notification_content.get_preferred_height (0, null, out content_height);
old_notification_content.get_preferred_height (0, null, out old_content_height);
content_height = float.max (content_height, old_content_height);
play_update_transition (content_height + PADDING * 2);
get_transition ("switch").completed.connect (() => {
if (old_notification_content != null)
old_notification_content.destroy ();
@ -189,10 +200,6 @@ namespace Gala.Plugins.Notify
});
}
this.summary = summary;
this.body = body;
notification_content.set_values (summary, body);
update_base (icon, expire_timeout);
}
@ -201,7 +208,7 @@ namespace Gala.Plugins.Notify
if (old_notification_content != null)
old_notification_content.y = animation_slide_y_offset;
notification_content.y = animation_slide_y_offset - ICON_SIZE - PADDING * 2;
notification_content.y = animation_slide_y_offset - animation_slide_height;
}
public override void update_allocation (out float content_height, AllocationFlags flags)

View File

@ -52,6 +52,7 @@ namespace Gala.Plugins.Notify
uint remove_timeout = 0;
// temporary things needed for the slide transition
protected float animation_slide_height { get; private set; }
GtkClutter.Texture old_texture;
float _animation_slide_y_offset = 0.0f;
public float animation_slide_y_offset {
@ -61,9 +62,7 @@ namespace Gala.Plugins.Notify
set {
_animation_slide_y_offset = value;
var height = ICON_SIZE + PADDING * 2;
icon_texture.y = -height + _animation_slide_y_offset;
icon_texture.y = -animation_slide_height + _animation_slide_y_offset;
old_texture.y = _animation_slide_y_offset;
update_slide_animation ();
@ -302,7 +301,7 @@ namespace Gala.Plugins.Notify
min_height = nat_height = ICON_SIZE + (MARGIN + PADDING) * 2;
}
protected void play_update_transition ()
protected void play_update_transition (float slide_height)
{
Transition transition;
if ((transition = get_transition ("switch")) != null) {
@ -310,6 +309,8 @@ namespace Gala.Plugins.Notify
remove_transition ("switch");
}
animation_slide_height = slide_height;
old_texture = new GtkClutter.Texture ();
icon_container.add_child (old_texture);
icon_container.set_clip (0, -PADDING, ICON_SIZE, ICON_SIZE + PADDING * 2);
@ -322,7 +323,7 @@ namespace Gala.Plugins.Notify
transition.duration = 200;
transition.progress_mode = AnimationMode.EASE_IN_OUT_QUAD;
transition.set_from_value (0.0f);
transition.set_to_value (ICON_SIZE + PADDING * 2.0f);
transition.set_to_value (animation_slide_height);
transition.remove_on_complete = true;
transition.completed.connect (() => {

View File

@ -136,8 +136,11 @@ namespace Gala.Plugins.Notify
return id;
}
if (notification.id == id && !notification.being_destroyed) {
var normal_notification = notification as NormalNotification;
var normal_notification = notification as NormalNotification;
if (!confirmation
&& notification.id == id
&& !notification.being_destroyed
&& normal_notification != null) {
if (normal_notification != null)
normal_notification.update (summary, body, pixbuf, timeout, actions);