REF use common text types

This commit is contained in:
Nathan Dwarshuis 2021-07-10 17:13:17 -04:00
parent 95d7abbd9e
commit e2f622fd22
4 changed files with 112 additions and 106 deletions

2
core

@ -1 +1 @@
Subproject commit 74aa89b9f069b46559b8652d7627dfc4b34efd58
Subproject commit a2c1c089c9933b191c5ef4fd1569b3ede80acdd3

View File

@ -17,18 +17,6 @@ local HEADER_UNDERLINE_CAP = CAIRO_LINE_CAP_ROUND
local HEADER_UNDERLINE_OFFSET = -20
local HEADER_UNDERLINE_THICKNESS = 3
local _bare_text = function(pt, text, font_spec, pattern, x_align)
return _G_Widget_.Text(pt, text, font_spec, pattern, x_align, 'center', nil, nil)
end
local _left_text = function(pt, text, font_spec, pattern)
return _bare_text(pt, text, font_spec, pattern, 'left')
end
local _right_text = function(pt, text, font_spec, pattern)
return _bare_text(pt, text, font_spec, pattern, 'right')
end
M.make_font_spec = function(f, s, bold)
return {
family = f,
@ -41,6 +29,33 @@ 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)
M.left_text_style = _G_Widget_.text_style(
M.normal_font_spec,
_G_Patterns_.INACTIVE_TEXT_FG,
'left',
'center'
)
M.right_text_style = _G_Widget_.text_style(
M.normal_font_spec,
_G_Patterns_.PRIMARY_FG,
'right',
'center'
)
local _bare_text = function(pt, text, style)
local fmt = _G_Widget_.text_format(false, false, false)
return _G_Widget_.Text(pt, text, style, fmt)
end
local _left_text = function(pt, text)
return _bare_text(pt, text, M.left_text_style)
end
local _right_text = function(pt, text)
return _bare_text(pt, text, M.right_text_style)
end
--------------------------------------------------------------------------------
-- header
@ -65,12 +80,13 @@ M.Header = function(x, y, w, s)
text = _G_Widget_.Text(
_G_Widget_.make_point(x, y),
s,
_G_Widget_.text_style(
M.make_font_spec(_G_Patterns_.FONT, HEADER_FONT_SIZE, true),
_G_Patterns_.HEADER_FG,
'left',
'top',
nil,
nil
'top'
),
_G_Widget_.text_format(false, false, false)
),
bottom_y = bottom_y,
-- underline = _G_Widget_.Line{
@ -128,23 +144,23 @@ M.initPercentPlot = function(x, y, w, h, spacing, label)
-- text_color = _G_Patterns_.INACTIVE_TEXT_FG,
-- font_spec = M.normal_font_spec,
-- },
label = _left_text(
_G_Widget_.make_point(x, y),
label,
M.normal_font_spec,
_G_Patterns_.INACTIVE_TEXT_FG
),
label = _left_text(_G_Widget_.make_point(x, y), label),
value = _G_Widget_.CriticalText(
_G_Widget_.make_point(x + w, y),
nil,
_G_Widget_.text_style(
M.normal_font_spec,
_G_Patterns_.PRIMARY_FG,
_G_Patterns_.CRITICAL_FG,
80,
'right',
'center',
nil,
'%'
'center'
),
_G_Widget_.text_format(
false,
'%',
false
),
_G_Patterns_.CRITICAL_FG,
80
),
-- value = _G_Widget_.CriticalText{
-- x = x + w,
@ -210,9 +226,7 @@ M.initLabeledScalePlot = function(x, y, w, h, f, spacing, label)
-- },
label = _left_text(
_G_Widget_.make_point(x, y),
label,
M.normal_font_spec,
_G_Patterns_.INACTIVE_TEXT_FG
label
),
-- value = _G_Widget_.Text{
-- x = x + w,
@ -223,9 +237,7 @@ M.initLabeledScalePlot = function(x, y, w, h, f, spacing, label)
-- },
value = _right_text(
_G_Widget_.make_point(x + w, y),
label,
M.normal_font_spec,
_G_Patterns_.PRIMARY_FG
label
),
plot = M.initThemedScalePlot(x, y + spacing, w, h, f),
}
@ -284,14 +296,19 @@ M.initTextRing = function(x, y, r, append_end, limit)
value = _G_Widget_.CriticalText(
_G_Widget_.make_point(x, y),
nil,
_G_Widget_.text_style(
M.normal_font_spec,
_G_Patterns_.PRIMARY_FG,
'center',
'center'
),
_G_Widget_.text_format(
false,
append_end,
false
),
_G_Patterns_.CRITICAL_FG,
limit,
'center',
'center',
nil,
append_end
limit
),
}
end
@ -342,9 +359,7 @@ M.initTextRow = function(x, y, w, label)
-- },
label = _left_text(
_G_Widget_.make_point(x, y),
label,
M.normal_font_spec,
_G_Patterns_.INACTIVE_TEXT_FG
label
),
-- value = _G_Widget_.Text{
-- x = x + w,
@ -356,9 +371,7 @@ M.initTextRow = function(x, y, w, label)
-- }
value = _right_text(
_G_Widget_.make_point(x + w, y),
nil,
M.normal_font_spec,
_G_Patterns_.PRIMARY_FG
nil
),
}
end
@ -391,9 +404,7 @@ M.initTextRowCrit = function(x, y, w, label, append_end, limit)
-- },
label = _left_text(
_G_Widget_.make_point(x, y),
label,
M.normal_font_spec,
_G_Patterns_.INACTIVE_TEXT_FG
label
),
-- value = _G_Widget_.CriticalText{
-- x = x + w,
@ -410,14 +421,19 @@ M.initTextRowCrit = function(x, y, w, label, append_end, limit)
value = _G_Widget_.CriticalText(
_G_Widget_.make_point(x + w, y),
nil,
_G_Widget_.text_style(
M.normal_font_spec,
_G_Patterns_.PRIMARY_FG,
_G_Patterns_.CRITICAL_FG,
limit,
'right',
'center',
nil,
append_end
'center'
),
_G_Widget_.text_format(
false,
append_end,
false
),
_G_Patterns_.CRITICAL_FG,
limit
)
}
end
@ -447,15 +463,10 @@ M.initTextRows = function(x, y, w, spacing, labels)
-- font_spec = M.normal_font_spec,
-- table.unpack(labels),
_G_Widget_.make_point(x, y),
spacing,
nil,
M.normal_font_spec,
_G_Patterns_.INACTIVE_TEXT_FG,
'left',
'center',
nil,
nil,
labels
labels,
M.left_text_style,
_G_Widget_.text_format(false, false, false),
spacing
),
-- values = _G_Widget_.TextColumn{
-- x = x + w,
@ -469,15 +480,10 @@ M.initTextRows = function(x, y, w, spacing, labels)
-- }
values = _G_Widget_.initTextColumnN(
_G_Widget_.make_point(x + w, y),
spacing,
nil,
M.normal_font_spec,
_G_Patterns_.PRIMARY_FG,
'right',
'center',
nil,
nil,
#labels
#labels,
M.right_text_style,
_G_Widget_.text_format(false, false, false),
spacing
)
}
end

