mirror of
https://github.com/labwc/labwc.git
synced 2026-04-07 08:21:20 -04:00
Use cache for title bar double beveled borders
This commit is contained in:
parent
2a0ff0d5b4
commit
536847cb5b
5 changed files with 143 additions and 160 deletions
|
|
@ -11,6 +11,7 @@
|
|||
#include "ssd-internal.h"
|
||||
#include "theme.h"
|
||||
#include "view.h"
|
||||
#include "common/borderset.h"
|
||||
|
||||
|
||||
|
||||
|
|
@ -56,185 +57,60 @@ ssd_border_create(struct ssd *ssd)
|
|||
int bevelSize = theme->border_bevel_width; // TODO: configurable
|
||||
|
||||
/* From Pull request 3382 */
|
||||
uint8_t r = color[0] * 255;
|
||||
uint8_t g = color[1] * 255;
|
||||
uint8_t b = color[2] * 255;
|
||||
uint8_t a = color[3] * 255;
|
||||
|
||||
/* highlight */
|
||||
uint8_t r1 = MIN(r * 5 / 4, a);
|
||||
uint8_t g1 = MIN(g * 5 / 4, a);
|
||||
uint8_t b1 = MIN(b * 5 / 4, a);
|
||||
|
||||
/* darker outline */
|
||||
uint8_t r0 = r / 2;
|
||||
uint8_t g0 = g / 2;
|
||||
uint8_t b0 = b / 2;
|
||||
|
||||
uint32_t col = ((uint32_t)a << 24) | ((uint32_t)r << 16)
|
||||
| ((uint32_t)g << 8) | b;
|
||||
uint32_t col0 = ((uint32_t)a << 24) | ((uint32_t)r0 << 16)
|
||||
| ((uint32_t)g0 << 8) | b0;
|
||||
uint32_t col1 = ((uint32_t)a << 24) | ((uint32_t)r1 << 16)
|
||||
| ((uint32_t)g1 << 8) | b1;
|
||||
|
||||
|
||||
uint32_t *left_data = znew_n(uint32_t, bw);
|
||||
uint32_t *top_data = znew_n(uint32_t, bw);
|
||||
uint32_t *right_data = znew_n(uint32_t, theme->border_width);
|
||||
uint32_t *bottom_data = znew_n(uint32_t, theme->border_width);
|
||||
|
||||
for (int i = 0; i < bw; i++) {
|
||||
if (i<bevelSize) {
|
||||
left_data[i] = col1;
|
||||
top_data[i] = col1;
|
||||
right_data[i] = col1;
|
||||
bottom_data[i] = col1;
|
||||
|
||||
} else if (i > (bw-bevelSize-1)) {
|
||||
left_data[i] = col0;
|
||||
top_data[i] = col0;
|
||||
right_data[i] = col0;
|
||||
bottom_data[i] = col0;
|
||||
|
||||
} else {
|
||||
left_data[i] = col;
|
||||
top_data[i] = col;
|
||||
right_data[i] = col;
|
||||
bottom_data[i] = col;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint32_t *tl_data = znew_n(uint32_t, bw*bw);
|
||||
uint32_t *tr_data = znew_n(uint32_t, bw*bw);
|
||||
uint32_t *bl_data = znew_n(uint32_t, bw*bw);
|
||||
uint32_t *br_data = znew_n(uint32_t, bw*bw);
|
||||
// Fill with solid
|
||||
for (int i=0; i<bw;i++) {
|
||||
for (int j=0; j<bw;j++) {
|
||||
tl_data[PIXEL(i, j)] = col;
|
||||
tr_data[PIXEL(i, j)] = col;
|
||||
bl_data[PIXEL(i, j)] = col;
|
||||
br_data[PIXEL(i, j)] = col;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Main Corners
|
||||
for (int i=0; i < bevelSize; i++) {
|
||||
|
||||
// Solid bar parts
|
||||
for (int j=0; j<bw; j++) {
|
||||
// Top left corner: Entire "bevel size" top rows are highlighted
|
||||
tl_data[PIXEL(j, i)] = col1;
|
||||
// First "bevel size" top columns are highlighted
|
||||
tl_data[PIXEL(i, j)] = col1;
|
||||
|
||||
// Bottom Right corner: Entire "bevel size" last rows are lowlight
|
||||
br_data[PIXEL(j, (bw-1-i))] = col0;
|
||||
// Last "bevel size" columns are lowlight
|
||||
br_data[PIXEL((bw-1-i), j)] = col0;
|
||||
|
||||
|
||||
// Bottom left corner: Entire "bevel size" last rows are lowlight
|
||||
bl_data[PIXEL(j, (bw-1-i))] = col0;
|
||||
// First "bevel size" columns are highlight, except for the bottom right corner
|
||||
bl_data[PIXEL(i, j)] = col1;
|
||||
|
||||
// Top Right corner: Entire "bevel size" first rows are highlight
|
||||
tr_data[PIXEL(j, i)] = col1;
|
||||
// Last "bevel size" columns are lowlight, except for the top left
|
||||
tr_data[PIXEL((bw-1-i), j)] = col0;
|
||||
|
||||
}
|
||||
}
|
||||
// Beveled Corner Parts
|
||||
for (int i=0; i < bevelSize; i++) {
|
||||
|
||||
for (int j=0; j<bevelSize; j++) {
|
||||
// Outer Corners
|
||||
// Bottom left corner:
|
||||
// First "bevel size" columns are highlight, except for the bottom right corner
|
||||
bl_data[PIXEL(i, (bw - 1 - j))] = (j >= i) ? col1 : col0;
|
||||
|
||||
// Top Right corner:
|
||||
// Last "bevel size" columns are lowlight, except for the top left
|
||||
tr_data[PIXEL((bw-1-i), j)] = (j > i) ? col0 : col1;
|
||||
|
||||
|
||||
// Inner Corners
|
||||
// Top left corner: Bottom right is all dark
|
||||
tl_data[PIXEL((bw-1-i), (bw - 1 - j))] = col0;
|
||||
|
||||
// Bottom Right corner: Top left is all light
|
||||
br_data[PIXEL(i, j)] = col1;
|
||||
|
||||
// Top Right corner:
|
||||
// Interior bottom left is dark on top, light on bottom
|
||||
tr_data[PIXEL(i, (bw-1-j))] = (i > j) ? col1 : col0;
|
||||
|
||||
// Bottom Left corner:
|
||||
// Interior top right is dark on top, light on bottom
|
||||
bl_data[PIXEL((bw-1-i), j)] = (i > j) ? col0 : col1;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
float r = color[0];
|
||||
float g = color[1];
|
||||
float b = color[2];
|
||||
float a = color[3];
|
||||
|
||||
uint32_t colour32 = (uint32_t)(a*255) << 24 | (uint32_t)(r*255) << 16 | (uint32_t)(g*255) << 8 | (uint32_t)(b*255);
|
||||
struct borderset * renderedborders = getBorders(colour32, bw, 2, bevelSize);
|
||||
|
||||
struct lab_data_buffer *ttexture_buffer =
|
||||
buffer_create_from_data(top_data, 1,theme->border_width,
|
||||
buffer_create_from_data(renderedborders->top, 1,theme->border_width,
|
||||
4);
|
||||
subtree->ttexture = wlr_scene_buffer_create(parent, &ttexture_buffer->base);
|
||||
wlr_buffer_drop(&ttexture_buffer->base);
|
||||
|
||||
|
||||
struct lab_data_buffer *btexture_buffer =
|
||||
buffer_create_from_data(bottom_data, 1,theme->border_width,
|
||||
buffer_create_from_data(renderedborders->bottom, 1,theme->border_width,
|
||||
4);
|
||||
subtree->btexture = wlr_scene_buffer_create(parent, &btexture_buffer->base);
|
||||
wlr_buffer_drop(&btexture_buffer->base);
|
||||
|
||||
|
||||
struct lab_data_buffer *ltexture_buffer =
|
||||
buffer_create_from_data(left_data, theme->border_width, 1,
|
||||
buffer_create_from_data(renderedborders->left, theme->border_width, 1,
|
||||
4*theme->border_width);
|
||||
subtree->ltexture = wlr_scene_buffer_create(parent, <exture_buffer->base);
|
||||
wlr_buffer_drop(<exture_buffer->base);
|
||||
|
||||
|
||||
struct lab_data_buffer *rtexture_buffer =
|
||||
buffer_create_from_data(right_data, theme->border_width, 1,
|
||||
buffer_create_from_data(renderedborders->right, theme->border_width, 1,
|
||||
4*theme->border_width);
|
||||
subtree->rtexture = wlr_scene_buffer_create(parent, &rtexture_buffer->base);
|
||||
wlr_buffer_drop(&rtexture_buffer->base);
|
||||
|
||||
|
||||
|
||||
struct lab_data_buffer *tltexture_buffer =
|
||||
buffer_create_from_data(tl_data, theme->border_width, theme->border_width,
|
||||
buffer_create_from_data(renderedborders->tl, theme->border_width, theme->border_width,
|
||||
4*theme->border_width);
|
||||
subtree->tlcorner = wlr_scene_buffer_create(parent, &tltexture_buffer->base);
|
||||
wlr_buffer_drop(&tltexture_buffer->base);
|
||||
|
||||
struct lab_data_buffer *trtexture_buffer =
|
||||
buffer_create_from_data(tr_data, theme->border_width, theme->border_width,
|
||||
buffer_create_from_data(renderedborders->tr, theme->border_width, theme->border_width,
|
||||
4*theme->border_width);
|
||||
subtree->trcorner = wlr_scene_buffer_create(parent, &trtexture_buffer->base);
|
||||
wlr_buffer_drop(&trtexture_buffer->base);
|
||||
|
||||
|
||||
|
||||
struct lab_data_buffer *bltexture_buffer =
|
||||
buffer_create_from_data(bl_data, theme->border_width, theme->border_width,
|
||||
buffer_create_from_data(renderedborders->bl, theme->border_width, theme->border_width,
|
||||
4*theme->border_width);
|
||||
subtree->blcorner = wlr_scene_buffer_create(parent, &bltexture_buffer->base);
|
||||
wlr_buffer_drop(&bltexture_buffer->base);
|
||||
|
||||
struct lab_data_buffer *brtexture_buffer =
|
||||
buffer_create_from_data(br_data, theme->border_width, theme->border_width,
|
||||
buffer_create_from_data(renderedborders->br, theme->border_width, theme->border_width,
|
||||
4*theme->border_width);
|
||||
subtree->brcorner = wlr_scene_buffer_create(parent, &brtexture_buffer->base);
|
||||
wlr_buffer_drop(&brtexture_buffer->base);
|
||||
} else {
|
||||
|
||||
subtree->left = lab_wlr_scene_rect_create(parent,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue