REF move pattern code into drawing modules

This commit is contained in:
Nathan Dwarshuis 2021-07-04 22:24:18 -04:00
parent ed505d0e15
commit d4ac91ac35
8 changed files with 220 additions and 153 deletions

2
core

@ -1 +1 @@
Subproject commit 7b8e82ee6a5c3c18133c1edc0f7247b3d20b4cb3
Subproject commit a5f1912f6bf2a1fa54d9385971400fcb2de80e90

View File

@ -55,7 +55,8 @@ local separator = _G_Widget_.Line{
p2 = {
x = _G_INIT_DATA_.RIGHT_X + _G_INIT_DATA_.SECTION_WIDTH,
y = _SEP_Y_,
}
},
line_pattern = _G_Patterns_.BORDER_FG,
}
local _BAR_Y_ = _SEP_Y_ + _SEPARATOR_SPACING_
@ -67,7 +68,9 @@ local bars = _G_Widget_.CompoundBar{
spacing = _SPACING_,
num_bars = FS_NUM,
-- thickness = 12,
critical_limit = '>0.8'
critical_limit = '>0.8',
indicator_pattern = Patterns.INDICATOR_FG_PRIMARY,
line_pattern = Patterns.INDICATOR_BG,
}
local labels = _G_Widget_.TextColumn{

View File

@ -43,8 +43,9 @@ local status = {
local _SEP_Y_1_ = header.bottom_y + _SEPARATOR_SPACING_
local separator1 = _G_Widget_.Line{
p1 = {x = _G_INIT_DATA_.LEFT_X, y = _SEP_Y_1_},
p2 = {x = _RIGHT_X_, y = _SEP_Y_1_}
p1 = {x = _G_INIT_DATA_.LEFT_X, y = _SEP_Y_1_},
p2 = {x = _RIGHT_X_, y = _SEP_Y_1_},
line_pattern = _G_Patterns_.BORDER_FG,
}
local _INTERNAL_TEMP_Y_ = _SEP_Y_1_ + _SEPARATOR_SPACING_
@ -67,8 +68,9 @@ local internal_temp = {
local _SEP_Y_2_ = _INTERNAL_TEMP_Y_ + _SEPARATOR_SPACING_
local separator2 = _G_Widget_.Line{
p1 = {x = _G_INIT_DATA_.LEFT_X, y = _SEP_Y_2_},
p2 = {x = _RIGHT_X_, y = _SEP_Y_2_}
p1 = {x = _G_INIT_DATA_.LEFT_X, y = _SEP_Y_2_},
p2 = {x = _RIGHT_X_, y = _SEP_Y_2_},
line_pattern = _G_Patterns_.BORDER_FG,
}
local _CLOCK_SPEED_Y_ = _SEP_Y_2_ + _SEPARATOR_SPACING_
@ -94,8 +96,9 @@ local clock_speed = {
local _SEP_Y_3_ = _CLOCK_SPEED_Y_ + _TEXT_SPACING_ * 2
local separator3 = _G_Widget_.Line{
p1 = {x = _G_INIT_DATA_.LEFT_X, y = _SEP_Y_3_},
p2 = {x = _RIGHT_X_, y = _SEP_Y_3_}
p1 = {x = _G_INIT_DATA_.LEFT_X, y = _SEP_Y_3_},
p2 = {x = _RIGHT_X_, y = _SEP_Y_3_},
line_pattern = _G_Patterns_.BORDER_FG,
}
local _GPU_UTIL_Y_ = _SEP_Y_3_ + _SEPARATOR_SPACING_
@ -117,7 +120,11 @@ local gpu_util = {
x = _G_INIT_DATA_.LEFT_X,
y = _GPU_UTIL_Y_ + _PLOT_SEC_BREAK_,
width = _G_INIT_DATA_.SECTION_WIDTH,
height = _PLOT_HEIGHT_
height = _PLOT_HEIGHT_,
outline_pattern = _G_Patterns_.BORDER_FG,
intrvl_pattern = _G_Patterns_.BORDER_FG,
data_line_pattern = _G_Patterns_.PLOT_FILL_BORDER_PRIMARY,
data_fill_pattern = _G_Patterns_.PLOT_FILL_BG_PRIMARY,
}
}
@ -140,7 +147,11 @@ local mem_util = {
x = _G_INIT_DATA_.LEFT_X,
y = _MEM_UTIL_Y_ + _PLOT_SEC_BREAK_,
width = _G_INIT_DATA_.SECTION_WIDTH,
height = _PLOT_HEIGHT_
height = _PLOT_HEIGHT_,
outline_pattern = _G_Patterns_.BORDER_FG,
intrvl_pattern = _G_Patterns_.BORDER_FG,
data_line_pattern = _G_Patterns_.PLOT_FILL_BORDER_PRIMARY,
data_fill_pattern = _G_Patterns_.PLOT_FILL_BG_PRIMARY,
}
}
@ -163,7 +174,11 @@ local vid_util = {
x = _G_INIT_DATA_.LEFT_X,
y = _VID_UTIL_Y_ + _PLOT_SEC_BREAK_,
width = _G_INIT_DATA_.SECTION_WIDTH,
height = _PLOT_HEIGHT_
height = _PLOT_HEIGHT_,
outline_pattern = _G_Patterns_.BORDER_FG,
intrvl_pattern = _G_Patterns_.BORDER_FG,
data_line_pattern = _G_Patterns_.PLOT_FILL_BORDER_PRIMARY,
data_fill_pattern = _G_Patterns_.PLOT_FILL_BG_PRIMARY,
}
}

View File

@ -63,7 +63,9 @@ local dial = _G_Widget_.Dial{
y = DIAL_Y,
radius = DIAL_RADIUS,
thickness = _DIAL_THICKNESS_,
critical_limit = '>0.8'
critical_limit = '>0.8',
dial_pattern = _G_Patterns_.INDICATOR_FG_PRIMARY,
arc_pattern = _G_Patterns_.INDICATOR_BG
}
local cache_arc = _G_Widget_.Arc{
x = DIAL_X,
@ -133,20 +135,28 @@ local cache = {
local _PLOT_Y_ = _PLOT_SECTION_BREAK_ + header.bottom_y + DIAL_RADIUS * 2
local plot = _G_Widget_.LabelPlot{
x = _G_INIT_DATA_.RIGHT_X,
y = _PLOT_Y_,
width = _G_INIT_DATA_.SECTION_WIDTH,
height = _PLOT_HEIGHT_
x = _G_INIT_DATA_.RIGHT_X,
y = _PLOT_Y_,
width = _G_INIT_DATA_.SECTION_WIDTH,
height = _PLOT_HEIGHT_,
outline_pattern = _G_Patterns_.BORDER_FG,
intrvl_pattern = _G_Patterns_.BORDER_FG,
data_line_pattern = _G_Patterns_.PLOT_FILL_BORDER_PRIMARY,
data_fill_pattern = _G_Patterns_.PLOT_FILL_BG_PRIMARY,
}
local tbl = _G_Widget_.Table{
x = _G_INIT_DATA_.RIGHT_X,
y = _PLOT_Y_ + _PLOT_HEIGHT_ + _TABLE_SECTION_BREAK_,
width = _G_INIT_DATA_.SECTION_WIDTH,
height = _TABLE_HEIGHT_,
'Name',
'PID',
'Mem (%)'
x = _G_INIT_DATA_.RIGHT_X,
y = _PLOT_Y_ + _PLOT_HEIGHT_ + _TABLE_SECTION_BREAK_,
width = _G_INIT_DATA_.SECTION_WIDTH,
height = _TABLE_HEIGHT_,
body_color = _G_Patterns_.INACTIVE_TEXT_FG,
header_color = _G_Patterns_.PRIMARY_FG,
line_pattern = _G_Patterns_.BORDER_FG,
separator_pattern = _G_Patterns_.BORDER_FG,
'Name',
'PID',
'Mem (%)'
}
local update = function(cr)

View File

@ -26,47 +26,55 @@ local header = _G_Widget_.Header{
local _RIGHT_X_ = _G_INIT_DATA_.CENTER_RIGHT_X + _G_INIT_DATA_.SECTION_WIDTH
local dnload = {
label = _G_Widget_.Text{
x = _G_INIT_DATA_.CENTER_RIGHT_X,
y = header.bottom_y,
text = 'Download',
},
speed = _G_Widget_.Text{
x = _RIGHT_X_,
y = header.bottom_y,
x_align = 'right',
text_color = _G_Patterns_.PRIMARY_FG
},
plot = _G_Widget_.ScalePlot{
x = _G_INIT_DATA_.CENTER_RIGHT_X,
y = header.bottom_y + _PLOT_SEC_BREAK_,
width = _G_INIT_DATA_.SECTION_WIDTH,
height = _PLOT_HEIGHT_,
y_label_func = network_label_function
}
label = _G_Widget_.Text{
x = _G_INIT_DATA_.CENTER_RIGHT_X,
y = header.bottom_y,
text = 'Download',
},
speed = _G_Widget_.Text{
x = _RIGHT_X_,
y = header.bottom_y,
x_align = 'right',
text_color = _G_Patterns_.PRIMARY_FG
},
plot = _G_Widget_.ScalePlot{
x = _G_INIT_DATA_.CENTER_RIGHT_X,
y = header.bottom_y + _PLOT_SEC_BREAK_,
width = _G_INIT_DATA_.SECTION_WIDTH,
height = _PLOT_HEIGHT_,
y_label_func = network_label_function,
outline_pattern = _G_Patterns_.BORDER_FG,
intrvl_pattern = _G_Patterns_.BORDER_FG,
data_line_pattern = _G_Patterns_.PLOT_FILL_BORDER_PRIMARY,
data_fill_pattern = _G_Patterns_.PLOT_FILL_BG_PRIMARY,
}
}
local _UPLOAD_Y_ = header.bottom_y + _PLOT_HEIGHT_ + _PLOT_SEC_BREAK_ * 2
local upload = {
label = _G_Widget_.Text{
x = _G_INIT_DATA_.CENTER_RIGHT_X,
y = _UPLOAD_Y_,
text = 'Upload',
},
speed = _G_Widget_.Text{
x = _RIGHT_X_,
y = _UPLOAD_Y_,
x_align = 'right',
text_color = _G_Patterns_.PRIMARY_FG
},
plot = _G_Widget_.ScalePlot{
x = _G_INIT_DATA_.CENTER_RIGHT_X,
y = _UPLOAD_Y_ + _PLOT_SEC_BREAK_,
width = _G_INIT_DATA_.SECTION_WIDTH,
height = _PLOT_HEIGHT_,
y_label_func = network_label_function
}
label = _G_Widget_.Text{
x = _G_INIT_DATA_.CENTER_RIGHT_X,
y = _UPLOAD_Y_,
text = 'Upload',
},
speed = _G_Widget_.Text{
x = _RIGHT_X_,
y = _UPLOAD_Y_,
x_align = 'right',
text_color = _G_Patterns_.PRIMARY_FG
},
plot = _G_Widget_.ScalePlot{
x = _G_INIT_DATA_.CENTER_RIGHT_X,
y = _UPLOAD_Y_ + _PLOT_SEC_BREAK_,
width = _G_INIT_DATA_.SECTION_WIDTH,
height = _PLOT_HEIGHT_,
y_label_func = network_label_function,
outline_pattern = _G_Patterns_.BORDER_FG,
intrvl_pattern = _G_Patterns_.BORDER_FG,
data_line_pattern = _G_Patterns_.PLOT_FILL_BORDER_PRIMARY,
data_fill_pattern = _G_Patterns_.PLOT_FILL_BG_PRIMARY,
}
}
local interface_counters_tbl = {}

View File

@ -33,73 +33,85 @@ local _RIGHT_X_ = _G_INIT_DATA_.RIGHT_X + _G_INIT_DATA_.SECTION_WIDTH
local pkg0 = {
label = _G_Widget_.Text{
x = _G_INIT_DATA_.RIGHT_X,
y = header.bottom_y,
text = 'PKG0',
x = _G_INIT_DATA_.RIGHT_X,
y = header.bottom_y,
text = 'PKG0',
},
value = _G_Widget_.Text{
x = _RIGHT_X_,
y = header.bottom_y,
x_align = 'right',
text_color = Patterns.PRIMARY_FG,
text = '<core>',
append_end = ' W',
x = _RIGHT_X_,
y = header.bottom_y,
x_align = 'right',
text_color = Patterns.PRIMARY_FG,
text = '<core>',
append_end = ' W',
},
plot = _G_Widget_.ScalePlot{
x = _G_INIT_DATA_.RIGHT_X,
y = header.bottom_y + _PLOT_SEC_BREAK_,
width = _G_INIT_DATA_.SECTION_WIDTH,
height = _PLOT_HEIGHT_,
y_label_func = power_label_function,
x = _G_INIT_DATA_.RIGHT_X,
y = header.bottom_y + _PLOT_SEC_BREAK_,
width = _G_INIT_DATA_.SECTION_WIDTH,
height = _PLOT_HEIGHT_,
y_label_func = power_label_function,
outline_pattern = _G_Patterns_.BORDER_FG,
intrvl_pattern = _G_Patterns_.BORDER_FG,
data_line_pattern = _G_Patterns_.PLOT_FILL_BORDER_PRIMARY,
data_fill_pattern = _G_Patterns_.PLOT_FILL_BG_PRIMARY,
},
}
local _CORE_Y_ = header.bottom_y + _TEXT_SPACING_ + _PLOT_SEC_BREAK_ + _PLOT_HEIGHT_
local dram = {
label = _G_Widget_.Text{
x = _G_INIT_DATA_.RIGHT_X,
y = _CORE_Y_,
text = 'DRAM'
},
value = _G_Widget_.Text{
x = _RIGHT_X_,
y = _CORE_Y_,
x_align = 'right',
text_color = _G_Patterns_.PRIMARY_FG,
text = '<dram>',
append_end = ' W'
},
plot = _G_Widget_.ScalePlot{
x = _G_INIT_DATA_.RIGHT_X,
y = _CORE_Y_ + _PLOT_SEC_BREAK_,
width = _G_INIT_DATA_.SECTION_WIDTH,
height = _PLOT_HEIGHT_,
y_label_func = power_label_function,
}
label = _G_Widget_.Text{
x = _G_INIT_DATA_.RIGHT_X,
y = _CORE_Y_,
text = 'DRAM'
},
value = _G_Widget_.Text{
x = _RIGHT_X_,
y = _CORE_Y_,
x_align = 'right',
text_color = _G_Patterns_.PRIMARY_FG,
text = '<dram>',
append_end = ' W'
},
plot = _G_Widget_.ScalePlot{
x = _G_INIT_DATA_.RIGHT_X,
y = _CORE_Y_ + _PLOT_SEC_BREAK_,
width = _G_INIT_DATA_.SECTION_WIDTH,
height = _PLOT_HEIGHT_,
y_label_func = power_label_function,
outline_pattern = _G_Patterns_.BORDER_FG,
intrvl_pattern = _G_Patterns_.BORDER_FG,
data_line_pattern = _G_Patterns_.PLOT_FILL_BORDER_PRIMARY,
data_fill_pattern = _G_Patterns_.PLOT_FILL_BG_PRIMARY,
}
}
local _BATTERY_DRAW_Y_ = _CORE_Y_ + _PLOT_SEC_BREAK_ * 2 + _PLOT_HEIGHT_
local battery_draw = {
label = _G_Widget_.Text{
x = _G_INIT_DATA_.RIGHT_X,
y = _BATTERY_DRAW_Y_,
spacing = _TEXT_SPACING_,
text = 'Battery Draw'
},
value = _G_Widget_.CriticalText{
x = _RIGHT_X_,
y = _BATTERY_DRAW_Y_,
x_align = 'right',
},
plot = _G_Widget_.ScalePlot{
x = _G_INIT_DATA_.RIGHT_X,
y = _BATTERY_DRAW_Y_ + _PLOT_SEC_BREAK_,
width = _G_INIT_DATA_.SECTION_WIDTH,
height = _PLOT_HEIGHT_,
y_label_func = power_label_function,
}
label = _G_Widget_.Text{
x = _G_INIT_DATA_.RIGHT_X,
y = _BATTERY_DRAW_Y_,
spacing = _TEXT_SPACING_,
text = 'Battery Draw'
},
value = _G_Widget_.CriticalText{
x = _RIGHT_X_,
y = _BATTERY_DRAW_Y_,
x_align = 'right',
},
plot = _G_Widget_.ScalePlot{
x = _G_INIT_DATA_.RIGHT_X,
y = _BATTERY_DRAW_Y_ + _PLOT_SEC_BREAK_,
width = _G_INIT_DATA_.SECTION_WIDTH,
height = _PLOT_HEIGHT_,
y_label_func = power_label_function,
outline_pattern = _G_Patterns_.BORDER_FG,
intrvl_pattern = _G_Patterns_.BORDER_FG,
data_line_pattern = _G_Patterns_.PLOT_FILL_BORDER_PRIMARY,
data_fill_pattern = _G_Patterns_.PLOT_FILL_BG_PRIMARY,
}
}
local PKG0_PATH = '/sys/class/powercap/intel-rapl:0/energy_uj'

View File

@ -68,7 +68,9 @@ local _create_core_ = function(cores, id, x, y)
outer_radius = _DIAL_OUTER_RADIUS_,
spacing = _DIAL_SPACING_,
num_dials = NUM_THREADS_PER_CORE,
critical_limit = '>0.8'
critical_limit = '>0.8',
dial_pattern = _G_Patterns_.INDICATOR_FG_PRIMARY,
arc_pattern = _G_Patterns_.INDICATOR_BG
},
inner_ring = _G_Widget_.Arc{
x = x,
@ -149,7 +151,8 @@ local _SEP_Y_ = _FREQ_Y_ + _SEPARATOR_SPACING_
local separator = _G_Widget_.Line{
p1 = {x = _G_INIT_DATA_.LEFT_X, y = _SEP_Y_},
p2 = {x = _RIGHT_X_, y = _SEP_Y_}
p2 = {x = _RIGHT_X_, y = _SEP_Y_},
line_pattern = _G_Patterns_.BORDER_FG,
}
local _LOAD_Y_ = _SEP_Y_ + _SEPARATOR_SPACING_
@ -175,7 +178,11 @@ local plot = _G_Widget_.LabelPlot{
x = _G_INIT_DATA_.LEFT_X,
y = _PLOT_Y_,
width = _G_INIT_DATA_.SECTION_WIDTH,
height = _PLOT_HEIGHT_
height = _PLOT_HEIGHT_,
outline_pattern = _G_Patterns_.BORDER_FG,
intrvl_pattern = _G_Patterns_.BORDER_FG,
data_line_pattern = _G_Patterns_.PLOT_FILL_BORDER_PRIMARY,
data_fill_pattern = _G_Patterns_.PLOT_FILL_BG_PRIMARY,
}
local tbl = _G_Widget_.Table{
@ -184,6 +191,10 @@ local tbl = _G_Widget_.Table{
width = _G_INIT_DATA_.SECTION_WIDTH,
height = _TABLE_HEIGHT_,
num_rows = NUM_ROWS,
body_color = _G_Patterns_.INACTIVE_TEXT_FG,
header_color = _G_Patterns_.ACTIVE_FG,
line_pattern = _G_Patterns_.BORDER_FG,
separator_pattern = _G_Patterns_.BORDER_FG,
'Name',
'PID',
'CPU (%)'

View File

@ -58,49 +58,57 @@ local header = _G_Widget_.Header{
local _RIGHT_X_ = _G_INIT_DATA_.CENTER_LEFT_X + _G_INIT_DATA_.SECTION_WIDTH
local reads = {
label = _G_Widget_.Text{
x = _G_INIT_DATA_.CENTER_LEFT_X,
y = header.bottom_y,
text = 'Reads',
},
rate = _G_Widget_.Text{
x = _RIGHT_X_,
y = header.bottom_y,
x_align = 'right',
append_end=' B/s',
text_color = _G_Patterns_.PRIMARY_FG
},
plot = _G_Widget_.ScalePlot{
x = _G_INIT_DATA_.CENTER_LEFT_X,
y = header.bottom_y + _PLOT_SEC_BREAK_,
width = _G_INIT_DATA_.SECTION_WIDTH,
height = _PLOT_HEIGHT_,
y_label_func = io_label_function,
}
label = _G_Widget_.Text{
x = _G_INIT_DATA_.CENTER_LEFT_X,
y = header.bottom_y,
text = 'Reads',
},
rate = _G_Widget_.Text{
x = _RIGHT_X_,
y = header.bottom_y,
x_align = 'right',
append_end=' B/s',
text_color = _G_Patterns_.PRIMARY_FG
},
plot = _G_Widget_.ScalePlot{
x = _G_INIT_DATA_.CENTER_LEFT_X,
y = header.bottom_y + _PLOT_SEC_BREAK_,
width = _G_INIT_DATA_.SECTION_WIDTH,
height = _PLOT_HEIGHT_,
y_label_func = io_label_function,
outline_pattern = _G_Patterns_.BORDER_FG,
intrvl_pattern = _G_Patterns_.BORDER_FG,
data_line_pattern = _G_Patterns_.PLOT_FILL_BORDER_PRIMARY,
data_fill_pattern = _G_Patterns_.PLOT_FILL_BG_PRIMARY,
}
}
local _WRITE_Y_ = header.bottom_y + _PLOT_HEIGHT_ + _PLOT_SEC_BREAK_ * 2
local writes = {
label = _G_Widget_.Text{
x = _G_INIT_DATA_.CENTER_LEFT_X,
y = _WRITE_Y_,
text = 'Writes',
},
rate = _G_Widget_.Text{
x = _RIGHT_X_,
y = _WRITE_Y_,
x_align = 'right',
append_end =' B/s',
text_color = _G_Patterns_.PRIMARY_FG
},
plot = _G_Widget_.ScalePlot{
x = _G_INIT_DATA_.CENTER_LEFT_X,
y = _WRITE_Y_ + _PLOT_SEC_BREAK_,
width = _G_INIT_DATA_.SECTION_WIDTH,
height = _PLOT_HEIGHT_,
y_label_func = io_label_function,
}
label = _G_Widget_.Text{
x = _G_INIT_DATA_.CENTER_LEFT_X,
y = _WRITE_Y_,
text = 'Writes',
},
rate = _G_Widget_.Text{
x = _RIGHT_X_,
y = _WRITE_Y_,
x_align = 'right',
append_end =' B/s',
text_color = _G_Patterns_.PRIMARY_FG
},
plot = _G_Widget_.ScalePlot{
x = _G_INIT_DATA_.CENTER_LEFT_X,
y = _WRITE_Y_ + _PLOT_SEC_BREAK_,
width = _G_INIT_DATA_.SECTION_WIDTH,
height = _PLOT_HEIGHT_,
y_label_func = io_label_function,
outline_pattern = _G_Patterns_.BORDER_FG,
intrvl_pattern = _G_Patterns_.BORDER_FG,
data_line_pattern = _G_Patterns_.PLOT_FILL_BORDER_PRIMARY,
data_fill_pattern = _G_Patterns_.PLOT_FILL_BG_PRIMARY,
}
}
_PLOT_SEC_BREAK_ = nil