typedef enum Alignment
This commit is contained in:
parent
af6ff367eb
commit
1d6613349e
2
config.h
2
config.h
|
@ -103,7 +103,7 @@ struct Widget
|
||||||
/** Statusbar */
|
/** Statusbar */
|
||||||
Statusbar *statusbar;
|
Statusbar *statusbar;
|
||||||
/** Alignement */
|
/** Alignement */
|
||||||
int alignment;
|
Alignment alignment;
|
||||||
/** Misc private data */
|
/** Misc private data */
|
||||||
void *data;
|
void *data;
|
||||||
/** Location on status bar */
|
/** Location on status bar */
|
||||||
|
|
14
draw.c
14
draw.c
|
@ -121,12 +121,18 @@ draw_text(DrawCtx *ctx,
|
||||||
buf[len - 3] = '.';
|
buf[len - 3] = '.';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(align == AlignLeft)
|
switch(align)
|
||||||
|
{
|
||||||
|
case AlignLeft:
|
||||||
cairo_move_to(cr, x + padding, y + font->ascent + (ctx->height - font->height) / 2);
|
cairo_move_to(cr, x + padding, y + font->ascent + (ctx->height - font->height) / 2);
|
||||||
else if(align == AlignRight)
|
break;
|
||||||
|
case AlignRight:
|
||||||
cairo_move_to(cr, x + (w - nw) + padding, y + font->ascent + (ctx->height - font->height) / 2);
|
cairo_move_to(cr, x + (w - nw) + padding, y + font->ascent + (ctx->height - font->height) / 2);
|
||||||
else
|
break;
|
||||||
|
default:
|
||||||
cairo_move_to(cr, x + ((w - nw) / 2) + padding, y + font->ascent + (ctx->height - font->height) / 2);
|
cairo_move_to(cr, x + ((w - nw) / 2) + padding, y + font->ascent + (ctx->height - font->height) / 2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
cairo_show_text(cr, buf);
|
cairo_show_text(cr, buf);
|
||||||
|
|
||||||
cairo_font_face_destroy(font_face);
|
cairo_font_face_destroy(font_face);
|
||||||
|
@ -309,7 +315,7 @@ textwidth(XftFont *font, char *text)
|
||||||
return MAX(te.x_advance, te.width);
|
return MAX(te.x_advance, te.width);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
Alignment
|
||||||
draw_get_align(const char *align)
|
draw_get_align(const char *align)
|
||||||
{
|
{
|
||||||
if(!a_strncmp(align, "center", 6))
|
if(!a_strncmp(align, "center", 6))
|
||||||
|
|
10
draw.h
10
draw.h
|
@ -25,7 +25,13 @@
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xft/Xft.h>
|
#include <X11/Xft/Xft.h>
|
||||||
|
|
||||||
enum { AlignLeft, AlignRight, AlignFlex, AlignCenter };
|
typedef enum
|
||||||
|
{
|
||||||
|
AlignLeft,
|
||||||
|
AlignRight,
|
||||||
|
AlignFlex,
|
||||||
|
AlignCenter
|
||||||
|
} Alignment;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -56,7 +62,7 @@ void draw_image_from_argb_data(DrawCtx *, int, int, int, int, int, unsigned char
|
||||||
Area draw_get_image_size(const char *filename);
|
Area draw_get_image_size(const char *filename);
|
||||||
Drawable draw_rotate(DrawCtx *, int, double, int, int);
|
Drawable draw_rotate(DrawCtx *, int, double, int, int);
|
||||||
unsigned short textwidth(XftFont *, char *);
|
unsigned short textwidth(XftFont *, char *);
|
||||||
int draw_get_align(const char *);
|
Alignment draw_get_align(const char *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||||
|
|
6
widget.c
6
widget.c
|
@ -66,8 +66,12 @@ widget_calculate_alignments(Widget *widget)
|
||||||
int
|
int
|
||||||
widget_calculate_offset(int barwidth, int widgetwidth, int offset, int alignment)
|
widget_calculate_offset(int barwidth, int widgetwidth, int offset, int alignment)
|
||||||
{
|
{
|
||||||
if (alignment == AlignLeft || alignment == AlignFlex)
|
switch(alignment)
|
||||||
|
{
|
||||||
|
case AlignLeft:
|
||||||
|
case AlignFlex:
|
||||||
return offset;
|
return offset;
|
||||||
|
}
|
||||||
return barwidth - offset - widgetwidth;
|
return barwidth - offset - widgetwidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ extern AwesomeConf globalconf;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int align;
|
Alignment align;
|
||||||
XColor fg;
|
XColor fg;
|
||||||
XColor bg;
|
XColor bg;
|
||||||
} Data;
|
} Data;
|
||||||
|
|
|
@ -37,7 +37,7 @@ extern AwesomeConf globalconf;
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
Bool show_icons;
|
Bool show_icons;
|
||||||
int align;
|
Alignment align;
|
||||||
XColor fg_sel;
|
XColor fg_sel;
|
||||||
XColor bg_sel;
|
XColor bg_sel;
|
||||||
XColor fg;
|
XColor fg;
|
||||||
|
|
|
@ -30,7 +30,7 @@ typedef struct
|
||||||
{
|
{
|
||||||
char *text;
|
char *text;
|
||||||
int width;
|
int width;
|
||||||
int align;
|
Alignment align;
|
||||||
XColor fg;
|
XColor fg;
|
||||||
XColor bg;
|
XColor bg;
|
||||||
} Data;
|
} Data;
|
||||||
|
|
Loading…
Reference in New Issue