split drawing modules into static and dynamic

This commit is contained in:
petrucci4prez 2018-08-05 11:22:07 -04:00
parent 77974cc7bc
commit 715e856d20
11 changed files with 132 additions and 34 deletions

View File

@ -1,3 +1,5 @@
local M = {}
local Text = require 'Text'
local Line = require 'Line'
local TextColumn = require 'TextColumn'
@ -59,7 +61,11 @@ local update = function(cr)
end
end
local draw = function(cr, trigger)
local draw_static = function(cr)
end
local draw_dynamic = function(cr, trigger)
if trigger == 0 then update(cr) end
Text.draw(header.text, cr)
@ -68,4 +74,7 @@ local draw = function(cr, trigger)
CompoundBar.draw(bars, cr)
end
return draw
M.draw_static = draw_static
M.draw_dynamic = draw_dynamic
return M

View File

@ -1,3 +1,5 @@
local M = {}
local CriticalText = require 'CriticalText'
local Text = require 'Text'
local TextColumn = require 'TextColumn'
@ -266,7 +268,11 @@ _GPU_UTIL_Y_ = nil
_MEM_UTIL_Y_ = nil
_VID_UTIL_Y_ = nil
local draw = function(cr)
local draw_static = function(cr)
end
local draw_dynamic = function(cr)
update(cr)
Text.draw(header.text, cr)
@ -300,5 +306,7 @@ local draw = function(cr)
LabelPlot.draw(vid_util.plot, cr)
end
return draw
M.draw_static = draw_static
M.draw_dynamic = draw_dynamic
return M

View File

@ -1,3 +1,5 @@
local M = {}
local Arc = require 'Arc'
local Dial = require 'Dial'
local CriticalText = require 'CriticalText'
@ -196,7 +198,11 @@ _TEXT_LEFT_X_ = nil
_RIGHT_X_ = nil
_PLOT_Y_ = nil
local draw = function(cr)
local draw_static = function(cr)
end
local draw_dynamic = function(cr)
update(cr)
Text.draw(header.text, cr)
@ -216,4 +222,7 @@ local draw = function(cr)
Table.draw(tbl, cr)
end
return draw
M.draw_static = draw_static
M.draw_dynamic = draw_dynamic
return M

View File

@ -1,3 +1,5 @@
local M = {}
local Text = require 'Text'
local Line = require 'Line'
local ScalePlot = require 'ScalePlot'
@ -130,7 +132,11 @@ _PLOT_HEIGHT_ = nil
_RIGHT_X_ = nil
_UPLOAD_Y_ = nil
local draw = function(cr, update_frequency)
local draw_static = function(cr)
end
local draw_dynamic = function(cr, update_frequency)
update(cr, update_frequency)
Text.draw(header.text, cr)
@ -145,4 +151,7 @@ local draw = function(cr, update_frequency)
ScalePlot.draw(upload.plot, cr)
end
return draw
M.draw_static = draw_static
M.draw_dynamic = draw_dynamic
return M

View File

@ -1,3 +1,5 @@
local M = {}
local Text = require 'Text'
local Line = require 'Line'
local TextColumn = require 'TextColumn'
@ -47,7 +49,11 @@ local update = function(cr)
end
end
local draw = function(cr, log_is_changed)
local draw_static = function(cr)
end
local draw_dynamic = function(cr, log_is_changed)
if log_is_changed then update(cr) end
Text.draw(header.text, cr)
@ -56,4 +62,7 @@ local draw = function(cr, log_is_changed)
TextColumn.draw(info, cr)
end
return draw
M.draw_static = draw_static
M.draw_dynamic = draw_dynamic
return M

View File

@ -1,3 +1,5 @@
local M = {}
local Widget = require 'Widget'
local FillRect = require 'FillRect'
@ -22,10 +24,12 @@ local right = Widget.Panel{
Widget = nil
local draw = function(cr)
local draw_static = function(cr)
FillRect.draw(left, cr)
FillRect.draw(center, cr)
FillRect.draw(right, cr)
end
return draw
M.draw_static = draw_static
return M

View File

@ -1,3 +1,5 @@
local M = {}
local Patterns = require 'Patterns'
local Text = require 'Text'
local TextColumn = require 'TextColumn'
@ -209,7 +211,11 @@ _RIGHT_X_ = nil
_CORE_Y_ = nil
_BATTERY_DRAW_Y_ = nil
local draw = function(cr, update_frequency, is_using_ac)
local draw_static = function(cr)
end
local draw_dynamic = function(cr, update_frequency, is_using_ac)
update(cr, update_frequency, is_using_ac)
Text.draw(header.text, cr)
@ -230,4 +236,7 @@ local draw = function(cr, update_frequency, is_using_ac)
ScalePlot.draw(battery_draw.plot, cr)
end
return draw
M.draw_static = draw_static
M.draw_dynamic = draw_dynamic
return M

View File

@ -1,3 +1,5 @@
local M = {}
local Arc = require 'Arc'
local CompoundDial = require 'CompoundDial'
local CriticalText = require 'CriticalText'
@ -249,7 +251,11 @@ _SEP_Y_ = nil
_PROCESS_Y_ = nil
_PLOT_Y_ = nil
local draw = function(cr)
local draw_static = function(cr)
end
local draw_dynamic = function(cr)
update(cr)
Text.draw(header.text, cr)
@ -278,4 +284,7 @@ local draw = function(cr)
Table.draw(tbl, cr)
end
return draw
M.draw_static = draw_static
M.draw_dynamic = draw_dynamic
return M

View File

@ -1,3 +1,5 @@
local M = {}
local Text = require 'Text'
local Line = require 'Line'
local ScalePlot = require 'ScalePlot'
@ -117,7 +119,11 @@ local update = function(cr, update_frequency)
update_stat(cr, writes, write_byte_cnt, update_frequency)
end
local draw = function(cr, update_frequency)
local draw_static = function(cr)
end
local draw_dynamic = function(cr, update_frequency)
update(cr, update_frequency)
Text.draw(header.text, cr)
@ -132,4 +138,7 @@ local draw = function(cr, update_frequency)
ScalePlot.draw(writes.plot, cr)
end
return draw
M.draw_static = draw_static
M.draw_dynamic = draw_dynamic
return M

View File

@ -1,3 +1,5 @@
local M = {}
local Text = require 'Text'
local Line = require 'Line'
local TextColumn = require 'TextColumn'
@ -42,7 +44,11 @@ local info = _G_Widget_.TextColumn{
_TEXT_SPACING_ = nil
local draw = function(cr, log_is_changed)
local draw_static = function(cr)
end
local draw_dynamic = function(cr, log_is_changed)
TextColumn.set(info, cr, 2, Util.conky('$uptime'))
if log_is_changed then
@ -58,4 +64,7 @@ local draw = function(cr, log_is_changed)
TextColumn.draw(info, cr)
end
return draw
M.draw_static = draw_static
M.draw_dynamic = draw_dynamic
return M

View File

@ -158,7 +158,21 @@ local uninit = 1
conky_startup = function()
cs_p = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1920, 1080)
local cr = __cairo_create(cs_p)
Panel(cr)
Panel.draw_static(cr)
System.draw_static(cr)
Graphics.draw_static(cr)
Processor.draw_static(cr)
ReadWrite.draw_static(cr)
Network.draw_static(cr)
Pacman.draw_static(cr)
FileSystem.draw_static(cr)
Power.draw_static(cr)
Memory.draw_static(cr)
uninit = nil
end
@ -170,6 +184,8 @@ function conky_main()
local cs = __cairo_xlib_surface_create(_cw.display, _cw.drawable, _cw.visual, 1920, 1080)
local cr = __cairo_create(cs)
local pt1 = os.clock()
cairo_set_source_surface(cr, cs_p, 0, 0)
cairo_paint(cr)
@ -189,22 +205,20 @@ function conky_main()
local log_is_changed = false
if t2 == 0 then log_is_changed = check_if_log_changed() end
-- local pt1 = os.clock()
System.draw_dynamic(cr, log_is_changed)
Graphics.draw_dynamic(cr)
Processor.draw_dynamic(cr)
System(cr, log_is_changed)
Graphics(cr)
Processor(cr)
ReadWrite.draw_dynamic(cr, UPDATE_FREQUENCY)
Network.draw_dynamic(cr, UPDATE_FREQUENCY)
ReadWrite(cr, UPDATE_FREQUENCY)
Network(cr, UPDATE_FREQUENCY)
Pacman.draw_dynamic(cr, log_is_changed)
FileSystem.draw_dynamic(cr, t1)
Power.draw_dynamic(cr, UPDATE_FREQUENCY, is_using_ac)
Memory.draw_dynamic(cr)
Pacman(cr, log_is_changed)
FileSystem(cr, t1)
Power(cr, UPDATE_FREQUENCY, is_using_ac)
Memory(cr)
-- local pt2 = os.clock() - pt1
-- print(pt2)
local pt2 = os.clock() - pt1
print(pt2)
__cairo_surface_destroy(cs)
__cairo_destroy(cr)