mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
feat: implement <font place="InactiveWindow"> (ref scope: 2.4.7) (#1292)
* feat: implement <font place="InactiveWindow"> (ref scope: 2.4.7) * docs: add inactivewindow
This commit is contained in:
parent
d59b1d0966
commit
b34d074063
6 changed files with 25 additions and 3 deletions
|
|
@ -238,6 +238,7 @@ windows using the mouse.
|
|||
The font to use for a specific element of a window, menu or OSD.
|
||||
Places can be any of:
|
||||
- ActiveWindow - titlebar of active window
|
||||
- InactiveWindow - titlebar of all windows that aren't focused by the cursor
|
||||
- MenuItem - menu item (currently only root menu)
|
||||
- OnScreenDisplay - items in the on screen display
|
||||
If no place attribute is provided, the setting will be applied to all
|
||||
|
|
|
|||
|
|
@ -25,6 +25,12 @@
|
|||
<slant>normal</slant>
|
||||
<weight>normal</weight>
|
||||
</font>
|
||||
<font place="InactiveWindow">
|
||||
<name>sans</name>
|
||||
<size>10</size>
|
||||
<slant>normal</slant>
|
||||
<weight>normal</weight>
|
||||
</font>
|
||||
<font place="MenuItem">
|
||||
<name>sans</name>
|
||||
<size>10</size>
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ struct rcxml {
|
|||
int corner_radius;
|
||||
bool ssd_keep_border;
|
||||
struct font font_activewindow;
|
||||
struct font font_inactivewindow;
|
||||
struct font font_menuitem;
|
||||
struct font font_osd;
|
||||
/* Pointer to current theme */
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ enum font_place {
|
|||
FONT_PLACE_NONE = 0,
|
||||
FONT_PLACE_UNKNOWN,
|
||||
FONT_PLACE_ACTIVEWINDOW,
|
||||
FONT_PLACE_INACTIVEWINDOW,
|
||||
FONT_PLACE_MENUITEM,
|
||||
FONT_PLACE_OSD,
|
||||
/* TODO: Add all places based on Openbox's rc.xml */
|
||||
|
|
@ -564,12 +565,16 @@ fill_font(char *nodename, char *content, enum font_place place)
|
|||
* attribute, we set all font variables
|
||||
*/
|
||||
set_font_attr(&rc.font_activewindow, nodename, content);
|
||||
set_font_attr(&rc.font_inactivewindow, nodename, content);
|
||||
set_font_attr(&rc.font_menuitem, nodename, content);
|
||||
set_font_attr(&rc.font_osd, nodename, content);
|
||||
break;
|
||||
case FONT_PLACE_ACTIVEWINDOW:
|
||||
set_font_attr(&rc.font_activewindow, nodename, content);
|
||||
break;
|
||||
case FONT_PLACE_INACTIVEWINDOW:
|
||||
set_font_attr(&rc.font_inactivewindow, nodename, content);
|
||||
break;
|
||||
case FONT_PLACE_MENUITEM:
|
||||
set_font_attr(&rc.font_menuitem, nodename, content);
|
||||
break;
|
||||
|
|
@ -592,6 +597,8 @@ enum_font_place(const char *place)
|
|||
}
|
||||
if (!strcasecmp(place, "ActiveWindow")) {
|
||||
return FONT_PLACE_ACTIVEWINDOW;
|
||||
} else if (!strcasecmp(place, "InactiveWindow")) {
|
||||
return FONT_PLACE_INACTIVEWINDOW;
|
||||
} else if (!strcasecmp(place, "MenuItem")) {
|
||||
return FONT_PLACE_MENUITEM;
|
||||
} else if (!strcasecmp(place, "OnScreenDisplay")
|
||||
|
|
@ -949,6 +956,7 @@ rcxml_init(void)
|
|||
rc.corner_radius = 8;
|
||||
|
||||
init_font_defaults(&rc.font_activewindow);
|
||||
init_font_defaults(&rc.font_inactivewindow);
|
||||
init_font_defaults(&rc.font_menuitem);
|
||||
init_font_defaults(&rc.font_osd);
|
||||
|
||||
|
|
@ -1256,6 +1264,9 @@ post_processing(void)
|
|||
if (!rc.font_activewindow.name) {
|
||||
rc.font_activewindow.name = xstrdup("sans");
|
||||
}
|
||||
if (!rc.font_inactivewindow.name) {
|
||||
rc.font_inactivewindow.name = xstrdup("sans");
|
||||
}
|
||||
if (!rc.font_menuitem.name) {
|
||||
rc.font_menuitem.name = xstrdup("sans");
|
||||
}
|
||||
|
|
@ -1440,6 +1451,7 @@ void
|
|||
rcxml_finish(void)
|
||||
{
|
||||
zfree(rc.font_activewindow.name);
|
||||
zfree(rc.font_inactivewindow.name);
|
||||
zfree(rc.font_menuitem.name);
|
||||
zfree(rc.font_osd.name);
|
||||
zfree(rc.theme_name);
|
||||
|
|
|
|||
|
|
@ -317,6 +317,7 @@ ssd_update_title(struct ssd *ssd)
|
|||
bool title_unchanged = state->text && !strcmp(title, state->text);
|
||||
|
||||
float *text_color;
|
||||
struct font *font = NULL;
|
||||
struct ssd_part *part;
|
||||
struct ssd_sub_tree *subtree;
|
||||
struct ssd_state_title_width *dstate;
|
||||
|
|
@ -327,9 +328,11 @@ ssd_update_title(struct ssd *ssd)
|
|||
if (subtree == &ssd->titlebar.active) {
|
||||
dstate = &state->active;
|
||||
text_color = theme->window_active_label_text_color;
|
||||
font = &rc.font_activewindow;
|
||||
} else {
|
||||
dstate = &state->inactive;
|
||||
text_color = theme->window_inactive_label_text_color;
|
||||
font = &rc.font_inactivewindow;
|
||||
}
|
||||
|
||||
if (title_bg_width <= 0) {
|
||||
|
|
@ -356,9 +359,8 @@ ssd_update_title(struct ssd *ssd)
|
|||
}
|
||||
|
||||
if (part->buffer) {
|
||||
/* TODO: Do we only have active window fonts? */
|
||||
scaled_font_buffer_update(part->buffer, title,
|
||||
title_bg_width, &rc.font_activewindow,
|
||||
title_bg_width, font,
|
||||
text_color, NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -848,7 +848,7 @@ create_corners(struct theme *theme)
|
|||
static void
|
||||
post_processing(struct theme *theme)
|
||||
{
|
||||
int h = font_height(&rc.font_activewindow);
|
||||
int h = MAX(font_height(&rc.font_activewindow), font_height(&rc.font_inactivewindow));
|
||||
if (theme->title_height < h) {
|
||||
theme->title_height = h + 2 * theme->padding_height;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue