use image instead of symbols for layouts

This commit is contained in:
Julien Danjou 2007-12-27 00:13:44 +01:00
parent e77fe9c2a0
commit 91cc5a4618
20 changed files with 44 additions and 40 deletions

View File

@ -87,7 +87,7 @@ cleanup_screen(int screen)
for(l = globalconf.screens[screen].layouts; l; l = ln)
{
ln = l->next;
p_delete(&l->symbol);
p_delete(&l->image);
p_delete(&l);
}
}

View File

@ -14,21 +14,22 @@ screen 0
}
layouts
{
layout tile { symbol = "[]=" }
layout tileleft { symbol = "=[]" }
layout max { symbol = "[ ]" }
layout spiral { symbol = "(@)" }
layout dwindle { symbol = "[\\]" }
layout floating { symbol = "><>" }
layout tile { image = "tile.png" }
layout tileleft { image = "tileleft.png" }
layout max { image = "max.png" }
layout spiral { image = "spiral.png" }
layout dwindle { image = "dwindle.png" }
layout floating { image = "floating.png" }
}
statusbar
{
position = "top"
taglist tl {}
layoutinfo li {}
netwmicon nwi {}
focustitle ft {}
textbox tb {}
taglist mytaglist {}
layoutinfo mylayoutinfo {}
netwmicon mynetwmicon {}
focustitle myfocustitle {}
textbox mytextbox {}
}
}

View File

@ -382,7 +382,7 @@ config_parse(const char *confpatharg)
};
static cfg_opt_t layout_opts[] =
{
CFG_STR((char *) "symbol", (char *) "???", CFGF_NONE),
CFG_STR((char *) "image", NULL, CFGF_NONE),
CFG_END()
};
static cfg_opt_t layouts_opts[] =
@ -587,10 +587,10 @@ config_parse(const char *confpatharg)
if(!layout->arrange)
{
warn("unknown layout %s in configuration file\n", cfg_title(cfgsectmp));
layout->symbol = NULL;
layout->image = NULL;
continue;
}
layout->symbol = a_strdup(cfg_getstr(cfgsectmp, "symbol"));
layout->image = a_strdup(cfg_getstr(cfgsectmp, "image"));
if(i < cfg_size(cfg_layouts, "layout") - 1)
layout = layout->next = p_new(Layout, 1);

View File

@ -55,7 +55,7 @@ typedef struct AwesomeConf AwesomeConf;
typedef struct Layout Layout;
struct Layout
{
char *symbol;
char *image;
void (*arrange) (int);
Layout *next;
};

16
draw.c
View File

@ -175,20 +175,31 @@ void draw_image_from_argb_data(DrawCtx *ctx, int x, int y, int w, int h,
}
void
draw_image(DrawCtx *ctx, int x, int y, const char *filename)
draw_image(DrawCtx *ctx, int x, int y, int wanted_h, const char *filename)
{
double ratio;
int h;
cairo_surface_t *surface, *source;
cairo_t *cr;
source = cairo_xlib_surface_create(ctx->display, ctx->drawable, ctx->visual, ctx->width, ctx->height);
surface = cairo_image_surface_create_from_png(filename);
cr = cairo_create (source);
cairo_set_source_surface(cr, surface, x, y);
if(wanted_h > 0 && (h = cairo_image_surface_get_height(surface)) > 0)
{
ratio = (double) wanted_h / (double) h;
cairo_scale(cr, ratio, ratio);
cairo_set_source_surface(cr, surface, x / ratio, y / ratio);
}
else
cairo_set_source_surface(cr, surface, x, y);
cairo_paint(cr);
cairo_destroy(cr);
cairo_surface_destroy(source);
cairo_surface_destroy(surface);
}
int
@ -205,7 +216,6 @@ draw_get_image_width(const char *filename)
return width;
}
Drawable
draw_rotate(DrawCtx *ctx, int screen, double angle, int tx, int ty)
{

2
draw.h
View File

@ -41,7 +41,7 @@ void draw_free_context(DrawCtx*);
void draw_text(DrawCtx *, int, int, int, int, XftFont *, const char *, XColor fg, XColor bg);
void draw_rectangle(DrawCtx *, int, int, int, int, Bool, XColor);
void draw_circle(DrawCtx *, int, int, int, Bool, XColor);
void draw_image(DrawCtx *, int, int, const char *);
void draw_image(DrawCtx *, int, int, int, const char *);
void draw_image_from_argb_data(DrawCtx *, int, int, int, int, int, unsigned char *);
int draw_get_image_width(const char *filename);
Drawable draw_rotate(DrawCtx *, int, double, int, int);

BIN
icons/layouts/dwindle.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

BIN
icons/layouts/dwindlew.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

BIN
icons/layouts/floating.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

BIN
icons/layouts/floatingw.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

BIN
icons/layouts/max.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
icons/layouts/maxw.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
icons/layouts/spiral.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
icons/layouts/spiralw.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
icons/layouts/tile.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
icons/layouts/tileleft.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
icons/layouts/tileleftw.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
icons/layouts/tilew.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -29,17 +29,16 @@ static int
iconbox_draw(Widget *widget, DrawCtx *ctx, int offset,
int used __attribute__ ((unused)))
{
VirtScreen vscreen = globalconf.screens[widget->statusbar->screen];
int location, width;
width = draw_get_image_width(widget->data);
location = widget_calculate_offset(vscreen.statusbar->width,
location = widget_calculate_offset(widget->statusbar->width,
width,
offset,
widget->alignment);
draw_image(ctx, location, 0, widget->data);
draw_image(ctx, location, 0, 0, widget->data);
return width;
}

View File

@ -2,6 +2,8 @@
* layoutinfo.c - layout info widget
*
* Copyright © 2007 Aldo Cortesi <aldo@nullcube.com>
* Copyright © 2007 Julien Danjou <julien@danjou.info>
* Aldo Cortesi <aldo@nullcube.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -32,23 +34,15 @@ layoutinfo_draw(Widget *widget,
int offset,
int used __attribute__ ((unused)))
{
int width = 0, location;
VirtScreen vscreen = globalconf.screens[widget->statusbar->screen];
Layout *l;
for(l = vscreen.layouts ; l; l = l->next)
width = MAX(width, (textwidth(ctx, vscreen.font, l->symbol)));
location = widget_calculate_offset(vscreen.statusbar->width,
width,
offset,
widget->alignment);
draw_text(ctx, location, 0,
width,
vscreen.statusbar->height,
vscreen.font,
get_current_layout(widget->statusbar->screen)->symbol,
vscreen.colors_normal[ColFG],
vscreen.colors_normal[ColBG]);
return width;
int location = widget_calculate_offset(widget->statusbar->width,
widget->statusbar->height,
offset,
widget->alignment);
draw_image(ctx, location, 0, widget->statusbar->height,
get_current_layout(widget->statusbar->screen)->image);
return widget->statusbar->height;
}
Widget *