View File

@ -92,15 +92,15 @@ local labels = _G_Widget_.TextColumn(
_G_INIT_DATA_.RIGHT_X,
_BAR_Y_
),
_SPACING_,
nil,
{'root', 'boot', 'home', 'data', 'dcache', 'tmpfs'},
_G_Widget_.text_style(
Common.normal_font_spec,
_G_Patterns_.INACTIVE_TEXT_FG,
'left',
'center',
nil,
nil,
{'root', 'boot', 'home', 'data', 'dcache', 'tmpfs'}
'center'
),
_G_Widget_.text_format(false, false, false),
_SPACING_
)
_SPACING_ = nil

View File

@ -136,30 +136,30 @@ local cache = {
_TEXT_LEFT_X_,
_LINE_1_Y_ + _TEXT_SPACING_
),
_TEXT_SPACING_,
nil,
{'Page Cache', 'Buffers', 'Kernel Slab'},
_G_Widget_.text_style(
Common.normal_font_spec,
_G_Patterns_.INACTIVE_TEXT_FG,
'left',
'center',
nil,
nil,
{'Page Cache', 'Buffers', 'Kernel Slab'}
'center'
),
_G_Widget_.text_format(false, false, false),
_TEXT_SPACING_
),
percents = _G_Widget_.initTextColumnN(
_G_Widget_.make_point(
_RIGHT_X_,
_LINE_1_Y_ + _TEXT_SPACING_
),
_TEXT_SPACING_,
nil,
3,
_G_Widget_.text_style(
Common.normal_font_spec,
_G_Patterns_.SECONDARY_FG,
'right',
'center',
nil,
' %',
3
'center'
),
_G_Widget_.text_format(false, '%', false),
_TEXT_SPACING_
),
}