Allow a single gradient per bg/state
This commit is contained in:
parent
15150fb577
commit
207129447d
7 changed files with 18 additions and 38 deletions
|
@ -288,14 +288,12 @@ task_active_background_id = 2
|
|||
systray_background_id = 0
|
||||
clock_background_id = 0
|
||||
</code></pre>
|
||||
<p>Identifier 0 refers to a special background which is fully transparent, identifier 1 applies the first background defined in the config file etc.</p><h3 id="gradients">Gradients<a name="gradients" href="#gradients" class="md2man-permalink" title="permalink"></a></h3><p>(Available since 0.13.0)</p><p>Backgrounds also allow specifying one or more gradient layers
|
||||
<p>Identifier 0 refers to a special background which is fully transparent, identifier 1 applies the first background defined in the config file etc.</p><h3 id="gradients">Gradients<a name="gradients" href="#gradients" class="md2man-permalink" title="permalink"></a></h3><p>(Available since 0.13.0)</p><p>Backgrounds also allow specifying gradient layers
|
||||
that are drawn on top of the solid color background.</p><p>First the user must define one or more gradients in the config file,
|
||||
each starting with <code>gradient = TYPE</code>. These must be added before backgrounds.</p><p>Then gradients can be added by index to backgrounds,
|
||||
using the <code>gradient_id = INDEX</code>, <code>hover_gradient_id = INDEX</code> and
|
||||
<code>pressed_gradient_id = INDEX</code>, where <code>INDEX</code> is
|
||||
the gradient index, starting from 1. The <code>*gradient_id</code> option can be repeated
|
||||
for the same background, which results in multiple gradients
|
||||
being drawn on top of each other in the given order.</p><h4 id="simple-gradients">Simple gradients<a name="simple-gradients" href="#simple-gradients" class="md2man-permalink" title="permalink"></a></h4><p>These are gradients that vary from fixed control points (top-to-bottom, left-to-right
|
||||
the gradient index, starting from 1.</p><h4 id="simple-gradients">Simple gradients<a name="simple-gradients" href="#simple-gradients" class="md2man-permalink" title="permalink"></a></h4><p>These are gradients that vary from fixed control points (top-to-bottom, left-to-right
|
||||
or center-to-corners). The user must specify the start and end colors,
|
||||
and can optionally add extra color stops in between.</p><h5 id="vertical-gradient-with-color-varying-from-the-top-edge-to-the-bottom-edge-two-colors">Vertical gradient, with color varying from the top edge to the bottom edge, two colors<a name="vertical-gradient-with-color-varying-from-the-top-edge-to-the-bottom-edge-two-colors" href="#vertical-gradient-with-color-varying-from-the-top-edge-to-the-bottom-edge-two-colors" class="md2man-permalink" title="permalink"></a></h5><pre class="highlight plaintext"><code>gradient = vertical
|
||||
start_color = #rrggbb opacity
|
||||
|
|
|
@ -179,7 +179,7 @@ Identifier 0 refers to a special background which is fully transparent, identifi
|
|||
.PP
|
||||
(Available since 0.13.0)
|
||||
.PP
|
||||
Backgrounds also allow specifying one or more gradient layers
|
||||
Backgrounds also allow specifying gradient layers
|
||||
that are drawn on top of the solid color background.
|
||||
.PP
|
||||
First the user must define one or more gradients in the config file,
|
||||
|
@ -188,9 +188,7 @@ each starting with \fB\fCgradient = TYPE\fR\&. These must be added before backgr
|
|||
Then gradients can be added by index to backgrounds,
|
||||
using the \fB\fCgradient_id = INDEX\fR, \fB\fChover_gradient_id = INDEX\fR and
|
||||
\fB\fCpressed_gradient_id = INDEX\fR, where \fB\fCINDEX\fR is
|
||||
the gradient index, starting from 1. The \fB\fC*gradient_id\fR option can be repeated
|
||||
for the same background, which results in multiple gradients
|
||||
being drawn on top of each other in the given order.
|
||||
the gradient index, starting from 1.
|
||||
.SS Simple gradients
|
||||
.PP
|
||||
These are gradients that vary from fixed control points (top\-to\-bottom, left\-to\-right
|
||||
|
|
|
@ -142,7 +142,7 @@ Identifier 0 refers to a special background which is fully transparent, identifi
|
|||
|
||||
(Available since 0.13.0)
|
||||
|
||||
Backgrounds also allow specifying one or more gradient layers
|
||||
Backgrounds also allow specifying gradient layers
|
||||
that are drawn on top of the solid color background.
|
||||
|
||||
First the user must define one or more gradients in the config file,
|
||||
|
@ -151,9 +151,7 @@ each starting with `gradient = TYPE`. These must be added before backgrounds.
|
|||
Then gradients can be added by index to backgrounds,
|
||||
using the `gradient_id = INDEX`, `hover_gradient_id = INDEX` and
|
||||
`pressed_gradient_id = INDEX`, where `INDEX` is
|
||||
the gradient index, starting from 1. The `*gradient_id` option can be repeated
|
||||
for the same background, which results in multiple gradients
|
||||
being drawn on top of each other in the given order.
|
||||
the gradient index, starting from 1.
|
||||
|
||||
#### Simple gradients
|
||||
|
||||
|
|
|
@ -318,19 +318,19 @@ void add_entry(char *key, char *value)
|
|||
int id = atoi(value);
|
||||
id = (id < gradients->len && id >= 0) ? id : -1;
|
||||
if (id >= 0)
|
||||
bg->gradients[MOUSE_NORMAL] = g_list_append(bg->gradients[MOUSE_NORMAL], &g_array_index(gradients, GradientClass, id));
|
||||
bg->gradients[MOUSE_NORMAL] = &g_array_index(gradients, GradientClass, id);
|
||||
} else if (strcmp(key, "hover_gradient_id") == 0) {
|
||||
Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1);
|
||||
int id = atoi(value);
|
||||
id = (id < gradients->len && id >= 0) ? id : -1;
|
||||
if (id >= 0)
|
||||
bg->gradients[MOUSE_OVER] = g_list_append(bg->gradients[MOUSE_OVER], &g_array_index(gradients, GradientClass, id));
|
||||
bg->gradients[MOUSE_OVER] = &g_array_index(gradients, GradientClass, id);
|
||||
} else if (strcmp(key, "pressed_gradient_id") == 0) {
|
||||
Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1);
|
||||
int id = atoi(value);
|
||||
id = (id < gradients->len && id >= 0) ? id : -1;
|
||||
if (id >= 0)
|
||||
bg->gradients[MOUSE_DOWN] = g_list_append(bg->gradients[MOUSE_DOWN], &g_array_index(gradients, GradientClass, id));
|
||||
bg->gradients[MOUSE_DOWN] = &g_array_index(gradients, GradientClass, id);
|
||||
}
|
||||
|
||||
/* Gradients */
|
||||
|
|
|
@ -156,10 +156,7 @@ void cleanup_panel()
|
|||
|
||||
free_area(&panel_config.area);
|
||||
|
||||
if (backgrounds) {
|
||||
for (guint i = 0; i < backgrounds->len; i++)
|
||||
cleanup_background(&g_array_index(backgrounds, Background, i));
|
||||
}
|
||||
g_array_free(backgrounds, TRUE);
|
||||
backgrounds = NULL;
|
||||
if (gradients) {
|
||||
for (guint i = 0; i < gradients->len; i++)
|
||||
|
|
|
@ -40,16 +40,6 @@ void init_background(Background *bg)
|
|||
bg->border.mask = BORDER_TOP | BORDER_BOTTOM | BORDER_LEFT | BORDER_RIGHT;
|
||||
}
|
||||
|
||||
void cleanup_background(Background *bg)
|
||||
{
|
||||
if (debug_gradients)
|
||||
fprintf(stderr, YELLOW "freeing gradient list %p" RESET "\n", (void*)bg->gradients);
|
||||
for (int i = 0; i < MOUSE_STATE_COUNT; i++) {
|
||||
g_list_free(bg->gradients[i]);
|
||||
bg->gradients[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void initialize_positions(void *obj, int offset)
|
||||
{
|
||||
Area *a = (Area *)obj;
|
||||
|
@ -964,12 +954,12 @@ void instantiate_area_gradients(Area *area)
|
|||
fprintf(stderr, "Initializing gradients for area %s\n", area->name);
|
||||
for (int i = 0; i < MOUSE_STATE_COUNT; i++) {
|
||||
g_assert_null(area->gradient_instances_by_state[i]);
|
||||
for (GList *l = area->bg->gradients[i]; l; l = l->next) {
|
||||
GradientClass *g = (GradientClass *)l->data;
|
||||
GradientInstance *gi = (GradientInstance *)calloc(1, sizeof(GradientInstance));
|
||||
instantiate_gradient(area, g, gi);
|
||||
area->gradient_instances_by_state[i] = g_list_append(area->gradient_instances_by_state[i], gi);
|
||||
}
|
||||
GradientClass *g = area->bg->gradients[i];
|
||||
if (!g)
|
||||
continue;
|
||||
GradientInstance *gi = (GradientInstance *)calloc(1, sizeof(GradientInstance));
|
||||
instantiate_gradient(area, g, gi);
|
||||
area->gradient_instances_by_state[i] = g_list_append(area->gradient_instances_by_state[i], gi);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -152,8 +152,8 @@ typedef struct Background {
|
|||
// On mouse press
|
||||
Color fill_color_pressed;
|
||||
Color border_color_pressed;
|
||||
// Each list element is a pointer to a GradientClass (list can be empty), no ownership
|
||||
GList *gradients[MOUSE_STATE_COUNT];
|
||||
// Pointer to a GradientClass or NULL, no ownership
|
||||
GradientClass *gradients[MOUSE_STATE_COUNT];
|
||||
} Background;
|
||||
|
||||
typedef enum Layout {
|
||||
|
@ -244,7 +244,6 @@ typedef struct Area {
|
|||
|
||||
// Initializes the Background member to default values.
|
||||
void init_background(Background *bg);
|
||||
void cleanup_background(Background *bg);
|
||||
|
||||
// Layout
|
||||
|
||||
|
|
Loading…
Reference in a new issue