最適化
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
#include "display.h"
|
||||
#include "program.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
void drawbuttons(UiSystem *ui, SuwaButton *btn, XftDraw *xftdraw) {
|
||||
unsigned long curbg = btn->pressed ? BTSEL : BTCOL;
|
||||
unsigned long curbg = btn->pressed ? BTSEL : btn->bg_color;
|
||||
XSetForeground(ui->display, ui->gc, curbg);
|
||||
XFillRectangle(ui->display, ui->target, ui->gc, btn->x, btn->y,
|
||||
btn->width, btn->height);
|
||||
|
||||
// 文字の中央に
|
||||
if (btn->label && ui->font && xftdraw) {
|
||||
const FcChar8 *str = (const FcChar8 *)btn->label;
|
||||
if (btn->text && ui->font && xftdraw) {
|
||||
const FcChar8 *str = (const FcChar8 *)btn->text;
|
||||
int len = strlen((const char *)str);
|
||||
|
||||
XGlyphInfo extents;
|
||||
@@ -23,9 +22,7 @@ void drawbuttons(UiSystem *ui, SuwaButton *btn, XftDraw *xftdraw) {
|
||||
int tx = btn->x + (btn->width - text_w) / 2;
|
||||
int ty = btn->y + (btn->height - text_h) / 2 + ui->font->ascent;
|
||||
|
||||
// tx -= extents.x;
|
||||
|
||||
XftDrawStringUtf8(xftdraw, &ui->color, ui->font, tx, ty,
|
||||
(FcChar8 *)btn->label, len);
|
||||
(FcChar8 *)btn->text, len);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user