initial fade-out groundwork
This commit is contained in:
parent
6084ea42ec
commit
e51fda46d3
4 changed files with 9 additions and 8 deletions
|
@ -122,6 +122,7 @@ struct sway_container {
|
||||||
// TODO: move alpha to state?
|
// TODO: move alpha to state?
|
||||||
float alpha;
|
float alpha;
|
||||||
float target_alpha;
|
float target_alpha;
|
||||||
|
float max_alpha;
|
||||||
|
|
||||||
int corner_radius;
|
int corner_radius;
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,9 @@ struct cmd_results *cmd_opacity(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcasecmp(argv[0], "plus")) {
|
if (!strcasecmp(argv[0], "plus")) {
|
||||||
val = con->target_alpha + val;
|
val = con->max_alpha + val;
|
||||||
} else if (!strcasecmp(argv[0], "minus")) {
|
} else if (!strcasecmp(argv[0], "minus")) {
|
||||||
val = con->target_alpha - val;
|
val = con->max_alpha - val;
|
||||||
} else if (argc > 1 && strcasecmp(argv[0], "set")) {
|
} else if (argc > 1 && strcasecmp(argv[0], "set")) {
|
||||||
return cmd_results_new(CMD_INVALID,
|
return cmd_results_new(CMD_INVALID,
|
||||||
"Expected: set|plus|minus <0..1>: %s", argv[0]);
|
"Expected: set|plus|minus <0..1>: %s", argv[0]);
|
||||||
|
@ -36,6 +36,7 @@ struct cmd_results *cmd_opacity(int argc, char **argv) {
|
||||||
return cmd_results_new(CMD_FAILURE, "opacity value out of bounds");
|
return cmd_results_new(CMD_FAILURE, "opacity value out of bounds");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
con->max_alpha = val;
|
||||||
con->target_alpha = val;
|
con->target_alpha = val;
|
||||||
container_damage_whole(con);
|
container_damage_whole(con);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
|
|
|
@ -527,19 +527,17 @@ static void containers_tick_alpha(list_t *containers, struct sway_output *output
|
||||||
}
|
}
|
||||||
|
|
||||||
float alpha_step;
|
float alpha_step;
|
||||||
|
struct sway_container *con = NULL;
|
||||||
for (int i = 0; i < containers->length; ++i) {
|
for (int i = 0; i < containers->length; ++i) {
|
||||||
struct sway_container *con = containers->items[i];
|
con = containers->items[i];
|
||||||
if (con->pending.children) {
|
if (con->pending.children) {
|
||||||
containers_tick_alpha(con->pending.children, output);
|
containers_tick_alpha(con->pending.children, output);
|
||||||
} else { // should this else be removed?
|
} else { // should this else be removed?
|
||||||
if (con->alpha == con->target_alpha) {
|
if (con->alpha == con->target_alpha) {
|
||||||
continue;
|
continue;
|
||||||
} else if (con->alpha < con->target_alpha) { // fade-in animation
|
|
||||||
alpha_step = (con->target_alpha * output->refresh_sec) / config->animation_duration;
|
|
||||||
con->alpha = MIN(con->alpha + alpha_step, con->target_alpha);
|
|
||||||
} else if (con->alpha > con->target_alpha) { // fade-out animation
|
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
|
alpha_step = (con->max_alpha * output->refresh_sec) / config->animation_duration;
|
||||||
|
con->alpha = con->alpha < con->target_alpha ? MIN(con->alpha + alpha_step, con->target_alpha) : MAX(con->alpha - alpha_step, con->target_alpha);
|
||||||
output_damage_whole_container(output, con);
|
output_damage_whole_container(output, con);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ struct sway_container *container_create(struct sway_view *view) {
|
||||||
c->view = view;
|
c->view = view;
|
||||||
c->alpha = 0.0f;
|
c->alpha = 0.0f;
|
||||||
c->target_alpha = 1.0f;
|
c->target_alpha = 1.0f;
|
||||||
|
c->max_alpha = 1.0f;
|
||||||
c->saturation = 1.0f;
|
c->saturation = 1.0f;
|
||||||
c->dim = config->default_dim_inactive;
|
c->dim = config->default_dim_inactive;
|
||||||
c->shadow_enabled = config->shadow_enabled;
|
c->shadow_enabled = config->shadow_enabled;
|
||||||
|
|
Loading…
Add table
Reference in a new issue