mirror of
https://github.com/labwc/labwc.git
synced 2026-03-05 01:40:24 -05:00
common/font: Add scale argument
This commit is contained in:
parent
2aaf26e87b
commit
f3a685155d
4 changed files with 10 additions and 10 deletions
|
|
@ -24,7 +24,7 @@ int font_height(struct font *font);
|
||||||
* @color: foreground color in rgba format
|
* @color: foreground color in rgba format
|
||||||
*/
|
*/
|
||||||
void font_buffer_create(struct lab_data_buffer **buffer, int max_width,
|
void font_buffer_create(struct lab_data_buffer **buffer, int max_width,
|
||||||
const char *text, struct font *font, float *color);
|
const char *text, struct font *font, float *color, double scale);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* font_buffer_update - Wrapper around font_buffer_create
|
* font_buffer_update - Wrapper around font_buffer_create
|
||||||
|
|
@ -32,7 +32,7 @@ void font_buffer_create(struct lab_data_buffer **buffer, int max_width,
|
||||||
* wlr_buffer_drop() will be called on the buffer.
|
* wlr_buffer_drop() will be called on the buffer.
|
||||||
*/
|
*/
|
||||||
void font_buffer_update(struct lab_data_buffer **buffer, int max_width,
|
void font_buffer_update(struct lab_data_buffer **buffer, int max_width,
|
||||||
const char *text, struct font *font, float *color);
|
const char *text, struct font *font, float *color, double scale);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* font_finish - free some font related resources
|
* font_finish - free some font related resources
|
||||||
|
|
|
||||||
|
|
@ -51,18 +51,18 @@ font_height(struct font *font)
|
||||||
|
|
||||||
void
|
void
|
||||||
font_buffer_update(struct lab_data_buffer **buffer, int max_width,
|
font_buffer_update(struct lab_data_buffer **buffer, int max_width,
|
||||||
const char *text, struct font *font, float *color)
|
const char *text, struct font *font, float *color, double scale)
|
||||||
{
|
{
|
||||||
if (*buffer) {
|
if (*buffer) {
|
||||||
wlr_buffer_drop(&(*buffer)->base);
|
wlr_buffer_drop(&(*buffer)->base);
|
||||||
*buffer = NULL;
|
*buffer = NULL;
|
||||||
}
|
}
|
||||||
font_buffer_create(buffer, max_width, text, font, color);
|
font_buffer_create(buffer, max_width, text, font, color, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
font_buffer_create(struct lab_data_buffer **buffer, int max_width,
|
font_buffer_create(struct lab_data_buffer **buffer, int max_width,
|
||||||
const char *text, struct font *font, float *color)
|
const char *text, struct font *font, float *color, double scale)
|
||||||
{
|
{
|
||||||
if (!text || !*text) {
|
if (!text || !*text) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -72,8 +72,7 @@ font_buffer_create(struct lab_data_buffer **buffer, int max_width,
|
||||||
if (max_width && rect.width > max_width) {
|
if (max_width && rect.width > max_width) {
|
||||||
rect.width = max_width;
|
rect.width = max_width;
|
||||||
}
|
}
|
||||||
/* TODO: scale */
|
*buffer = buffer_create_cairo(rect.width, rect.height, scale, true);
|
||||||
*buffer = buffer_create_cairo(rect.width, rect.height, 1, true);
|
|
||||||
if (!*buffer) {
|
if (!*buffer) {
|
||||||
wlr_log(WLR_ERROR, "Failed to create font buffer of size %dx%d",
|
wlr_log(WLR_ERROR, "Failed to create font buffer of size %dx%d",
|
||||||
rect.width, rect.height);
|
rect.width, rect.height);
|
||||||
|
|
|
||||||
|
|
@ -99,9 +99,9 @@ item_create(struct menu *menu, const char *text)
|
||||||
|
|
||||||
/* Font buffer */
|
/* Font buffer */
|
||||||
font_buffer_create(&menuitem->normal.buffer, item_max_width,
|
font_buffer_create(&menuitem->normal.buffer, item_max_width,
|
||||||
text, &font, theme->menu_items_text_color);
|
text, &font, theme->menu_items_text_color, 1);
|
||||||
font_buffer_create(&menuitem->selected.buffer, item_max_width,
|
font_buffer_create(&menuitem->selected.buffer, item_max_width,
|
||||||
text, &font, theme->menu_items_active_text_color);
|
text, &font, theme->menu_items_active_text_color, 1);
|
||||||
if (!menuitem->normal.buffer || !menuitem->selected.buffer) {
|
if (!menuitem->normal.buffer || !menuitem->selected.buffer) {
|
||||||
wlr_log(WLR_ERROR, "Failed to create menu item '%s'", text);
|
wlr_log(WLR_ERROR, "Failed to create menu item '%s'", text);
|
||||||
if (menuitem->normal.buffer) {
|
if (menuitem->normal.buffer) {
|
||||||
|
|
|
||||||
|
|
@ -247,7 +247,8 @@ ssd_update_title(struct view *view)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Generate and update the lab_data_buffer, drops the old buffer */
|
/* Generate and update the lab_data_buffer, drops the old buffer */
|
||||||
font_buffer_update(&part->buffer, title_bg_width, title, &font, text_color);
|
font_buffer_update(&part->buffer, title_bg_width, title, &font,
|
||||||
|
text_color, 1);
|
||||||
if (!part->buffer) {
|
if (!part->buffer) {
|
||||||
/* This can happen for example by defining a font size of 0 */
|
/* This can happen for example by defining a font size of 0 */
|
||||||
wlr_log(WLR_ERROR, "Failed to create title buffer");
|
wlr_log(WLR_ERROR, "Failed to create title buffer");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue