mirror of
https://github.com/elementary/gala.git
synced 2024-10-26 16:01:57 +03:00
Add fade-in / fade-out
This commit is contained in:
parent
bd347ef9ef
commit
3f843fa8c4
@ -545,7 +545,7 @@ namespace Gala
|
||||
get_parent ().remove_child (this);
|
||||
|
||||
unowned WorkspaceInsertThumb inserter = (WorkspaceInsertThumb) destination;
|
||||
workspace.get_screen ().reorder_workspace (workspace, inserter.workspace_index);
|
||||
// workspace.get_screen ().reorder_workspace (workspace, inserter.workspace_index);
|
||||
|
||||
restore_group ();
|
||||
} else {
|
||||
|
@ -327,6 +327,9 @@ namespace Gala
|
||||
return false;
|
||||
}
|
||||
|
||||
float greyscale_opacity = 0.0f;
|
||||
uint fade_in_id = 0U;
|
||||
uint fade_out_id = 0U;
|
||||
void toggle_greyscale ()
|
||||
{
|
||||
if (greyscale_effect == null) {
|
||||
@ -334,22 +337,58 @@ namespace Gala
|
||||
greyscale_effect.set_name ("greyscale");
|
||||
greyscale_effect.set_shader_source ("""
|
||||
uniform sampler2D texture;
|
||||
uniform float opacity;
|
||||
|
||||
void main () {
|
||||
vec4 color = texture2D (texture, cogl_tex_coord0_in.xy);
|
||||
float gray = dot(color.rgb, vec3(0.299, 0.587, 0.114));
|
||||
cogl_color_out = vec4(vec3(gray), 1.0);
|
||||
cogl_color_out = mix (color, vec4(vec3(gray), 1.0), opacity);
|
||||
}
|
||||
""");
|
||||
|
||||
greyscale_effect.set_uniform_value ("texture", 0);
|
||||
greyscale_effect.set_uniform_value ("opacity", 0.0f);
|
||||
}
|
||||
|
||||
const uint FADE_TIMEOUT = 300 / 100;
|
||||
if (AppearanceSettings.get_default ().greyscale) {
|
||||
if (ui_group.get_effect ("greyscale") == null) {
|
||||
bool animates_out = fade_out_id > 0U;
|
||||
if (ui_group.get_effect ("greyscale") == null || animates_out) {
|
||||
ui_group.add_effect (greyscale_effect);
|
||||
if (animates_out) {
|
||||
Source.remove (fade_out_id);
|
||||
}
|
||||
|
||||
fade_in_id = Timeout.add (FADE_TIMEOUT, () => {
|
||||
greyscale_effect.set_uniform_value ("opacity", greyscale_opacity);
|
||||
greyscale_opacity += 0.01f;
|
||||
|
||||
bool stop = greyscale_opacity > 1.0f;
|
||||
if (stop) {
|
||||
fade_in_id = 0U;
|
||||
}
|
||||
|
||||
return !stop;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (ui_group.get_effect ("greyscale") != null) {
|
||||
if (fade_in_id > 0U) {
|
||||
Source.remove (fade_in_id);
|
||||
}
|
||||
|
||||
fade_out_id = Timeout.add (FADE_TIMEOUT, () => {
|
||||
greyscale_opacity -= 0.01f;
|
||||
greyscale_effect.set_uniform_value ("opacity", greyscale_opacity);
|
||||
|
||||
bool stop = greyscale_opacity <= 0.0f;
|
||||
if (stop) {
|
||||
ui_group.remove_effect (greyscale_effect);
|
||||
fade_out_id = 0U;
|
||||
}
|
||||
|
||||
return !stop;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user