ENH make all widget modules lowercase

This commit is contained in:
Nathan Dwarshuis 2021-07-29 22:37:30 -04:00
parent f96f587e11
commit 4d0e9d03ed
10 changed files with 171 additions and 171 deletions

2
core

@ -1 +1 @@
Subproject commit 0b2a689a905e1b4968d0b1881f9dcee1b85db25f Subproject commit f04271472373e5ae290108dc27742fef5f32def5

View File

@ -1,21 +1,21 @@
local M = {} local M = {}
local F = require 'Fundamental' local F = require 'primitive'
local Util = require 'Util' local Util = require 'Util'
local theme = require 'theme' local theme = require 'theme'
local Dial = require 'Dial' local dial = require 'dial'
local Rect = require 'Rect' local rect = require 'rect'
local FillRect = require 'FillRect' local fillrect = require 'fillrect'
local CompoundDial = require 'CompoundDial' local compounddial = require 'compounddial'
local Arc = require 'Arc' local arc = require 'arc'
local Text = require 'Text' local text = require 'text'
local Table = require 'Table' local tbl = require 'texttable'
local CompoundBar = require 'CompoundBar' local compoundbar = require 'compoundbar'
local ThresholdText = require 'ThresholdText' local thresholdtext = require 'thresholdtext'
local TextColumn = require 'TextColumn' local textcolumn = require 'textcolumn'
local Line = require 'Line' local line = require 'line'
local Timeseries = require 'Timeseries' local timeseries = require 'timeseries'
local ScaledTimeseries = require 'ScaledTimeseries' local scaledtimeseries = require 'scaledtimeseries'
local s = require 'style' local s = require 'style'
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -66,35 +66,35 @@ local normal_font_spec = make_font_spec(FONT, NORMAL_FONT_SIZE, false)
local label_font_spec = make_font_spec(FONT, PLOT_LABEL_FONT_SIZE, false) local label_font_spec = make_font_spec(FONT, PLOT_LABEL_FONT_SIZE, false)
local _text_row_style = function(x_align, color) local _text_row_style = function(x_align, color)
return Text.style(normal_font_spec, color, x_align, 'center') return text.style(normal_font_spec, color, x_align, 'center')
end end
local left_text_style = _text_row_style('left', theme.INACTIVE_TEXT_FG) local left_text_style = _text_row_style('left', theme.INACTIVE_TEXT_FG)
local right_text_style = _text_row_style('right', theme.PRIMARY_FG) local right_text_style = _text_row_style('right', theme.PRIMARY_FG)
local _bare_text = function(pt, text, style) local _bare_text = function(pt, _text, style)
return Text.build_plain(pt, text, style) return text.build_plain(pt, _text, style)
end end
local _left_text = function(pt, text) local _left_text = function(pt, _text)
return _bare_text(pt, text, left_text_style) return _bare_text(pt, _text, left_text_style)
end end
local _right_text = function(pt, text) local _right_text = function(pt, _text)
return _bare_text(pt, text, right_text_style) return _bare_text(pt, _text, right_text_style)
end end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- header -- header
M.Header = function(x, y, w, text) M.Header = function(x, y, w, _text)
local bottom_y = y + HEADER_HEIGHT local bottom_y = y + HEADER_HEIGHT
local underline_y = y + HEADER_UNDERLINE_OFFSET local underline_y = y + HEADER_UNDERLINE_OFFSET
return { return {
text = Text.build_plain( text = text.build_plain(
F.make_point(x, y), F.make_point(x, y),
text, _text,
Text.style( text.style(
make_font_spec(FONT, HEADER_FONT_SIZE, true), make_font_spec(FONT, HEADER_FONT_SIZE, true),
theme.HEADER_FG, theme.HEADER_FG,
'left', 'left',
@ -102,10 +102,10 @@ M.Header = function(x, y, w, text)
) )
), ),
bottom_y = bottom_y, bottom_y = bottom_y,
underline = Line.build( underline = line.build(
F.make_point(x, underline_y), F.make_point(x, underline_y),
F.make_point(x + w, underline_y), F.make_point(x + w, underline_y),
Line.config( line.config(
s.line(HEADER_UNDERLINE_THICKNESS, HEADER_UNDERLINE_CAP), s.line(HEADER_UNDERLINE_THICKNESS, HEADER_UNDERLINE_CAP),
theme.HEADER_FG, theme.HEADER_FG,
true true
@ -115,20 +115,20 @@ M.Header = function(x, y, w, text)
end end
M.drawHeader = function(cr, header) M.drawHeader = function(cr, header)
Text.draw(header.text, cr) text.draw(header.text, cr)
Line.draw(header.underline, cr) line.draw(header.underline, cr)
end end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- label plot -- label plot
local default_grid_config = Timeseries.grid_config( local default_grid_config = timeseries.grid_config(
PLOT_GRID_X_N, PLOT_GRID_X_N,
PLOT_GRID_Y_N, PLOT_GRID_Y_N,
theme.PLOT_GRID_FG theme.PLOT_GRID_FG
) )
local default_plot_config = Timeseries.config( local default_plot_config = timeseries.config(
PLOT_NUM_POINTS, PLOT_NUM_POINTS,
theme.PLOT_OUTLINE_FG, theme.PLOT_OUTLINE_FG,
theme.PLOT_FILL_BORDER_PRIMARY, theme.PLOT_FILL_BORDER_PRIMARY,
@ -136,14 +136,14 @@ local default_plot_config = Timeseries.config(
default_grid_config default_grid_config
) )
M.percent_label_config = Timeseries.label_config( M.percent_label_config = timeseries.label_config(
theme.INACTIVE_TEXT_FG, theme.INACTIVE_TEXT_FG,
label_font_spec, label_font_spec,
function(_) return function(z) return Util.round_to_string(z * 100)..'%' end end function(_) return function(z) return Util.round_to_string(z * 100)..'%' end end
) )
M.initthemedLabelPlot = function(x, y, w, h, label_config, update_freq) M.initthemedLabelPlot = function(x, y, w, h, label_config, update_freq)
return Timeseries.build( return timeseries.build(
F.make_box(x, y, w, h), F.make_box(x, y, w, h),
update_freq, update_freq,
default_plot_config, default_plot_config,
@ -157,12 +157,12 @@ end
M.initPercentPlot_formatted = function(x, y, w, h, spacing, label, update_freq, format) M.initPercentPlot_formatted = function(x, y, w, h, spacing, label, update_freq, format)
return { return {
label = _left_text(F.make_point(x, y), label), label = _left_text(F.make_point(x, y), label),
value = ThresholdText.build_formatted( value = thresholdtext.build_formatted(
F.make_point(x + w, y), F.make_point(x + w, y),
nil, nil,
right_text_style, right_text_style,
format, format,
ThresholdText.style(theme.CRITICAL_FG, 80) thresholdtext.style(theme.CRITICAL_FG, 80)
), ),
plot = M.initthemedLabelPlot( plot = M.initthemedLabelPlot(
x, x,
@ -180,13 +180,13 @@ M.initPercentPlot = function(x, y, w, h, spacing, label, update_freq)
end end
M.percent_plot_draw_static = function(pp, cr) M.percent_plot_draw_static = function(pp, cr)
Text.draw(pp.label, cr) text.draw(pp.label, cr)
Timeseries.draw_static(pp.plot, cr) timeseries.draw_static(pp.plot, cr)
end end
M.percent_plot_draw_dynamic = function(pp, cr) M.percent_plot_draw_dynamic = function(pp, cr)
ThresholdText.draw(pp.value, cr) thresholdtext.draw(pp.value, cr)
Timeseries.draw_dynamic(pp.plot, cr) timeseries.draw_dynamic(pp.plot, cr)
end end
-- TODO this is pretty confusing, nil means -1 which gets fed to any text -- TODO this is pretty confusing, nil means -1 which gets fed to any text
@ -198,8 +198,8 @@ M.percent_plot_set = function(pp, value)
t = math.floor(value) t = math.floor(value)
p = value * 0.01 p = value * 0.01
end end
Text.set(pp.value, t) text.set(pp.value, t)
Timeseries.update(pp.plot, p) timeseries.update(pp.plot, p)
end end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -234,15 +234,15 @@ M.converted_y_label_format_generator = function(unit)
end end
M.base_2_scale_data = function(m) M.base_2_scale_data = function(m)
return ScaledTimeseries.scaling_parameters(2, m, 0.9) return scaledtimeseries.scaling_parameters(2, m, 0.9)
end end
M.initthemedScalePlot = function(x, y, w, h, f, min_domain, update_freq) M.initthemedScalePlot = function(x, y, w, h, f, min_domain, update_freq)
return ScaledTimeseries.build( return scaledtimeseries.build(
F.make_box(x, y, w, h), F.make_box(x, y, w, h),
update_freq, update_freq,
default_plot_config, default_plot_config,
Timeseries.label_config( timeseries.label_config(
theme.INACTIVE_TEXT_FG, theme.INACTIVE_TEXT_FG,
label_font_spec, label_font_spec,
f f
@ -258,7 +258,7 @@ M.initLabeledScalePlot = function(x, y, w, h, format_fun, label_fun, spacing,
label, min_domain, update_freq) label, min_domain, update_freq)
return { return {
label = _left_text(F.make_point(x, y), label), label = _left_text(F.make_point(x, y), label),
value = Text.build_formatted( value = text.build_formatted(
F.make_point(x + w, y), F.make_point(x + w, y),
0, 0,
right_text_style, right_text_style,
@ -269,17 +269,17 @@ M.initLabeledScalePlot = function(x, y, w, h, format_fun, label_fun, spacing,
end end
M.annotated_scale_plot_draw_static = function(asp, cr) M.annotated_scale_plot_draw_static = function(asp, cr)
Text.draw(asp.label, cr) text.draw(asp.label, cr)
end end
M.annotated_scale_plot_draw_dynamic = function(asp, cr) M.annotated_scale_plot_draw_dynamic = function(asp, cr)
Text.draw(asp.value, cr) text.draw(asp.value, cr)
ScaledTimeseries.draw_dynamic(asp.plot, cr) scaledtimeseries.draw_dynamic(asp.plot, cr)
end end
M.annotated_scale_plot_set = function(asp, value) M.annotated_scale_plot_set = function(asp, value)
Text.set(asp.value, value) text.set(asp.value, value)
ScaledTimeseries.update(asp.plot, value) scaledtimeseries.update(asp.plot, value)
end end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -309,7 +309,7 @@ M.build_rate_timeseries = function(x, y, w, h, format_fun, label_fun, spacing,
label, min_domain, update_freq, init) label, min_domain, update_freq, init)
return { return {
label = _left_text(F.make_point(x, y), label), label = _left_text(F.make_point(x, y), label),
value = Text.build_formatted( value = text.build_formatted(
F.make_point(x + w, y), F.make_point(x + w, y),
0, 0,
right_text_style, right_text_style,
@ -323,8 +323,8 @@ end
M.update_rate_timeseries = function(obj, value) M.update_rate_timeseries = function(obj, value)
local rate = obj.derive(obj.prev_value, value) local rate = obj.derive(obj.prev_value, value)
Text.set(obj.value, rate) text.set(obj.value, rate)
ScaledTimeseries.update(obj.plot, rate) scaledtimeseries.update(obj.plot, rate)
obj.prev_value = value obj.prev_value = value
end end
@ -335,9 +335,9 @@ end
-- I have multiple layers on top of each other -- I have multiple layers on top of each other
M.arc = function(x, y, r, thickness, pattern) M.arc = function(x, y, r, thickness, pattern)
return Arc.build( return arc.build(
F.make_semicircle(x, y, r, 90, 360), F.make_semicircle(x, y, r, 90, 360),
Arc.config(s.line(thickness, CAIRO_LINE_CAP_BUTT), pattern) arc.config(s.line(thickness, CAIRO_LINE_CAP_BUTT), pattern)
) )
end end
@ -345,43 +345,43 @@ end
-- ring -- ring
M.initRing = function(x, y, r) M.initRing = function(x, y, r)
return Arc.build( return arc.build(
F.make_semicircle(x, y, r, 0, 360), F.make_semicircle(x, y, r, 0, 360),
Arc.config(s.line(ARC_WIDTH, CAIRO_LINE_CAP_BUTT), theme.BORDER_FG) arc.config(s.line(ARC_WIDTH, CAIRO_LINE_CAP_BUTT), theme.BORDER_FG)
) )
end end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- ring with text data in the center -- ring with text data in the center
M.initTextRing = function(x, y, r, fmt, limit) M.inittextRing = function(x, y, r, fmt, limit)
return { return {
ring = M.initRing(x, y, r), ring = M.initRing(x, y, r),
value = ThresholdText.build_formatted( value = thresholdtext.build_formatted(
F.make_point(x, y), F.make_point(x, y),
0, 0,
Text.style( text.style(
normal_font_spec, normal_font_spec,
theme.PRIMARY_FG, theme.PRIMARY_FG,
'center', 'center',
'center' 'center'
), ),
fmt, fmt,
ThresholdText.style(theme.CRITICAL_FG, limit) thresholdtext.style(theme.CRITICAL_FG, limit)
), ),
} }
end end
M.text_ring_draw_static = function(tr, cr) M.text_ring_draw_static = function(tr, cr)
Arc.draw(tr.ring, cr) arc.draw(tr.ring, cr)
end end
M.text_ring_draw_dynamic = function(tr, cr) M.text_ring_draw_dynamic = function(tr, cr)
ThresholdText.draw(tr.value, cr) thresholdtext.draw(tr.value, cr)
end end
M.text_ring_set = function(tr, value) M.text_ring_set = function(tr, value)
ThresholdText.set(tr.value, value) thresholdtext.set(tr.value, value)
end end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -397,27 +397,27 @@ end
M.dial = function(x, y, radius, thickness, threshold, format) M.dial = function(x, y, radius, thickness, threshold, format)
return { return {
dial = Dial.build( dial = dial.build(
F.make_semicircle(x, y, radius, DIAL_THETA0, DIAL_THETA1), F.make_semicircle(x, y, radius, DIAL_THETA0, DIAL_THETA1),
Arc.config(s.line(thickness, CAIRO_LINE_CAP_BUTT), theme.INDICATOR_BG), arc.config(s.line(thickness, CAIRO_LINE_CAP_BUTT), theme.INDICATOR_BG),
threshold_indicator(threshold) threshold_indicator(threshold)
), ),
text_ring = M.initTextRing(x, y, radius - thickness / 2 - 2, format, threshold), text_ring = M.inittextRing(x, y, radius - thickness / 2 - 2, format, threshold),
} }
end end
M.dial_set = function(dl, value) M.dial_set = function(dl, value)
Dial.set(dl.dial, value) dial.set(dl.dial, value)
M.text_ring_set(dl.text_ring, value) M.text_ring_set(dl.text_ring, value)
end end
M.dial_draw_static = function(dl, cr) M.dial_draw_static = function(dl, cr)
Dial.draw_static(dl.dial, cr) dial.draw_static(dl.dial, cr)
M.text_ring_draw_static(dl.text_ring, cr) M.text_ring_draw_static(dl.text_ring, cr)
end end
M.dial_draw_dynamic = function(dl, cr) M.dial_draw_dynamic = function(dl, cr)
Dial.draw_dynamic(dl.dial, cr) dial.draw_dynamic(dl.dial, cr)
M.text_ring_draw_dynamic(dl.text_ring, cr) M.text_ring_draw_dynamic(dl.text_ring, cr)
end end
@ -426,9 +426,9 @@ end
M.compound_dial = function(x, y, outer_radius, inner_radius, thickness, M.compound_dial = function(x, y, outer_radius, inner_radius, thickness,
threshold, num_dials) threshold, num_dials)
return CompoundDial.build( return compounddial.build(
F.make_semicircle(x, y, outer_radius, DIAL_THETA0, DIAL_THETA1), F.make_semicircle(x, y, outer_radius, DIAL_THETA0, DIAL_THETA1),
Arc.config(s.line(thickness, CAIRO_LINE_CAP_BUTT), theme.INDICATOR_BG), arc.config(s.line(thickness, CAIRO_LINE_CAP_BUTT), theme.INDICATOR_BG),
threshold_indicator(threshold), threshold_indicator(threshold),
inner_radius, inner_radius,
num_dials num_dials
@ -440,17 +440,17 @@ end
M.compound_bar = function(x, y, w, pad, labels, spacing, thickness, threshold) M.compound_bar = function(x, y, w, pad, labels, spacing, thickness, threshold)
return { return {
labels = TextColumn.build( labels = textcolumn.build(
F.make_point(x, y), F.make_point(x, y),
labels, labels,
left_text_style, left_text_style,
nil, nil,
spacing spacing
), ),
bars = CompoundBar.build( bars = compoundbar.build(
F.make_point(x + pad, y), F.make_point(x + pad, y),
w - pad, w - pad,
Line.config( line.config(
s.line(thickness, CAIRO_LINE_CAP_BUTT), s.line(thickness, CAIRO_LINE_CAP_BUTT),
theme.INDICATOR_BG, theme.INDICATOR_BG,
true true
@ -464,26 +464,26 @@ M.compound_bar = function(x, y, w, pad, labels, spacing, thickness, threshold)
end end
M.compound_bar_draw_static = function(cb, cr) M.compound_bar_draw_static = function(cb, cr)
TextColumn.draw(cb.labels, cr) textcolumn.draw(cb.labels, cr)
CompoundBar.draw_static(cb.bars, cr) compoundbar.draw_static(cb.bars, cr)
end end
M.compound_bar_draw_dynamic = function(cb, cr) M.compound_bar_draw_dynamic = function(cb, cr)
CompoundBar.draw_dynamic(cb.bars, cr) compoundbar.draw_dynamic(cb.bars, cr)
end end
M.compound_bar_set = function(cb, i, value) M.compound_bar_set = function(cb, i, value)
CompoundBar.set(cb.bars, i, value) compoundbar.set(cb.bars, i, value)
end end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- separator (eg a horizontal line) -- separator (eg a horizontal line)
M.initSeparator = function(x, y, w) M.initSeparator = function(x, y, w)
return Line.build( return line.build(
F.make_point(x, y), F.make_point(x, y),
F.make_point(x + w, y), F.make_point(x + w, y),
Line.config( line.config(
s.line(SEPARATOR_THICKNESS, CAIRO_LINE_CAP_BUTT), s.line(SEPARATOR_THICKNESS, CAIRO_LINE_CAP_BUTT),
theme.BORDER_FG, theme.BORDER_FG,
true true
@ -494,7 +494,7 @@ end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- text row (label with a value, aligned as far apart as possible) -- text row (label with a value, aligned as far apart as possible)
M.initTextRow = function(x, y, w, label) M.inittextRow = function(x, y, w, label)
return { return {
label = _left_text(F.make_point(x, y), label), label = _left_text(F.make_point(x, y), label),
value = _right_text(F.make_point(x + w, y), nil), value = _right_text(F.make_point(x + w, y), nil),
@ -502,34 +502,34 @@ M.initTextRow = function(x, y, w, label)
end end
M.text_row_draw_static = function(row, cr) M.text_row_draw_static = function(row, cr)
Text.draw(row.label, cr) text.draw(row.label, cr)
end end
M.text_row_draw_dynamic = function(row, cr) M.text_row_draw_dynamic = function(row, cr)
Text.draw(row.value, cr) text.draw(row.value, cr)
end end
M.text_row_set = function(row, value) M.text_row_set = function(row, value)
Text.set(row.value, value) text.set(row.value, value)
end end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- text row with critical indicator -- text row with critical indicator
M.initTextRowCrit = function(x, y, w, label, append_end, limit) M.inittextRowCrit = function(x, y, w, label, append_end, limit)
return{ return{
label = _left_text(F.make_point(x, y), label), label = _left_text(F.make_point(x, y), label),
value = ThresholdText.build_formatted( value = thresholdtext.build_formatted(
F.make_point(x + w, y), F.make_point(x + w, y),
nil, nil,
Text.style( text.style(
normal_font_spec, normal_font_spec,
theme.PRIMARY_FG, theme.PRIMARY_FG,
'right', 'right',
'center' 'center'
), ),
append_end, append_end,
ThresholdText.style(theme.CRITICAL_FG, limit) thresholdtext.style(theme.CRITICAL_FG, limit)
) )
} }
end end
@ -537,18 +537,18 @@ end
M.text_row_crit_draw_static = M.text_row_draw_static M.text_row_crit_draw_static = M.text_row_draw_static
M.text_row_crit_draw_dynamic = function(row, cr) M.text_row_crit_draw_dynamic = function(row, cr)
ThresholdText.draw(row.value, cr) thresholdtext.draw(row.value, cr)
end end
M.text_row_crit_set = function(row, value) M.text_row_crit_set = function(row, value)
ThresholdText.set(row.value, value) thresholdtext.set(row.value, value)
end end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- text column -- text column
M.text_column = function(x, y, spacing, labels, x_align, color) M.text_column = function(x, y, spacing, labels, x_align, color)
return TextColumn.build( return textcolumn.build(
F.make_point(x, y), F.make_point(x, y),
labels, labels,
_text_row_style(x_align, color), _text_row_style(x_align, color),
@ -560,16 +560,16 @@ end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- multiple text row separated by spacing -- multiple text row separated by spacing
M.initTextRows_color = function(x, y, w, spacing, labels, color, format) M.inittextRows_color = function(x, y, w, spacing, labels, color, format)
return { return {
labels = TextColumn.build( labels = textcolumn.build(
F.make_point(x, y), F.make_point(x, y),
labels, labels,
left_text_style, left_text_style,
nil, nil,
spacing spacing
), ),
values = TextColumn.build_n( values = textcolumn.build_n(
F.make_point(x + w, y), F.make_point(x + w, y),
#labels, #labels,
_text_row_style('right', color), _text_row_style('right', color),
@ -580,8 +580,8 @@ M.initTextRows_color = function(x, y, w, spacing, labels, color, format)
} }
end end
M.initTextRows_formatted = function(x, y, w, spacing, labels, format) M.inittextRows_formatted = function(x, y, w, spacing, labels, format)
return M.initTextRows_color( return M.inittextRows_color(
x, x,
y, y,
w, w,
@ -592,8 +592,8 @@ M.initTextRows_formatted = function(x, y, w, spacing, labels, format)
) )
end end
M.initTextRows = function(x, y, w, spacing, labels) M.inittextRows = function(x, y, w, spacing, labels)
return M.initTextRows_formatted( return M.inittextRows_formatted(
x, x,
y, y,
w, w,
@ -604,15 +604,15 @@ M.initTextRows = function(x, y, w, spacing, labels)
end end
M.text_rows_draw_static = function(rows, cr) M.text_rows_draw_static = function(rows, cr)
TextColumn.draw(rows.labels, cr) textcolumn.draw(rows.labels, cr)
end end
M.text_rows_draw_dynamic = function(rows, cr) M.text_rows_draw_dynamic = function(rows, cr)
TextColumn.draw(rows.values, cr) textcolumn.draw(rows.values, cr)
end end
M.text_rows_set = function(rows, i, value) M.text_rows_set = function(rows, i, value)
TextColumn.set(rows.values, i, value) textcolumn.set(rows.values, i, value)
end end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -620,22 +620,22 @@ end
local default_table_font_spec = make_font_spec(FONT, TABLE_FONT_SIZE, false) local default_table_font_spec = make_font_spec(FONT, TABLE_FONT_SIZE, false)
local default_table_style = Table.style( local default_table_style = tbl.style(
Rect.config( rect.config(
s.closed_poly(TABLE_LINE_THICKNESS, CAIRO_LINE_JOIN_MITER), s.closed_poly(TABLE_LINE_THICKNESS, CAIRO_LINE_JOIN_MITER),
theme.BORDER_FG theme.BORDER_FG
), ),
Line.config( line.config(
s.line(TABLE_LINE_THICKNESS, CAIRO_LINE_CAP_BUTT), s.line(TABLE_LINE_THICKNESS, CAIRO_LINE_CAP_BUTT),
theme.BORDER_FG, theme.BORDER_FG,
true true
), ),
Table.header_config( tbl.header_config(
default_table_font_spec, default_table_font_spec,
theme.PRIMARY_FG, theme.PRIMARY_FG,
TABLE_HEADER_PAD TABLE_HEADER_PAD
), ),
Table.body_config( tbl.body_config(
default_table_font_spec, default_table_font_spec,
theme.INACTIVE_TEXT_FG, theme.INACTIVE_TEXT_FG,
TABLE_BODY_FORMAT TABLE_BODY_FORMAT
@ -648,8 +648,8 @@ local default_table_style = Table.style(
) )
) )
M.initTable = function(x, y, w, h, n, labels) M.inittable = function(x, y, w, h, n, labels)
return Table.build( return tbl.build(
F.make_box(x, y, w, h), F.make_box(x, y, w, h),
n, n,
labels, labels,
@ -661,9 +661,9 @@ end
-- panel -- panel
M.initPanel = function(x, y, w, h, thickness) M.initPanel = function(x, y, w, h, thickness)
return FillRect.build( return fillrect.build(
F.make_box(x, y, w, h), F.make_box(x, y, w, h),
Rect.config( rect.config(
s.closed_poly(thickness, CAIRO_LINE_JOIN_MITER), s.closed_poly(thickness, CAIRO_LINE_JOIN_MITER),
theme.BORDER_FG theme.BORDER_FG
), ),

View File

@ -1,4 +1,4 @@
local Line = require 'Line' local line = require 'line'
local Util = require 'Util' local Util = require 'Util'
local common = require 'common' local common = require 'common'
local geometry = require 'geometry' local geometry = require 'geometry'
@ -23,7 +23,7 @@ return function()
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- smartd -- smartd
local smart = common.initTextRow( local smart = common.inittextRow(
geometry.RIGHT_X, geometry.RIGHT_X,
header.bottom_y, header.bottom_y,
geometry.SECTION_WIDTH, geometry.SECTION_WIDTH,
@ -78,7 +78,7 @@ return function()
local draw_static = function(cr) local 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)
Line.draw(separator, cr) line.draw(separator, cr)
common.compound_bar_draw_static(fs, cr) common.compound_bar_draw_static(fs, cr)
end end

View File

@ -1,5 +1,5 @@
local Text = require 'Text' local text = require 'text'
local Line = require 'Line' local line = require 'line'
local Util = require 'Util' local Util = require 'Util'
local common = require 'common' local common = require 'common'
local geometry = require 'geometry' local geometry = require 'geometry'
@ -28,7 +28,7 @@ return function(update_freq)
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- gpu status -- gpu status
local status = common.initTextRow( local status = common.inittextRow(
geometry.LEFT_X, geometry.LEFT_X,
header.bottom_y, header.bottom_y,
geometry.SECTION_WIDTH, geometry.SECTION_WIDTH,
@ -48,7 +48,7 @@ return function(update_freq)
local INTERNAL_TEMP_Y = SEP_Y1 + SEPARATOR_SPACING local INTERNAL_TEMP_Y = SEP_Y1 + SEPARATOR_SPACING
local internal_temp = common.initTextRowCrit( local internal_temp = common.inittextRowCrit(
geometry.LEFT_X, geometry.LEFT_X,
INTERNAL_TEMP_Y, INTERNAL_TEMP_Y,
geometry.SECTION_WIDTH, geometry.SECTION_WIDTH,
@ -72,7 +72,7 @@ return function(update_freq)
local CLOCK_SPEED_Y = SEP_Y2 + SEPARATOR_SPACING local CLOCK_SPEED_Y = SEP_Y2 + SEPARATOR_SPACING
local clock_speed = common.initTextRows( local clock_speed = common.inittextRows(
geometry.LEFT_X, geometry.LEFT_X,
CLOCK_SPEED_Y, CLOCK_SPEED_Y,
geometry.SECTION_WIDTH, geometry.SECTION_WIDTH,
@ -162,7 +162,7 @@ return function(update_freq)
if Util.read_file(GPU_BUS_CTRL, nil, '*l') == 'on' then if Util.read_file(GPU_BUS_CTRL, nil, '*l') == 'on' then
local nvidia_settings_glob = Util.execute_cmd(NV_QUERY) local nvidia_settings_glob = Util.execute_cmd(NV_QUERY)
if nvidia_settings_glob == '' then if nvidia_settings_glob == '' then
Text.set(status.value, 'Error') text.set(status.value, 'Error')
nvidia_off() nvidia_off()
else else
common.text_row_set(status, 'On') common.text_row_set(status, 'On')
@ -180,7 +180,7 @@ return function(update_freq)
common.percent_plot_set(vid_util, vid_utilization) common.percent_plot_set(vid_util, vid_utilization)
end end
else else
Text.set(status.value, 'Off') text.set(status.value, 'Off')
nvidia_off() nvidia_off()
end end
end end
@ -192,13 +192,13 @@ return function(update_freq)
common.drawHeader(cr, header) common.drawHeader(cr, header)
common.text_row_draw_static(status, cr) common.text_row_draw_static(status, cr)
Line.draw(separator1, cr) line.draw(separator1, cr)
common.text_row_crit_draw_static(internal_temp, cr) common.text_row_crit_draw_static(internal_temp, cr)
Line.draw(separator2, cr) line.draw(separator2, cr)
common.text_rows_draw_static(clock_speed, cr) common.text_rows_draw_static(clock_speed, cr)
Line.draw(separator3, cr) line.draw(separator3, cr)
common.percent_plot_draw_static(gpu_util, cr) common.percent_plot_draw_static(gpu_util, cr)
common.percent_plot_draw_static(mem_util, cr) common.percent_plot_draw_static(mem_util, cr)

View File

@ -1,5 +1,5 @@
local Timeseries = require 'Timeseries' local timeseries = require 'timeseries'
local Table = require 'Table' local texttable = require 'texttable'
local Util = require 'Util' local Util = require 'Util'
local common = require 'common' local common = require 'common'
local geometry = require 'geometry' local geometry = require 'geometry'
@ -85,7 +85,7 @@ return function(update_freq)
local CACHE_X = SWAP_X + CACHE_X_OFFSET + DIAL_DIAMETER / 2 local CACHE_X = SWAP_X + CACHE_X_OFFSET + DIAL_DIAMETER / 2
local CACHE_WIDTH = geometry.RIGHT_X + geometry.SECTION_WIDTH - CACHE_X local CACHE_WIDTH = geometry.RIGHT_X + geometry.SECTION_WIDTH - CACHE_X
local cache = common.initTextRows_formatted( local cache = common.inittextRows_formatted(
CACHE_X, CACHE_X,
CACHE_Y, CACHE_Y,
CACHE_WIDTH, CACHE_WIDTH,
@ -122,7 +122,7 @@ return function(update_freq)
end, end,
func.seq(NUM_ROWS)) func.seq(NUM_ROWS))
local tbl = common.initTable( local tbl = common.inittable(
geometry.RIGHT_X, geometry.RIGHT_X,
PLOT_Y + PLOT_HEIGHT + TABLE_SECTION_BREAK, PLOT_Y + PLOT_HEIGHT + TABLE_SECTION_BREAK,
geometry.SECTION_WIDTH, geometry.SECTION_WIDTH,
@ -161,12 +161,12 @@ return function(update_freq)
common.text_rows_set(cache, 3, shmem / memtotal * 100) common.text_rows_set(cache, 3, shmem / memtotal * 100)
common.text_rows_set(cache, 4, sreclaimable / memtotal * 100) common.text_rows_set(cache, 4, sreclaimable / memtotal * 100)
Timeseries.update(plot, used_percent) timeseries.update(plot, used_percent)
for r = 1, NUM_ROWS do for r = 1, NUM_ROWS do
Table.set(tbl, 1, r, conky(TABLE_CONKY[r].comm, '(%S+)')) texttable.set(tbl, 1, r, conky(TABLE_CONKY[r].comm, '(%S+)'))
Table.set(tbl, 2, r, conky(TABLE_CONKY[r].pid)) texttable.set(tbl, 2, r, conky(TABLE_CONKY[r].pid))
Table.set(tbl, 3, r, conky(TABLE_CONKY[r].mem)) texttable.set(tbl, 3, r, conky(TABLE_CONKY[r].mem))
end end
end end
@ -175,16 +175,16 @@ return function(update_freq)
common.dial_draw_static(mem, cr) common.dial_draw_static(mem, cr)
common.dial_draw_static(swap, cr) common.dial_draw_static(swap, cr)
common.text_rows_draw_static(cache, cr) common.text_rows_draw_static(cache, cr)
Timeseries.draw_static(plot, cr) timeseries.draw_static(plot, cr)
Table.draw_static(tbl, cr) texttable.draw_static(tbl, cr)
end end
local draw_dynamic = function(cr) local draw_dynamic = function(cr)
common.dial_draw_dynamic(mem, cr) common.dial_draw_dynamic(mem, cr)
common.dial_draw_dynamic(swap, cr) common.dial_draw_dynamic(swap, cr)
common.text_rows_draw_dynamic(cache, cr) common.text_rows_draw_dynamic(cache, cr)
Timeseries.draw_dynamic(plot, cr) timeseries.draw_dynamic(plot, cr)
Table.draw_dynamic(tbl, cr) texttable.draw_dynamic(tbl, cr)
end end
return {dynamic = draw_dynamic, static = draw_static, update = update} return {dynamic = draw_dynamic, static = draw_static, update = update}

View File

@ -14,7 +14,7 @@ return function()
'PACMAN' 'PACMAN'
) )
local rows = common.initTextRows( local rows = common.inittextRows(
geometry.RIGHT_X, geometry.RIGHT_X,
header.bottom_y, header.bottom_y,
geometry.SECTION_WIDTH, geometry.SECTION_WIDTH,

View File

@ -1,6 +1,6 @@
local CompoundDial = require 'CompoundDial' local compounddial = require 'compounddial'
local Line = require 'Line' local line = require 'line'
local Table = require 'Table' local texttable = require 'texttable'
local Util = require 'Util' local Util = require 'Util'
local common = require 'common' local common = require 'common'
local geometry = require 'geometry' local geometry = require 'geometry'
@ -55,7 +55,7 @@ return function(update_freq)
0.8, 0.8,
nthreads nthreads
), ),
coretemp = common.initTextRing( coretemp = common.inittextRing(
x, x,
y, y,
DIAL_INNER_RADIUS - 2, DIAL_INNER_RADIUS - 2,
@ -77,7 +77,7 @@ return function(update_freq)
local HWP_Y = header.bottom_y + DIAL_OUTER_RADIUS * 2 + PLOT_SECTION_BREAK local HWP_Y = header.bottom_y + DIAL_OUTER_RADIUS * 2 + PLOT_SECTION_BREAK
local cpu_status = common.initTextRows( local cpu_status = common.inittextRows(
geometry.LEFT_X, geometry.LEFT_X,
HWP_Y, HWP_Y,
geometry.SECTION_WIDTH, geometry.SECTION_WIDTH,
@ -122,7 +122,7 @@ return function(update_freq)
func.seq(NUM_ROWS) func.seq(NUM_ROWS)
) )
local tbl = common.initTable( local tbl = common.inittable(
geometry.LEFT_X, geometry.LEFT_X,
PLOT_Y + PLOT_HEIGHT + TABLE_SECTION_BREAK, PLOT_Y + PLOT_HEIGHT + TABLE_SECTION_BREAK,
geometry.SECTION_WIDTH, geometry.SECTION_WIDTH,
@ -142,7 +142,7 @@ return function(update_freq)
for _, load_data in pairs(cpu_loads) do for _, load_data in pairs(cpu_loads) do
local cur = load_data.percent_active local cur = load_data.percent_active
load_sum = load_sum + cur load_sum = load_sum + cur
CompoundDial.set(cores[load_data.conky_core_id].loads, load_data.conky_thread_id, cur) compounddial.set(cores[load_data.conky_core_id].loads, load_data.conky_thread_id, cur)
end end
for conky_core_id, path in pairs(coretemp_paths) do for conky_core_id, path in pairs(coretemp_paths) do
@ -163,9 +163,9 @@ return function(update_freq)
for r = 1, NUM_ROWS do for r = 1, NUM_ROWS do
local pid = conky(TABLE_CONKY[r].pid, '(%d+)') -- may have leading spaces local pid = conky(TABLE_CONKY[r].pid, '(%d+)') -- may have leading spaces
if pid ~= '' then if pid ~= '' then
Table.set(tbl, 1, r, Util.read_file('/proc/'..pid..'/comm', '(%C+)')) texttable.set(tbl, 1, r, Util.read_file('/proc/'..pid..'/comm', '(%C+)'))
Table.set(tbl, 2, r, pid) texttable.set(tbl, 2, r, pid)
Table.set(tbl, 3, r, conky(TABLE_CONKY[r].cpu)) texttable.set(tbl, 3, r, conky(TABLE_CONKY[r].cpu))
end end
end end
end end
@ -175,27 +175,27 @@ return function(update_freq)
for i = 1, #cores do for i = 1, #cores do
common.text_ring_draw_static(cores[i].coretemp, cr) common.text_ring_draw_static(cores[i].coretemp, cr)
CompoundDial.draw_static(cores[i].loads, cr) compounddial.draw_static(cores[i].loads, cr)
end end
common.text_rows_draw_static(cpu_status, cr) common.text_rows_draw_static(cpu_status, cr)
Line.draw(separator, cr) line.draw(separator, cr)
common.percent_plot_draw_static(total_load, cr) common.percent_plot_draw_static(total_load, cr)
Table.draw_static(tbl, cr) texttable.draw_static(tbl, cr)
end end
local draw_dynamic = function(cr) local draw_dynamic = function(cr)
for i = 1, #cores do for i = 1, #cores do
CompoundDial.draw_dynamic(cores[i].loads, cr) compounddial.draw_dynamic(cores[i].loads, cr)
common.text_ring_draw_dynamic(cores[i].coretemp, cr) common.text_ring_draw_dynamic(cores[i].coretemp, cr)
end end
common.text_rows_draw_dynamic(cpu_status, cr) common.text_rows_draw_dynamic(cpu_status, cr)
common.percent_plot_draw_dynamic(total_load, cr) common.percent_plot_draw_dynamic(total_load, cr)
Table.draw_dynamic(tbl, cr) texttable.draw_dynamic(tbl, cr)
end end
return {static = draw_static, dynamic = draw_dynamic, update = update} return {static = draw_static, dynamic = draw_dynamic, update = update}

View File

@ -1,6 +1,6 @@
local common = require 'common' local common = require 'common'
local geometry = require 'geometry' local geometry = require 'geometry'
local FillRect = require 'FillRect' local fillrect = require 'fillrect'
return function(left_modules, center_modules, right_modules) return function(left_modules, center_modules, right_modules)
local __cairo_set_source_surface = cairo_set_source_surface local __cairo_set_source_surface = cairo_set_source_surface
@ -26,7 +26,7 @@ return function(left_modules, center_modules, right_modules)
__cairo_translate(cr, -cs_x, -cs_y) __cairo_translate(cr, -cs_x, -cs_y)
FillRect.draw(panel, cr) fillrect.draw(panel, cr)
for _, f in pairs(modules) do for _, f in pairs(modules) do
f(cr) f(cr)
end end

View File

@ -14,7 +14,7 @@ return function()
'SYSTEM' 'SYSTEM'
) )
local rows = common.initTextRows( local rows = common.inittextRows(
geometry.LEFT_X, geometry.LEFT_X,
header.bottom_y, header.bottom_y,
geometry.SECTION_WIDTH, geometry.SECTION_WIDTH,

View File

@ -1,26 +1,26 @@
local M = {} local M = {}
local Color = require 'Color' local color = require 'color'
M.FONT = 'Neuropolitical' M.FONT = 'Neuropolitical'
-- text colors -- text colors
M.HEADER_FG = Color.rgb(0xefefef) M.HEADER_FG = color.rgb(0xefefef)
M.PRIMARY_FG = Color.rgb(0xbfe1ff) M.PRIMARY_FG = color.rgb(0xbfe1ff)
M.CRITICAL_FG = Color.rgb(0xff8282) M.CRITICAL_FG = color.rgb(0xff8282)
M.INACTIVE_TEXT_FG = Color.rgb(0xc8c8c8) M.INACTIVE_TEXT_FG = color.rgb(0xc8c8c8)
M.MID_GREY = Color.rgb(0xd6d6d6) M.MID_GREY = color.rgb(0xd6d6d6)
M.BORDER_FG = Color.rgb(0x888888) M.BORDER_FG = color.rgb(0x888888)
M.PLOT_GRID_FG = Color.rgb(0x666666) M.PLOT_GRID_FG = color.rgb(0x666666)
M.PLOT_OUTLINE_FG = Color.rgb(0x777777) M.PLOT_OUTLINE_FG = color.rgb(0x777777)
-- arc bg colors -- arc bg colors
local GREY2 = 0xbfbfbf local GREY2 = 0xbfbfbf
local GREY5 = 0x565656 local GREY5 = 0x565656
M.INDICATOR_BG = Color.gradient_rgb{ M.INDICATOR_BG = color.gradient_rgb{
[0.0] = GREY5, [0.0] = GREY5,
[0.5] = GREY2, [0.5] = GREY2,
[1.0] = GREY5 [1.0] = GREY5
@ -29,7 +29,7 @@ M.INDICATOR_BG = Color.gradient_rgb{
-- arc/bar fg colors -- arc/bar fg colors
local PRIMARY1 = 0x99CEFF local PRIMARY1 = 0x99CEFF
local PRIMARY3 = 0x316BA6 local PRIMARY3 = 0x316BA6
M.INDICATOR_FG_PRIMARY = Color.gradient_rgb{ M.INDICATOR_FG_PRIMARY = color.gradient_rgb{
[0.0] = PRIMARY3, [0.0] = PRIMARY3,
[0.5] = PRIMARY1, [0.5] = PRIMARY1,
[1.0] = PRIMARY3 [1.0] = PRIMARY3
@ -37,7 +37,7 @@ M.INDICATOR_FG_PRIMARY = Color.gradient_rgb{
local CRITICAL1 = 0xFF3333 local CRITICAL1 = 0xFF3333
local CRITICAL3 = 0xFFB8B8 local CRITICAL3 = 0xFFB8B8
M.INDICATOR_FG_CRITICAL = Color.gradient_rgb{ M.INDICATOR_FG_CRITICAL = color.gradient_rgb{
[0.0] = CRITICAL1, [0.0] = CRITICAL1,
[0.5] = CRITICAL3, [0.5] = CRITICAL3,
[1.0] = CRITICAL1 [1.0] = CRITICAL1
@ -48,17 +48,17 @@ local PLOT_PRIMARY1 = 0x003f7c
local PLOT_PRIMARY2 = 0x1e90ff local PLOT_PRIMARY2 = 0x1e90ff
local PLOT_PRIMARY3 = 0x316ece local PLOT_PRIMARY3 = 0x316ece
local PLOT_PRIMARY4 = 0x8cc7ff local PLOT_PRIMARY4 = 0x8cc7ff
M.PLOT_FILL_BORDER_PRIMARY = Color.gradient_rgb{ M.PLOT_FILL_BORDER_PRIMARY = color.gradient_rgb{
[0.0] = PLOT_PRIMARY1, [0.0] = PLOT_PRIMARY1,
[1.0] = PLOT_PRIMARY2 [1.0] = PLOT_PRIMARY2
} }
M.PLOT_FILL_BG_PRIMARY = Color.gradient_rgba{ M.PLOT_FILL_BG_PRIMARY = color.gradient_rgba{
[0.2] = {PLOT_PRIMARY3, 0.5}, [0.2] = {PLOT_PRIMARY3, 0.5},
[1.0] = {PLOT_PRIMARY4, 1.0} [1.0] = {PLOT_PRIMARY4, 1.0}
} }
-- panel pattern -- panel pattern
M.PANEL_BG = Color.rgba(0x121212, 0.7) M.PANEL_BG = color.rgba(0x121212, 0.7)
return M return M