From a96dd545c8e56e3382cc8d82a834aa51a3e078a7 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Fri, 9 Jul 2021 23:53:21 -0400 Subject: [PATCH] REF use point for text --- core | 2 +- drawing/Common.lua | 60 +++++++++++++++++++++++------------------- drawing/FileSystem.lua | 29 +++++++++----------- drawing/Memory.lua | 12 ++++++--- 4 files changed, 55 insertions(+), 48 deletions(-) diff --git a/core b/core index b9bcd17..6ed1687 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit b9bcd174f57576f60c528b3deffd4c1764019a3a +Subproject commit 6ed168732ff88826ee58ae2729703b9d12c2fb77 diff --git a/drawing/Common.lua b/drawing/Common.lua index 797a718..9c66b36 100644 --- a/drawing/Common.lua +++ b/drawing/Common.lua @@ -17,16 +17,16 @@ local HEADER_UNDERLINE_CAP = CAIRO_LINE_CAP_ROUND local HEADER_UNDERLINE_OFFSET = -20 local HEADER_UNDERLINE_THICKNESS = 3 -local _bare_text = function(x, y, text, font_spec, pattern, x_align) - return _G_Widget_.Text(x, y, text, font_spec, pattern, x_align, 'center', nil, nil) +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(x, y, text, font_spec, pattern) - return _bare_text(x, y, text, font_spec, pattern, 'left') +local _left_text = function(pt, text, font_spec, pattern) + return _bare_text(pt, text, font_spec, pattern, 'left') end -local _right_text = function(x, y, text, font_spec, pattern) - return _bare_text(x, y, text, font_spec, pattern, 'right') +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) @@ -63,8 +63,7 @@ M.Header = function(x, y, w, s) -- -- weight = HEADER_FONT_WEIGHT -- }, text = _G_Widget_.Text( - x, - y, + _G_Widget_.make_point(x, y), s, M.make_font_spec(_G_Patterns_.FONT, HEADER_FONT_SIZE, true), _G_Patterns_.HEADER_FG, @@ -129,10 +128,14 @@ 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(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( - x + w, - y, + _G_Widget_.make_point(x, y), nil, M.normal_font_spec, _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, -- 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{ -- x = x + w, -- y = y, @@ -213,7 +221,12 @@ M.initLabeledScalePlot = function(x, y, w, h, f, spacing, label) -- text_color = _G_Patterns_.PRIMARY_FG, -- 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), } end @@ -267,8 +280,7 @@ M.initTextRing = function(x, y, r, append_end, limit) -- font_spec = M.normal_font_spec, -- }, value = _G_Widget_.CriticalText( - x, - y, + _G_Widget_.make_point(x, y), nil, M.normal_font_spec, _G_Patterns_.PRIMARY_FG, @@ -327,8 +339,7 @@ M.initTextRow = function(x, y, w, label) -- font_spec = M.normal_font_spec, -- }, label = _left_text( - x, - y, + _G_Widget_.make_point(x, y), label, M.normal_font_spec, _G_Patterns_.INACTIVE_TEXT_FG @@ -342,8 +353,7 @@ M.initTextRow = function(x, y, w, label) -- font_spec = M.normal_font_spec, -- } value = _right_text( - x + w, - y, + _G_Widget_.make_point(x + w, y), nil, M.normal_font_spec, _G_Patterns_.PRIMARY_FG @@ -378,8 +388,7 @@ M.initTextRowCrit = function(x, y, w, label, append_end, limit) -- font_spec = M.normal_font_spec, -- }, label = _left_text( - x, - y, + _G_Widget_.make_point(x, y), label, M.normal_font_spec, _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, -- } value = _G_Widget_.CriticalText( - x + w, - y, + _G_Widget_.make_point(x + w, y), nil, M.normal_font_spec, _G_Patterns_.PRIMARY_FG, @@ -436,8 +444,7 @@ M.initTextRows = function(x, y, w, spacing, labels) -- text_color = _G_Patterns_.INACTIVE_TEXT_FG, -- font_spec = M.normal_font_spec, -- table.unpack(labels), - x, - y, + _G_Widget_.make_point(x, y), spacing, nil, M.normal_font_spec, @@ -459,8 +466,7 @@ M.initTextRows = function(x, y, w, spacing, labels) -- num_rows = #labels, -- } values = _G_Widget_.initTextColumnN( - x + w, - y, + _G_Widget_.make_point(x + w, y), spacing, nil, M.normal_font_spec, diff --git a/drawing/FileSystem.lua b/drawing/FileSystem.lua index 1b77e23..9489de6 100644 --- a/drawing/FileSystem.lua +++ b/drawing/FileSystem.lua @@ -88,22 +88,19 @@ local bars = _G_Widget_.CompoundBar( -- 'tmpfs', -- } local labels = _G_Widget_.TextColumn( - _G_INIT_DATA_.RIGHT_X, - _BAR_Y_, - _SPACING_, - nil, - Common.normal_font_spec, - _G_Patterns_.INACTIVE_TEXT_FG, - 'left', - 'center', - nil, - nil, - {'root', - 'boot', - 'home', - 'data', - 'dcache', - 'tmpfs'} + _G_Widget_.make_point( + _G_INIT_DATA_.RIGHT_X, + _BAR_Y_ + ), + _SPACING_, + nil, + Common.normal_font_spec, + _G_Patterns_.INACTIVE_TEXT_FG, + 'left', + 'center', + nil, + nil, + {'root', 'boot', 'home', 'data', 'dcache', 'tmpfs'} ) _SPACING_ = nil diff --git a/drawing/Memory.lua b/drawing/Memory.lua index be19f3a..c3e04f1 100644 --- a/drawing/Memory.lua +++ b/drawing/Memory.lua @@ -128,8 +128,10 @@ local swap = Common.initTextRowCrit( -- } local cache = { labels = _G_Widget_.TextColumn( - _TEXT_LEFT_X_, - _LINE_1_Y_ + _TEXT_SPACING_, + _G_Widget_.make_point( + _TEXT_LEFT_X_, + _LINE_1_Y_ + _TEXT_SPACING_ + ), _TEXT_SPACING_, nil, Common.normal_font_spec, @@ -141,8 +143,10 @@ local cache = { {'Page Cache', 'Buffers', 'Kernel Slab'} ), percents = _G_Widget_.initTextColumnN( - _RIGHT_X_, - _LINE_1_Y_ + _TEXT_SPACING_, + _G_Widget_.make_point( + _RIGHT_X_, + _LINE_1_Y_ + _TEXT_SPACING_ + ), _TEXT_SPACING_, nil, Common.normal_font_spec,