REF use point for text

This commit is contained in:
Nathan Dwarshuis 2021-07-09 23:53:21 -04:00
parent 39c964a39f
commit a96dd545c8
4 changed files with 55 additions and 48 deletions

2
core

@ -1 +1 @@
Subproject commit b9bcd174f57576f60c528b3deffd4c1764019a3a Subproject commit 6ed168732ff88826ee58ae2729703b9d12c2fb77

View File

@ -17,16 +17,16 @@ 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
local _bare_text = function(x, y, text, font_spec, pattern, x_align) local _bare_text = function(pt, text, font_spec, pattern, x_align)
return _G_Widget_.Text(x, y, text, font_spec, pattern, x_align, 'center', nil, nil) return _G_Widget_.Text(pt, text, font_spec, pattern, x_align, 'center', nil, nil)
end end
local _left_text = function(x, y, text, font_spec, pattern) local _left_text = function(pt, text, font_spec, pattern)
return _bare_text(x, y, text, font_spec, pattern, 'left') return _bare_text(pt, text, font_spec, pattern, 'left')
end end
local _right_text = function(x, y, text, font_spec, pattern) local _right_text = function(pt, text, font_spec, pattern)
return _bare_text(x, y, text, font_spec, pattern, 'right') return _bare_text(pt, text, font_spec, pattern, 'right')
end end
M.make_font_spec = function(f, s, bold) M.make_font_spec = function(f, s, bold)
@ -63,8 +63,7 @@ M.Header = function(x, y, w, s)
-- -- weight = HEADER_FONT_WEIGHT -- -- weight = HEADER_FONT_WEIGHT
-- }, -- },
text = _G_Widget_.Text( text = _G_Widget_.Text(
x, _G_Widget_.make_point(x, y),
y,
s, s,
M.make_font_spec(_G_Patterns_.FONT, HEADER_FONT_SIZE, true), M.make_font_spec(_G_Patterns_.FONT, HEADER_FONT_SIZE, true),
_G_Patterns_.HEADER_FG, _G_Patterns_.HEADER_FG,
@ -129,10 +128,14 @@ M.initPercentPlot = function(x, y, w, h, spacing, label)
-- text_color = _G_Patterns_.INACTIVE_TEXT_FG, -- text_color = _G_Patterns_.INACTIVE_TEXT_FG,
-- font_spec = M.normal_font_spec, -- font_spec = M.normal_font_spec,
-- }, -- },
label = _left_text(x, y, label, M.normal_font_spec, _G_Patterns_.INACTIVE_TEXT_FG), label = _left_text(
_G_Widget_.make_point(x, y),
label,
M.normal_font_spec,
_G_Patterns_.INACTIVE_TEXT_FG
),
value = _G_Widget_.CriticalText( value = _G_Widget_.CriticalText(
x + w, _G_Widget_.make_point(x, y),
y,
nil, nil,
M.normal_font_spec, M.normal_font_spec,
_G_Patterns_.PRIMARY_FG, _G_Patterns_.PRIMARY_FG,
@ -205,7 +208,12 @@ M.initLabeledScalePlot = function(x, y, w, h, f, spacing, label)
-- text_color = _G_Patterns_.INACTIVE_TEXT_FG, -- text_color = _G_Patterns_.INACTIVE_TEXT_FG,
-- font_spec = M.normal_font_spec, -- font_spec = M.normal_font_spec,
-- }, -- },
label = _left_text(x, y, label, M.normal_font_spec, _G_Patterns_.INACTIVE_TEXT_FG), label = _left_text(
_G_Widget_.make_point(x, y),
label,
M.normal_font_spec,
_G_Patterns_.INACTIVE_TEXT_FG
),
-- value = _G_Widget_.Text{ -- value = _G_Widget_.Text{
-- x = x + w, -- x = x + w,
-- y = y, -- y = y,
@ -213,7 +221,12 @@ M.initLabeledScalePlot = function(x, y, w, h, f, spacing, label)
-- text_color = _G_Patterns_.PRIMARY_FG, -- text_color = _G_Patterns_.PRIMARY_FG,
-- font_spec = M.normal_font_spec, -- font_spec = M.normal_font_spec,
-- }, -- },
value = _right_text(x + w, y, label, M.normal_font_spec, _G_Patterns_.PRIMARY_FG), value = _right_text(
_G_Widget_.make_point(x + w, y),
label,
M.normal_font_spec,
_G_Patterns_.PRIMARY_FG
),
plot = M.initThemedScalePlot(x, y + spacing, w, h, f), plot = M.initThemedScalePlot(x, y + spacing, w, h, f),
} }
end end
@ -267,8 +280,7 @@ M.initTextRing = function(x, y, r, append_end, limit)
-- font_spec = M.normal_font_spec, -- font_spec = M.normal_font_spec,
-- }, -- },
value = _G_Widget_.CriticalText( value = _G_Widget_.CriticalText(
x, _G_Widget_.make_point(x, y),
y,
nil, nil,
M.normal_font_spec, M.normal_font_spec,
_G_Patterns_.PRIMARY_FG, _G_Patterns_.PRIMARY_FG,
@ -327,8 +339,7 @@ M.initTextRow = function(x, y, w, label)
-- font_spec = M.normal_font_spec, -- font_spec = M.normal_font_spec,
-- }, -- },
label = _left_text( label = _left_text(
x, _G_Widget_.make_point(x, y),
y,
label, label,
M.normal_font_spec, M.normal_font_spec,
_G_Patterns_.INACTIVE_TEXT_FG _G_Patterns_.INACTIVE_TEXT_FG
@ -342,8 +353,7 @@ M.initTextRow = function(x, y, w, label)
-- font_spec = M.normal_font_spec, -- font_spec = M.normal_font_spec,
-- } -- }
value = _right_text( value = _right_text(
x + w, _G_Widget_.make_point(x + w, y),
y,
nil, nil,
M.normal_font_spec, M.normal_font_spec,
_G_Patterns_.PRIMARY_FG _G_Patterns_.PRIMARY_FG
@ -378,8 +388,7 @@ M.initTextRowCrit = function(x, y, w, label, append_end, limit)
-- font_spec = M.normal_font_spec, -- font_spec = M.normal_font_spec,
-- }, -- },
label = _left_text( label = _left_text(
x, _G_Widget_.make_point(x, y),
y,
label, label,
M.normal_font_spec, M.normal_font_spec,
_G_Patterns_.INACTIVE_TEXT_FG _G_Patterns_.INACTIVE_TEXT_FG
@ -397,8 +406,7 @@ M.initTextRowCrit = function(x, y, w, label, append_end, limit)
-- font_spec = M.normal_font_spec, -- font_spec = M.normal_font_spec,
-- } -- }
value = _G_Widget_.CriticalText( value = _G_Widget_.CriticalText(
x + w, _G_Widget_.make_point(x + w, y),
y,
nil, nil,
M.normal_font_spec, M.normal_font_spec,
_G_Patterns_.PRIMARY_FG, _G_Patterns_.PRIMARY_FG,
@ -436,8 +444,7 @@ M.initTextRows = function(x, y, w, spacing, labels)
-- text_color = _G_Patterns_.INACTIVE_TEXT_FG, -- text_color = _G_Patterns_.INACTIVE_TEXT_FG,
-- font_spec = M.normal_font_spec, -- font_spec = M.normal_font_spec,
-- table.unpack(labels), -- table.unpack(labels),
x, _G_Widget_.make_point(x, y),
y,
spacing, spacing,
nil, nil,
M.normal_font_spec, M.normal_font_spec,
@ -459,8 +466,7 @@ M.initTextRows = function(x, y, w, spacing, labels)
-- num_rows = #labels, -- num_rows = #labels,
-- } -- }
values = _G_Widget_.initTextColumnN( values = _G_Widget_.initTextColumnN(
x + w, _G_Widget_.make_point(x + w, y),
y,
spacing, spacing,
nil, nil,
M.normal_font_spec, M.normal_font_spec,

View File

@ -88,8 +88,10 @@ local bars = _G_Widget_.CompoundBar(
-- 'tmpfs', -- 'tmpfs',
-- } -- }
local labels = _G_Widget_.TextColumn( local labels = _G_Widget_.TextColumn(
_G_Widget_.make_point(
_G_INIT_DATA_.RIGHT_X, _G_INIT_DATA_.RIGHT_X,
_BAR_Y_, _BAR_Y_
),
_SPACING_, _SPACING_,
nil, nil,
Common.normal_font_spec, Common.normal_font_spec,
@ -98,12 +100,7 @@ local labels = _G_Widget_.TextColumn(
'center', 'center',
nil, nil,
nil, nil,
{'root', {'root', 'boot', 'home', 'data', 'dcache', 'tmpfs'}
'boot',
'home',
'data',
'dcache',
'tmpfs'}
) )
_SPACING_ = nil _SPACING_ = nil

View File

@ -128,8 +128,10 @@ local swap = Common.initTextRowCrit(
-- } -- }
local cache = { local cache = {
labels = _G_Widget_.TextColumn( labels = _G_Widget_.TextColumn(
_G_Widget_.make_point(
_TEXT_LEFT_X_, _TEXT_LEFT_X_,
_LINE_1_Y_ + _TEXT_SPACING_, _LINE_1_Y_ + _TEXT_SPACING_
),
_TEXT_SPACING_, _TEXT_SPACING_,
nil, nil,
Common.normal_font_spec, Common.normal_font_spec,
@ -141,8 +143,10 @@ local cache = {
{'Page Cache', 'Buffers', 'Kernel Slab'} {'Page Cache', 'Buffers', 'Kernel Slab'}
), ),
percents = _G_Widget_.initTextColumnN( percents = _G_Widget_.initTextColumnN(
_G_Widget_.make_point(
_RIGHT_X_, _RIGHT_X_,
_LINE_1_Y_ + _TEXT_SPACING_, _LINE_1_Y_ + _TEXT_SPACING_
),
_TEXT_SPACING_, _TEXT_SPACING_,
nil, nil,
Common.normal_font_spec, Common.normal_font_spec,