mirror of
https://github.com/FelixKratz/SketchyBar
synced 2024-11-23 03:43:02 +00:00
Merge branch 'master' into enhancement/fix/powerline_position
This commit is contained in:
commit
85547b5ea0
3 changed files with 16 additions and 51 deletions
|
@ -285,7 +285,6 @@ void bar_refresh(struct bar *bar)
|
||||||
if (has_batt) {
|
if (has_batt) {
|
||||||
char batt[255];
|
char batt[255];
|
||||||
snprintf(batt, sizeof(batt), "%' '3d%%", percent);
|
snprintf(batt, sizeof(batt), "%' '3d%%", percent);
|
||||||
|
|
||||||
struct bar_line batt_line = bar_prepare_line(g_bar_manager.t_font, batt, g_bar_manager.foreground_color);
|
struct bar_line batt_line = bar_prepare_line(g_bar_manager.t_font, batt, g_bar_manager.foreground_color);
|
||||||
CGPoint p_pos = bar_align_line(bar, batt_line, ALIGN_RIGHT, ALIGN_CENTER);
|
CGPoint p_pos = bar_align_line(bar, batt_line, ALIGN_RIGHT, ALIGN_CENTER);
|
||||||
p_pos.x = time_line_pos - 40;
|
p_pos.x = time_line_pos - 40;
|
||||||
|
|
|
@ -28,66 +28,35 @@ void bar_manager_set_text_font(struct bar_manager *bar_manager, char *font_strin
|
||||||
CFRelease(bar_manager->t_font);
|
CFRelease(bar_manager->t_font);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bar_manager->space_underline.line) {
|
|
||||||
bar_destroy_line(bar_manager->space_underline);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bar_manager->power_underline.line) {
|
|
||||||
bar_destroy_line(bar_manager->power_underline);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bar_manager->clock_underline.line) {
|
|
||||||
bar_destroy_line(bar_manager->clock_underline);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (font_string != bar_manager->t_font_prop) {
|
if (font_string != bar_manager->t_font_prop) {
|
||||||
if (bar_manager->t_font_prop) {
|
if (bar_manager->t_font_prop) {
|
||||||
free(bar_manager->t_font_prop);
|
free(bar_manager->t_font_prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
bar_manager->t_font_prop = font_string;
|
bar_manager->t_font_prop = font_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
bar_manager->t_font = bar_create_font(bar_manager->t_font_prop);
|
bar_manager->t_font = bar_create_font(bar_manager->t_font_prop);
|
||||||
bar_manager->space_underline = bar_prepare_line(bar_manager->t_font, "______", rgba_color_from_hex(0xffd4d232));
|
|
||||||
bar_manager->power_underline = bar_prepare_line(bar_manager->t_font, "__________", rgba_color_from_hex(0xffd75f5f));
|
|
||||||
|
|
||||||
time_t rawtime;
|
|
||||||
time(&rawtime);
|
|
||||||
struct tm *timeinfo = localtime(&rawtime);
|
|
||||||
if (timeinfo) {
|
|
||||||
char time[255];
|
|
||||||
strftime(time, sizeof(time), g_bar_manager._clock_format, timeinfo);
|
|
||||||
char underline[255] = {0};
|
|
||||||
|
|
||||||
for (int i = 0; i < strlen(time) + 4; ++i)
|
|
||||||
underline[i] = '_';
|
|
||||||
|
|
||||||
bar_manager->clock_underline = bar_prepare_line(bar_manager->t_font, underline, rgba_color_from_hex(0xff458588));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
bar_manager->clock_underline = bar_prepare_line(bar_manager->t_font, "__________", rgba_color_from_hex(0xff458588));
|
|
||||||
|
|
||||||
bar_manager_refresh(bar_manager);
|
bar_manager_refresh(bar_manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bar_manager_set_icon_font(struct bar_manager *bar_manager, char *font_string)
|
void bar_manager_set_icon_font(struct bar_manager *bar_manager, char *font_string)
|
||||||
{
|
{
|
||||||
if (bar_manager->i_font) {
|
if (bar_manager->i_font) {
|
||||||
CFRelease(bar_manager->i_font);
|
CFRelease(bar_manager->i_font);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (font_string != bar_manager->i_font_prop) {
|
||||||
|
if (bar_manager->i_font_prop) {
|
||||||
|
free(bar_manager->i_font_prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (font_string != bar_manager->i_font_prop) {
|
bar_manager->i_font_prop = font_string;
|
||||||
if (bar_manager->i_font_prop) {
|
}
|
||||||
free(bar_manager->i_font_prop);
|
|
||||||
}
|
|
||||||
|
|
||||||
bar_manager->i_font_prop = font_string;
|
bar_manager->i_font = bar_create_font(bar_manager->i_font_prop);
|
||||||
}
|
if (bar_manager->_space_icon_strip) bar_manager_set_space_strip(bar_manager, bar_manager->_space_icon_strip);
|
||||||
|
if (bar_manager->_power_icon_strip) bar_manager_set_power_strip(bar_manager, bar_manager->_power_icon_strip);
|
||||||
bar_manager->i_font = bar_create_font(bar_manager->i_font_prop);
|
|
||||||
if (bar_manager->_space_icon_strip) bar_manager_set_space_strip(bar_manager, bar_manager->_space_icon_strip);
|
|
||||||
if (bar_manager->_power_icon_strip) bar_manager_set_power_strip(bar_manager, bar_manager->_power_icon_strip);
|
|
||||||
if (bar_manager->_clock_icon) bar_manager_set_clock_icon(bar_manager, bar_manager->_clock_icon);
|
if (bar_manager->_clock_icon) bar_manager_set_clock_icon(bar_manager, bar_manager->_clock_icon);
|
||||||
if (bar_manager->_space_icon) bar_manager_set_space_icon(bar_manager, bar_manager->_space_icon);
|
if (bar_manager->_space_icon) bar_manager_set_space_icon(bar_manager, bar_manager->_space_icon);
|
||||||
bar_manager_refresh(bar_manager);
|
bar_manager_refresh(bar_manager);
|
||||||
|
|
|
@ -23,9 +23,6 @@ struct bar_manager
|
||||||
struct bar_line clock_icon;
|
struct bar_line clock_icon;
|
||||||
struct bar_line battr_icon;
|
struct bar_line battr_icon;
|
||||||
struct bar_line power_icon;
|
struct bar_line power_icon;
|
||||||
struct bar_line space_underline;
|
|
||||||
struct bar_line power_underline;
|
|
||||||
struct bar_line clock_underline;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void bar_manager_set_foreground_color(struct bar_manager *bar_manager, uint32_t color);
|
void bar_manager_set_foreground_color(struct bar_manager *bar_manager, uint32_t color);
|
||||||
|
|
Loading…
Reference in a new issue