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;
|
||||
/** Alignement */
|
||||
int alignment;
|
||||
Alignment alignment;
|
||||
/** Misc private data */
|
||||
void *data;
|
||||
/** Location on status bar */
|
||||
|
|
14
draw.c
14
draw.c
|
@ -121,12 +121,18 @@ draw_text(DrawCtx *ctx,
|
|||
buf[len - 3] = '.';
|
||||
}
|
||||
|
||||
if(align == AlignLeft)
|
||||
switch(align)
|
||||
{
|
||||
case AlignLeft:
|
||||
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);
|
||||
else
|
||||
break;
|
||||
default:
|
||||
cairo_move_to(cr, x + ((w - nw) / 2) + padding, y + font->ascent + (ctx->height - font->height) / 2);
|
||||
break;
|
||||
}
|
||||
cairo_show_text(cr, buf);
|
||||
|
||||
cairo_font_face_destroy(font_face);
|
||||
|
@ -309,7 +315,7 @@ textwidth(XftFont *font, char *text)
|
|||
return MAX(te.x_advance, te.width);
|
||||
}
|
||||
|
||||
int
|
||||
Alignment
|
||||
draw_get_align(const char *align)
|
||||
{
|
||||
if(!a_strncmp(align, "center", 6))
|
||||
|
|
10
draw.h
10
draw.h
|
@ -25,7 +25,13 @@
|
|||
#include <X11/Xlib.h>
|
||||
#include <X11/Xft/Xft.h>
|
||||
|
||||
enum { AlignLeft, AlignRight, AlignFlex, AlignCenter };
|
||||
typedef enum
|
||||
{
|
||||
AlignLeft,
|
||||
AlignRight,
|
||||
AlignFlex,
|
||||
AlignCenter
|
||||
} Alignment;
|
||||
|
||||
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);
|
||||
Drawable draw_rotate(DrawCtx *, int, double, int, int);
|
||||
unsigned short textwidth(XftFont *, char *);
|
||||
int draw_get_align(const char *);
|
||||
Alignment draw_get_align(const char *);
|
||||
|
||||
#endif
|
||||
// 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
|
||||
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 barwidth - offset - widgetwidth;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ extern AwesomeConf globalconf;
|
|||
|
||||
typedef struct
|
||||
{
|
||||
int align;
|
||||
Alignment align;
|
||||
XColor fg;
|
||||
XColor bg;
|
||||
} Data;
|
||||
|
|
|
@ -37,7 +37,7 @@ extern AwesomeConf globalconf;
|
|||
typedef struct
|
||||
{
|
||||
Bool show_icons;
|
||||
int align;
|
||||
Alignment align;
|
||||
XColor fg_sel;
|
||||
XColor bg_sel;
|
||||
XColor fg;
|
||||
|
|
|
@ -30,7 +30,7 @@ typedef struct
|
|||
{
|
||||
char *text;
|
||||
int width;
|
||||
int align;
|
||||
Alignment align;
|
||||
XColor fg;
|
||||
XColor bg;
|
||||
} Data;
|
||||
|
|
Loading…
Reference in New Issue