REF move font specs into common module
This commit is contained in:
parent
b33cf3933f
commit
42535dfcb5
2
core
2
core
|
@ -1 +1 @@
|
||||||
Subproject commit b1034354e38299cf997ddface80aaf43a4de8523
|
Subproject commit f15bbe1bb31f75aad4b49566a11092e25a559205
|
|
@ -17,6 +17,18 @@ local HEADER_UNDERLINE_CAP = CAIRO_LINE_CAP_ROUND
|
||||||
local HEADER_UNDERLINE_OFFSET = -20
|
local HEADER_UNDERLINE_OFFSET = -20
|
||||||
local HEADER_UNDERLINE_THICKNESS = 3
|
local HEADER_UNDERLINE_THICKNESS = 3
|
||||||
|
|
||||||
|
M.make_font_spec = function(f, s, bold)
|
||||||
|
return {
|
||||||
|
family = f,
|
||||||
|
size = s,
|
||||||
|
weight = bold and CAIRO_FONT_WEIGHT_BOLD or CAIRO_FONT_WEIGHT_NORMAL,
|
||||||
|
slant = CAIRO_FONT_WEIGHT_NORMAL,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
M.normal_font_spec = M.make_font_spec(_G_Patterns_.FONT, 13, false)
|
||||||
|
M.label_font_spec = M.make_font_spec(_G_Patterns_.FONT, 8, false)
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- header
|
-- header
|
||||||
|
|
||||||
|
@ -30,12 +42,13 @@ M.Header = function(x, y, w, s)
|
||||||
x = x,
|
x = x,
|
||||||
y = y,
|
y = y,
|
||||||
text = s,
|
text = s,
|
||||||
font_size = HEADER_FONT_SIZE,
|
font_spec = M.make_font_spec(_G_Patterns_.FONT, HEADER_FONT_SIZE, true),
|
||||||
|
-- font_size = HEADER_FONT_SIZE,
|
||||||
x_align = 'left',
|
x_align = 'left',
|
||||||
y_align = 'top',
|
y_align = 'top',
|
||||||
text_color = _G_Patterns_.HEADER_FG,
|
text_color = _G_Patterns_.HEADER_FG,
|
||||||
slant = HEADER_FONT_SLANT,
|
-- slant = HEADER_FONT_SLANT,
|
||||||
weight = HEADER_FONT_WEIGHT
|
-- weight = HEADER_FONT_WEIGHT
|
||||||
},
|
},
|
||||||
bottom_y = bottom_y,
|
bottom_y = bottom_y,
|
||||||
underline = _G_Widget_.Line{
|
underline = _G_Widget_.Line{
|
||||||
|
@ -69,6 +82,7 @@ M.initThemedLabelPlot = function(x, y, w, h)
|
||||||
data_line_pattern = _G_Patterns_.PLOT_FILL_BORDER_PRIMARY,
|
data_line_pattern = _G_Patterns_.PLOT_FILL_BORDER_PRIMARY,
|
||||||
data_fill_pattern = _G_Patterns_.PLOT_FILL_BG_PRIMARY,
|
data_fill_pattern = _G_Patterns_.PLOT_FILL_BG_PRIMARY,
|
||||||
label_color = _G_Patterns_.INACTIVE_TEXT_FG,
|
label_color = _G_Patterns_.INACTIVE_TEXT_FG,
|
||||||
|
label_font_spec = M.label_font_spec,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -82,6 +96,7 @@ M.initPercentPlot = function(x, y, w, h, spacing, label)
|
||||||
y = y,
|
y = y,
|
||||||
text = label,
|
text = label,
|
||||||
text_color = _G_Patterns_.INACTIVE_TEXT_FG,
|
text_color = _G_Patterns_.INACTIVE_TEXT_FG,
|
||||||
|
font_spec = M.normal_font_spec,
|
||||||
},
|
},
|
||||||
value = _G_Widget_.CriticalText{
|
value = _G_Widget_.CriticalText{
|
||||||
x = x + w,
|
x = x + w,
|
||||||
|
@ -91,6 +106,7 @@ M.initPercentPlot = function(x, y, w, h, spacing, label)
|
||||||
critical_limit = '>80',
|
critical_limit = '>80',
|
||||||
text_color = _G_Patterns_.PRIMARY_FG,
|
text_color = _G_Patterns_.PRIMARY_FG,
|
||||||
critical_color = _G_Patterns_.PRIMARY_FG,
|
critical_color = _G_Patterns_.PRIMARY_FG,
|
||||||
|
font_spec = M.normal_font_spec,
|
||||||
},
|
},
|
||||||
plot = M.initThemedLabelPlot(x, y + spacing, w, h),
|
plot = M.initThemedLabelPlot(x, y + spacing, w, h),
|
||||||
}
|
}
|
||||||
|
@ -126,6 +142,7 @@ M.initThemedScalePlot = function(x, y, w, h, f)
|
||||||
data_line_pattern = _G_Patterns_.PLOT_FILL_BORDER_PRIMARY,
|
data_line_pattern = _G_Patterns_.PLOT_FILL_BORDER_PRIMARY,
|
||||||
data_fill_pattern = _G_Patterns_.PLOT_FILL_BG_PRIMARY,
|
data_fill_pattern = _G_Patterns_.PLOT_FILL_BG_PRIMARY,
|
||||||
label_color = _G_Patterns_.INACTIVE_TEXT_FG,
|
label_color = _G_Patterns_.INACTIVE_TEXT_FG,
|
||||||
|
label_font_spec = M.label_font_spec,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -139,12 +156,14 @@ M.initLabeledScalePlot = function(x, y, w, h, f, spacing, label)
|
||||||
y = y,
|
y = y,
|
||||||
text = label,
|
text = label,
|
||||||
text_color = _G_Patterns_.INACTIVE_TEXT_FG,
|
text_color = _G_Patterns_.INACTIVE_TEXT_FG,
|
||||||
|
font_spec = M.normal_font_spec,
|
||||||
},
|
},
|
||||||
value = _G_Widget_.Text{
|
value = _G_Widget_.Text{
|
||||||
x = x + w,
|
x = x + w,
|
||||||
y = y,
|
y = y,
|
||||||
x_align = 'right',
|
x_align = 'right',
|
||||||
text_color = _G_Patterns_.PRIMARY_FG
|
text_color = _G_Patterns_.PRIMARY_FG,
|
||||||
|
font_spec = M.normal_font_spec,
|
||||||
},
|
},
|
||||||
plot = M.initThemedScalePlot(x, y + spacing, w, h, f),
|
plot = M.initThemedScalePlot(x, y + spacing, w, h, f),
|
||||||
}
|
}
|
||||||
|
@ -194,6 +213,7 @@ M.initTextRing = function(x, y, r, append_end, limit)
|
||||||
critical_limit = limit,
|
critical_limit = limit,
|
||||||
text_color = _G_Patterns_.PRIMARY_FG,
|
text_color = _G_Patterns_.PRIMARY_FG,
|
||||||
critical_color = _G_Patterns_.CRITICAL_FG,
|
critical_color = _G_Patterns_.CRITICAL_FG,
|
||||||
|
font_spec = M.normal_font_spec,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -231,6 +251,7 @@ M.initTextRow = function(x, y, w, label)
|
||||||
y = y,
|
y = y,
|
||||||
text_color = _G_Patterns_.INACTIVE_TEXT_FG,
|
text_color = _G_Patterns_.INACTIVE_TEXT_FG,
|
||||||
text = label,
|
text = label,
|
||||||
|
font_spec = M.normal_font_spec,
|
||||||
},
|
},
|
||||||
value = _G_Widget_.Text{
|
value = _G_Widget_.Text{
|
||||||
x = x + w,
|
x = x + w,
|
||||||
|
@ -238,6 +259,7 @@ M.initTextRow = function(x, y, w, label)
|
||||||
x_align = 'right',
|
x_align = 'right',
|
||||||
text_color = _G_Patterns_.PRIMARY_FG,
|
text_color = _G_Patterns_.PRIMARY_FG,
|
||||||
text = "<NA>",
|
text = "<NA>",
|
||||||
|
font_spec = M.normal_font_spec,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -265,6 +287,7 @@ M.initTextRowCrit = function(x, y, w, label, append_end)
|
||||||
y = y,
|
y = y,
|
||||||
text = label,
|
text = label,
|
||||||
text_color = _G_Patterns_.INACTIVE_TEXT_FG,
|
text_color = _G_Patterns_.INACTIVE_TEXT_FG,
|
||||||
|
font_spec = M.normal_font_spec,
|
||||||
},
|
},
|
||||||
value = _G_Widget_.CriticalText{
|
value = _G_Widget_.CriticalText{
|
||||||
x = x + w,
|
x = x + w,
|
||||||
|
@ -274,6 +297,7 @@ M.initTextRowCrit = function(x, y, w, label, append_end)
|
||||||
critical_color = _G_Patterns_.CRITICAL_FG,
|
critical_color = _G_Patterns_.CRITICAL_FG,
|
||||||
append_end = append_end,
|
append_end = append_end,
|
||||||
text = '<NA>',
|
text = '<NA>',
|
||||||
|
font_spec = M.normal_font_spec,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -298,6 +322,7 @@ M.initTextRows = function(x, y, w, spacing, labels)
|
||||||
y = y,
|
y = y,
|
||||||
spacing = spacing,
|
spacing = spacing,
|
||||||
text_color = _G_Patterns_.INACTIVE_TEXT_FG,
|
text_color = _G_Patterns_.INACTIVE_TEXT_FG,
|
||||||
|
font_spec = M.normal_font_spec,
|
||||||
table.unpack(labels),
|
table.unpack(labels),
|
||||||
},
|
},
|
||||||
values = _G_Widget_.TextColumn{
|
values = _G_Widget_.TextColumn{
|
||||||
|
@ -306,6 +331,7 @@ M.initTextRows = function(x, y, w, spacing, labels)
|
||||||
spacing = spacing,
|
spacing = spacing,
|
||||||
x_align = 'right',
|
x_align = 'right',
|
||||||
text_color = _G_Patterns_.PRIMARY_FG,
|
text_color = _G_Patterns_.PRIMARY_FG,
|
||||||
|
font_spec = M.normal_font_spec,
|
||||||
num_rows = #labels,
|
num_rows = #labels,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,6 +363,8 @@ M.initTable = function(x, y, w, h, n, labels)
|
||||||
header_color = _G_Patterns_.PRIMARY_FG,
|
header_color = _G_Patterns_.PRIMARY_FG,
|
||||||
line_pattern = _G_Patterns_.BORDER_FG,
|
line_pattern = _G_Patterns_.BORDER_FG,
|
||||||
separator_pattern = _G_Patterns_.BORDER_FG,
|
separator_pattern = _G_Patterns_.BORDER_FG,
|
||||||
|
body_font_spec = M.make_font_spec(_G_Patterns_.FONT, 11, false),
|
||||||
|
header_font_spec = M.make_font_spec(_G_Patterns_.FONT, 11, false),
|
||||||
table.unpack(labels),
|
table.unpack(labels),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -62,6 +62,7 @@ local labels = _G_Widget_.TextColumn{
|
||||||
y = _BAR_Y_,
|
y = _BAR_Y_,
|
||||||
spacing = _SPACING_,
|
spacing = _SPACING_,
|
||||||
text_color = _G_Patterns_.INACTIVE_TEXT_FG,
|
text_color = _G_Patterns_.INACTIVE_TEXT_FG,
|
||||||
|
font_spec = Common.normal_font_spec,
|
||||||
'root',
|
'root',
|
||||||
'boot',
|
'boot',
|
||||||
'home',
|
'home',
|
||||||
|
@ -88,7 +89,7 @@ local update = function(cr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local draw_static = function(cr)
|
M.draw_static = function(cr)
|
||||||
Common.drawHeader(cr, header)
|
Common.drawHeader(cr, header)
|
||||||
|
|
||||||
Common.text_row_draw_static(smart, cr)
|
Common.text_row_draw_static(smart, cr)
|
||||||
|
@ -98,7 +99,7 @@ local draw_static = function(cr)
|
||||||
CompoundBar.draw_static(bars, cr)
|
CompoundBar.draw_static(bars, cr)
|
||||||
end
|
end
|
||||||
|
|
||||||
local draw_dynamic = function(cr, trigger)
|
M.draw_dynamic = function(cr, trigger)
|
||||||
if trigger == 0 then update(cr) end
|
if trigger == 0 then update(cr) end
|
||||||
|
|
||||||
Common.text_row_draw_dynamic(smart, cr)
|
Common.text_row_draw_dynamic(smart, cr)
|
||||||
|
@ -106,7 +107,4 @@ local draw_dynamic = function(cr, trigger)
|
||||||
CompoundBar.draw_dynamic(bars, cr)
|
CompoundBar.draw_dynamic(bars, cr)
|
||||||
end
|
end
|
||||||
|
|
||||||
M.draw_static = draw_static
|
|
||||||
M.draw_dynamic = draw_dynamic
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
@ -135,6 +135,7 @@ local nvidia_off = function(cr)
|
||||||
Common.text_rows_set.set(clock_speed, cr, 1, NA)
|
Common.text_rows_set.set(clock_speed, cr, 1, NA)
|
||||||
Common.text_rows_set.set(clock_speed, cr, 2, NA)
|
Common.text_rows_set.set(clock_speed, cr, 2, NA)
|
||||||
|
|
||||||
|
-- TODO refactor this
|
||||||
Text.set(gpu_util.value, cr, NA)
|
Text.set(gpu_util.value, cr, NA)
|
||||||
Text.set(mem_util.value, cr, NA)
|
Text.set(mem_util.value, cr, NA)
|
||||||
Text.set(vid_util.value, cr, NA)
|
Text.set(vid_util.value, cr, NA)
|
||||||
|
|
|
@ -98,6 +98,7 @@ local cache = {
|
||||||
y = _LINE_1_Y_ + _TEXT_SPACING_,
|
y = _LINE_1_Y_ + _TEXT_SPACING_,
|
||||||
spacing = _TEXT_SPACING_,
|
spacing = _TEXT_SPACING_,
|
||||||
text_color = _G_Patterns_.INACTIVE_TEXT_FG,
|
text_color = _G_Patterns_.INACTIVE_TEXT_FG,
|
||||||
|
font_spec = Common.normal_font_spec,
|
||||||
'Page Cache',
|
'Page Cache',
|
||||||
'Buffers',
|
'Buffers',
|
||||||
'Kernel Slab'
|
'Kernel Slab'
|
||||||
|
@ -108,6 +109,7 @@ local cache = {
|
||||||
x_align = 'right',
|
x_align = 'right',
|
||||||
append_end = ' %',
|
append_end = ' %',
|
||||||
text_color = _G_Patterns_.SECONDARY_FG,
|
text_color = _G_Patterns_.SECONDARY_FG,
|
||||||
|
font_spec = Common.normal_font_spec,
|
||||||
'<cached_kb>',
|
'<cached_kb>',
|
||||||
'<buffers_kb>',
|
'<buffers_kb>',
|
||||||
'<kernel_slab>'
|
'<kernel_slab>'
|
||||||
|
|
|
@ -3,6 +3,7 @@ local M = {}
|
||||||
local Color = require 'Color'
|
local Color = require 'Color'
|
||||||
local Util = require 'Util'
|
local Util = require 'Util'
|
||||||
|
|
||||||
|
M.FONT = 'Neuropolitical'
|
||||||
-- text colors
|
-- text colors
|
||||||
M.HEADER_FG = Color.init{hex_rgba = 0xffffff}
|
M.HEADER_FG = Color.init{hex_rgba = 0xffffff}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue