From 30a39aa34bce72f752ec43cb4f73017acc8e7ff6 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Sun, 11 Jul 2021 16:53:25 -0400 Subject: [PATCH] ENH use table style objects --- core | 2 +- drawing/Common.lua | 65 ++++++++++++++++++++++++++++++++++------------ 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/core b/core index baf94be..d21bbf5 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit baf94bef542099065d73c268bfb8ff0ae96908b9 +Subproject commit d21bbf57059f91a63e01fdb874f02e2c603cb85b diff --git a/drawing/Common.lua b/drawing/Common.lua index c20b640..cf02023 100644 --- a/drawing/Common.lua +++ b/drawing/Common.lua @@ -536,21 +536,52 @@ end -------------------------------------------------------------------------------- -- table +M.default_table_font_spec = M.make_font_spec(_G_Patterns_.FONT, 11, false) + +M.default_table_style = _G_Widget_.table_style( + _G_Widget_.rect_style( + 1, + _G_Patterns_.BORDER_FG + ), + _G_Widget_.line_style( + 1, + _G_Patterns_.BORDER_FG, + CAIRO_LINE_CAP_BUTT + ), + _G_Widget_.table_header_style( + M.default_table_font_spec, + _G_Patterns_.PRIMARY_FG, + 20 + ), + _G_Widget_.table_body_style( + M.default_table_font_spec, + _G_Patterns_.INACTIVE_TEXT_FG, + 8 + ), + _G_Widget_.padding(5, 15, 5, 15) +) + M.initTable = function(x, y, w, h, n, labels) - return _G_Widget_.Table{ - x = x, - y = y, - width = w, - height = h, - num_rows = n, - 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, - body_font_spec = M.make_font_spec(_G_Patterns_.FONT, 11, false), - header_font_spec = M.make_font_spec(_G_Patterns_.FONT, 11, false), - table.unpack(labels), - } + -- return _G_Widget_.Table{ + -- x = x, + -- y = y, + -- width = w, + -- height = h, + -- num_rows = n, + -- 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, + -- body_font_spec = M.make_font_spec(_G_Patterns_.FONT, 11, false), + -- header_font_spec = M.make_font_spec(_G_Patterns_.FONT, 11, false), + -- table.unpack(labels), + -- } + return _G_Widget_.Table( + _G_Widget_.make_box(_G_Widget_.make_point(x, y), w, h), + n, + labels, + M.default_table_style + ) end -------------------------------------------------------------------------------- @@ -563,8 +594,10 @@ M.initPanel = function(x, y, w, h, thickness) w, h ), - thickness, - _G_Patterns_.BORDER_FG, + _G_Widget_.rect_style( + thickness, + _G_Patterns_.BORDER_FG + ), _G_Patterns_.PANEL_BG ) end