Port 'fancy' decoration theme
5
Makefile
@ -71,6 +71,9 @@ base/lib/libtoaru_termemu.so: lib/termemu.c lib/termemu.h base/lib/libtoaru_grap
|
||||
base/lib/libtoaru_decorations.so: lib/decorations.c lib/decorations.h base/lib/libtoaru_graphics.so
|
||||
$(CC) -o $@ $(CFLAGS) -shared -fPIC $< -ltoaru_graphics
|
||||
|
||||
base/lib/libtoaru-decor-fancy.so: decors/decor-fancy.c lib/decorations.h base/lib/libtoaru_graphics.so base/lib/libtoaru_decorations.so
|
||||
$(CC) -o $@ $(CFLAGS) -shared -fPIC $< -ltoaru_decorations -ltoaru_graphics
|
||||
|
||||
base/bin/init: init.c base/lib/libnihc.a | dirs
|
||||
$(CC) -static -Wl,-static $(CFLAGS) -o $@ $< $(LIBS)
|
||||
|
||||
@ -101,7 +104,7 @@ base/bin/ls: ls.c base/lib/libnihc.so base/lib/libtoaru_list.so
|
||||
base/bin/%: %.c base/lib/libnihc.so | dirs
|
||||
$(CC) $(CFLAGS) -o $@ $< $(LIBS)
|
||||
|
||||
cdrom/ramdisk.img.gz: ${APPS_X} base/lib/ld.so | dirs
|
||||
cdrom/ramdisk.img.gz: ${APPS_X} base/lib/ld.so base/lib/libtoaru-decor-fancy.so | dirs
|
||||
genext2fs -B 4096 -d base -U -b 16384 -N 2048 cdrom/ramdisk.img
|
||||
rm -f cdrom/ramdisk.img.gz
|
||||
gzip cdrom/ramdisk.img
|
||||
|
1
base/etc/passwd
Normal file
@ -0,0 +1 @@
|
||||
root:x:0:0:Administrator:/home/root:/bin/sh:fancy
|
BIN
base/usr/share/ttk/active/button-close.bmp
Normal file
After Width: | Height: | Size: 394 B |
BIN
base/usr/share/ttk/active/ll.bmp
Normal file
After Width: | Height: | Size: 462 B |
BIN
base/usr/share/ttk/active/lm.bmp
Normal file
After Width: | Height: | Size: 174 B |
BIN
base/usr/share/ttk/active/lr.bmp
Normal file
After Width: | Height: | Size: 462 B |
BIN
base/usr/share/ttk/active/ml.bmp
Normal file
After Width: | Height: | Size: 162 B |
BIN
base/usr/share/ttk/active/mr.bmp
Normal file
After Width: | Height: | Size: 162 B |
BIN
base/usr/share/ttk/active/ul.bmp
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
base/usr/share/ttk/active/um.bmp
Normal file
After Width: | Height: | Size: 270 B |
BIN
base/usr/share/ttk/active/ur.bmp
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
base/usr/share/ttk/inactive/button-close.bmp
Normal file
After Width: | Height: | Size: 394 B |
BIN
base/usr/share/ttk/inactive/ll.bmp
Normal file
After Width: | Height: | Size: 462 B |
BIN
base/usr/share/ttk/inactive/lm.bmp
Normal file
After Width: | Height: | Size: 174 B |
BIN
base/usr/share/ttk/inactive/lr.bmp
Normal file
After Width: | Height: | Size: 462 B |
BIN
base/usr/share/ttk/inactive/ml.bmp
Normal file
After Width: | Height: | Size: 162 B |
BIN
base/usr/share/ttk/inactive/mr.bmp
Normal file
After Width: | Height: | Size: 162 B |
BIN
base/usr/share/ttk/inactive/ul.bmp
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
base/usr/share/ttk/inactive/um.bmp
Normal file
After Width: | Height: | Size: 270 B |
BIN
base/usr/share/ttk/inactive/ur.bmp
Normal file
After Width: | Height: | Size: 1.4 KiB |
147
decors/decor-fancy.c
Normal file
@ -0,0 +1,147 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "lib/yutani.h"
|
||||
#include "lib/graphics.h"
|
||||
//#include "lib/shmemfonts.h"
|
||||
#include "lib/decorations.h"
|
||||
|
||||
#define INACTIVE 9
|
||||
|
||||
#define TTK_FANCY_PATH "/usr/share/ttk/"
|
||||
|
||||
static int u_height = 33;
|
||||
static int ul_width = 10;
|
||||
static int ur_width = 10;
|
||||
static int ml_width = 6;
|
||||
static int mr_width = 6;
|
||||
static int l_height = 9;
|
||||
static int ll_width = 9;
|
||||
static int lr_width = 9;
|
||||
static int llx_offset = 3;
|
||||
static int lly_offset = 3;
|
||||
static int lrx_offset = 3;
|
||||
static int lry_offset = 3;
|
||||
|
||||
static sprite_t * sprites[20];
|
||||
|
||||
#define TEXT_OFFSET 24
|
||||
|
||||
static void init_sprite(int id, char * path) {
|
||||
sprites[id] = malloc(sizeof(sprite_t));
|
||||
load_sprite(sprites[id], path);
|
||||
sprites[id]->alpha = ALPHA_EMBEDDED;
|
||||
}
|
||||
|
||||
static void render_decorations_fancy(yutani_window_t * window, gfx_context_t * ctx, char * title, int decors_active) {
|
||||
int width = window->width;
|
||||
int height = window->height;
|
||||
|
||||
for (int j = 0; j < decor_top_height; ++j) {
|
||||
for (int i = 0; i < width; ++i) {
|
||||
GFX(ctx,i,j) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = decor_top_height; j < height - decor_bottom_height; ++j) {
|
||||
for (int i = 0; i < decor_left_width; ++i) {
|
||||
GFX(ctx,i,j) = 0;
|
||||
}
|
||||
for (int i = width - decor_right_width; i < width; ++i) {
|
||||
GFX(ctx,i,j) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = height - decor_bottom_height; j < height; ++j) {
|
||||
for (int i = 0; i < width; ++i) {
|
||||
GFX(ctx,i,j) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (decors_active == DECOR_INACTIVE) decors_active = INACTIVE;
|
||||
|
||||
draw_sprite(ctx, sprites[decors_active + 0], 0, 0);
|
||||
for (int i = 0; i < width - (ul_width + ur_width); ++i) {
|
||||
draw_sprite(ctx, sprites[decors_active + 1], i + ul_width, 0);
|
||||
}
|
||||
draw_sprite(ctx, sprites[decors_active + 2], width - ur_width, 0);
|
||||
for (int i = 0; i < height - (u_height + l_height); ++i) {
|
||||
draw_sprite(ctx, sprites[decors_active + 3], 0, i + u_height);
|
||||
draw_sprite(ctx, sprites[decors_active + 4], width - mr_width, i + u_height);
|
||||
}
|
||||
draw_sprite(ctx, sprites[decors_active + 5], 0, height - l_height);
|
||||
for (int i = 0; i < width - (ll_width + lr_width); ++i) {
|
||||
draw_sprite(ctx, sprites[decors_active + 6], i + ll_width, height - l_height);
|
||||
}
|
||||
draw_sprite(ctx, sprites[decors_active + 7], width - lr_width, height - l_height);
|
||||
|
||||
#if 0
|
||||
set_font_face(FONT_SANS_SERIF_BOLD);
|
||||
set_font_size(12);
|
||||
|
||||
char * tmp_title = strdup(title);
|
||||
int t_l = strlen(tmp_title);
|
||||
|
||||
#define EXTRA_SPACE 40
|
||||
|
||||
if (draw_string_width(tmp_title) + EXTRA_SPACE > width) {
|
||||
while (t_l >= 0 && (draw_string_width(tmp_title) + EXTRA_SPACE > width)) {
|
||||
tmp_title[t_l] = '\0';
|
||||
t_l--;
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen(tmp_title)) {
|
||||
int title_offset = (width / 2) - (draw_string_width(tmp_title) / 2);
|
||||
if (decors_active == 0) {
|
||||
draw_string(ctx, title_offset, TEXT_OFFSET, rgb(226,226,226), tmp_title);
|
||||
} else {
|
||||
draw_string(ctx, title_offset, TEXT_OFFSET, rgb(147,147,147), tmp_title);
|
||||
}
|
||||
}
|
||||
|
||||
free(tmp_title);
|
||||
#endif
|
||||
|
||||
/* Buttons */
|
||||
draw_sprite(ctx, sprites[decors_active + 8], width - 28, 16);
|
||||
}
|
||||
|
||||
static int check_button_press_fancy(yutani_window_t * window, int x, int y) {
|
||||
if (x >= window->width - 28 && x <= window->width - 18 &&
|
||||
y >= 16 && y <= 26) {
|
||||
return DECOR_CLOSE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void decor_init() {
|
||||
init_sprite(0, TTK_FANCY_PATH "active/ul.bmp");
|
||||
init_sprite(1, TTK_FANCY_PATH "active/um.bmp");
|
||||
init_sprite(2, TTK_FANCY_PATH "active/ur.bmp");
|
||||
init_sprite(3, TTK_FANCY_PATH "active/ml.bmp");
|
||||
init_sprite(4, TTK_FANCY_PATH "active/mr.bmp");
|
||||
init_sprite(5, TTK_FANCY_PATH "active/ll.bmp");
|
||||
init_sprite(6, TTK_FANCY_PATH "active/lm.bmp");
|
||||
init_sprite(7, TTK_FANCY_PATH "active/lr.bmp");
|
||||
init_sprite(8, TTK_FANCY_PATH "active/button-close.bmp");
|
||||
|
||||
init_sprite(INACTIVE + 0, TTK_FANCY_PATH "inactive/ul.bmp");
|
||||
init_sprite(INACTIVE + 1, TTK_FANCY_PATH "inactive/um.bmp");
|
||||
init_sprite(INACTIVE + 2, TTK_FANCY_PATH "inactive/ur.bmp");
|
||||
init_sprite(INACTIVE + 3, TTK_FANCY_PATH "inactive/ml.bmp");
|
||||
init_sprite(INACTIVE + 4, TTK_FANCY_PATH "inactive/mr.bmp");
|
||||
init_sprite(INACTIVE + 5, TTK_FANCY_PATH "inactive/ll.bmp");
|
||||
init_sprite(INACTIVE + 6, TTK_FANCY_PATH "inactive/lm.bmp");
|
||||
init_sprite(INACTIVE + 7, TTK_FANCY_PATH "inactive/lr.bmp");
|
||||
init_sprite(INACTIVE + 8, TTK_FANCY_PATH "inactive/button-close.bmp");
|
||||
|
||||
decor_top_height = 33;
|
||||
decor_bottom_height = 6;
|
||||
decor_left_width = 6;
|
||||
decor_right_width = 6;
|
||||
|
||||
decor_render_decorations = render_decorations_fancy;
|
||||
decor_check_button_press = check_button_press_fancy;
|
||||
}
|
||||
|