From c48e138b01f54dbbdcf0bfa59fb86c7bbec94b72 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 28 Mar 2021 02:33:38 -0700 Subject: [PATCH 1/3] doc: Add examples for the graph. --- lib/wibox/widget/graph.lua | 42 ++++++++++--- .../wibox/widget/graph/background_color.lua | 41 +++++++++++++ .../wibox/widget/graph/border_color.lua | 41 +++++++++++++ .../wibox/widget/graph/border_width.lua | 42 +++++++++++++ tests/examples/wibox/widget/graph/color.lua | 41 +++++++++++++ .../examples/wibox/widget/graph/max_value.lua | 56 ++++++++++++++++++ .../examples/wibox/widget/graph/min_value.lua | 57 ++++++++++++++++++ tests/examples/wibox/widget/graph/scale1.lua | 56 ++++++++++++++++++ tests/examples/wibox/widget/graph/stacked.lua | 59 +++++++++++++++++++ tests/examples/wibox/widget/graph/step.lua | 43 +++++++++----- .../wibox/widget/graph/step_shape.lua | 55 +++++++++++++++++ .../wibox/widget/graph/step_spacing.lua | 42 +++++++++++++ 12 files changed, 554 insertions(+), 21 deletions(-) create mode 100644 tests/examples/wibox/widget/graph/background_color.lua create mode 100644 tests/examples/wibox/widget/graph/border_color.lua create mode 100644 tests/examples/wibox/widget/graph/border_width.lua create mode 100644 tests/examples/wibox/widget/graph/color.lua create mode 100644 tests/examples/wibox/widget/graph/max_value.lua create mode 100644 tests/examples/wibox/widget/graph/min_value.lua create mode 100644 tests/examples/wibox/widget/graph/scale1.lua create mode 100644 tests/examples/wibox/widget/graph/stacked.lua create mode 100644 tests/examples/wibox/widget/graph/step_shape.lua create mode 100644 tests/examples/wibox/widget/graph/step_spacing.lua diff --git a/lib/wibox/widget/graph.lua b/lib/wibox/widget/graph.lua index 18e91ace..0c9d3fce 100644 --- a/lib/wibox/widget/graph.lua +++ b/lib/wibox/widget/graph.lua @@ -27,10 +27,21 @@ local beautiful = require("beautiful") local graph = { mt = {} } +--- Set the graph border_width. +-- +--@DOC_wibox_widget_graph_border_width_EXAMPLE@ +-- +-- @property border_width +-- @tparam number border_width +-- @propemits true false +-- @see border_color + --- Set the graph border color. -- -- If the value is nil, no border will be drawn. -- +--@DOC_wibox_widget_graph_border_color_EXAMPLE@ +-- -- @property border_color -- @tparam gears.color border_color The border color to set. -- @propbeautiful @@ -39,6 +50,8 @@ local graph = { mt = {} } --- Set the graph foreground color. -- +--@DOC_wibox_widget_graph_color_EXAMPLE@ +-- -- @property color -- @tparam color color The graph color. -- @usebeautiful beautiful.graph_fg @@ -47,6 +60,8 @@ local graph = { mt = {} } --- Set the graph background color. -- +--@DOC_wibox_widget_graph_background_color_EXAMPLE@ +-- -- @property background_color -- @tparam gears.color background_color The graph background color. -- @usebeautiful beautiful.graph_bg @@ -55,6 +70,8 @@ local graph = { mt = {} } --- Set the maximum value the graph should handle. -- +-- @DOC_wibox_widget_graph_max_value_EXAMPLE@ +-- -- If "scale" is also set, the graph never scales up below this value, but it -- automatically scales down to make all data fit. -- @@ -64,6 +81,8 @@ local graph = { mt = {} } --- The minimum value. -- +-- @DOC_wibox_widget_graph_min_value_EXAMPLE@ +-- -- Note that the min_value is not supported when used along with the stack -- property. -- @property min_value @@ -72,6 +91,8 @@ local graph = { mt = {} } --- Set the graph to automatically scale its values. Default is false. -- +--@DOC_wibox_widget_graph_scale1_EXAMPLE@ +-- -- @property scale -- @tparam boolean scale -- @propemits true false @@ -90,12 +111,16 @@ local graph = { mt = {} } -- -- Note that it isn't supported when used along with stacked graphs. -- +--@DOC_wibox_widget_graph_step_spacing_EXAMPLE@ +-- -- @property step_spacing -- @tparam[opt=0] number step_spacing -- @propemits true false --- The step shape. -- +--@DOC_wibox_widget_graph_step_shape_EXAMPLE@ +-- -- @property step_shape -- @tparam[opt=rectangle] gears.shape|function step_shape -- @propemits true false @@ -103,6 +128,7 @@ local graph = { mt = {} } --- Set the graph to draw stacks. Default is false. -- +--@DOC_wibox_widget_graph_stacked_EXAMPLE@ -- @property stack -- @tparam boolean stack -- @propemits true false @@ -130,7 +156,7 @@ local graph = { mt = {} } local properties = { "width", "height", "border_color", "stack", "stack_colors", "color", "background_color", "max_value", "scale", "min_value", "step_shape", - "step_spacing", "step_width" } + "step_spacing", "step_width", "border_width" } function graph.draw(_graph, _, cr, width, height) local max_value = _graph._private.max_value @@ -141,8 +167,9 @@ function graph.draw(_graph, _, cr, width, height) local step_shape = _graph._private.step_shape local step_spacing = _graph._private.step_spacing or 0 local step_width = _graph._private.step_width or 1 + local bw = _graph._private.border_width or 1 - cr:set_line_width(1) + cr:set_line_width(bw) -- Draw the background first cr:set_source(color(_graph._private.background_color or beautiful.graph_bg or "#000000aa")) @@ -150,9 +177,10 @@ function graph.draw(_graph, _, cr, width, height) -- Account for the border width cr:save() + if _graph._private.border_color then - cr:translate(1, 1) - width, height = width - 2, height - 2 + cr:translate(bw, bw) + width, height = width - 2*bw, height - 2*bw end -- Draw a stacked graph @@ -239,10 +267,10 @@ function graph.draw(_graph, _, cr, width, height) -- Draw the border last so that it overlaps already drawn values if _graph._private.border_color then -- We decremented these by two above - width, height = width + 2, height + 2 + width, height = width + 2*bw, height + 2*bw -- Draw the border - cr:rectangle(0.5, 0.5, width - 1, height - 1) + cr:rectangle(bw/2, bw/2, width - bw, height - bw) cr:set_source(color(_graph._private.border_color or beautiful.graph_border_color or "#ffffff")) cr:stroke() end @@ -277,7 +305,7 @@ function graph:add_value(value, group) table.insert(values, value) local border_width = 0 - if self._private.border_color then border_width = 2 end + if self._private.border_color then border_width = self._private.border_width*2 end -- Ensure we never have more data than we can draw while #values > self._private.width - border_width do diff --git a/tests/examples/wibox/widget/graph/background_color.lua b/tests/examples/wibox/widget/graph/background_color.lua new file mode 100644 index 00000000..7c8a1dae --- /dev/null +++ b/tests/examples/wibox/widget/graph/background_color.lua @@ -0,0 +1,41 @@ +--DOC_GEN_IMAGE --DOC_HIDE +local parent = ... --DOC_HIDE +local wibox = require("wibox") --DOC_HIDE + +local data = { --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE +} --DOC_HIDE + +local l = wibox.layout { --DOC_HIDE + forced_height = 100, --DOC_HIDE + forced_width = 100, --DOC_HIDE + spacing = 5, --DOC_HIDE + layout = wibox.layout.flex.vertical --DOC_HIDE +} --DOC_HIDE + +for _, color in ipairs {"#ff0000", "#00ff00", "#0000ff", "#ff00ff" } do + local w = --DOC_HIDE + + wibox.widget { + border_width = 2, --DOC_HIDE + margins = 5, --DOC_HIDE + max_value = 29, + background_color = color, + widget = wibox.widget.graph, + } + + l:add(w) --DOC_HIDE + + for _, v in ipairs(data) do --DOC_HIDE + w:add_value(v) --DOC_HIDE + end --DOC_HIDE + + end + +parent:add(l) --DOC_HIDE + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/graph/border_color.lua b/tests/examples/wibox/widget/graph/border_color.lua new file mode 100644 index 00000000..e7db465f --- /dev/null +++ b/tests/examples/wibox/widget/graph/border_color.lua @@ -0,0 +1,41 @@ +--DOC_GEN_IMAGE --DOC_HIDE +local parent = ... --DOC_HIDE +local wibox = require("wibox") --DOC_HIDE + +local data = { --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE +} --DOC_HIDE + +local l = wibox.layout { --DOC_HIDE + forced_height = 100, --DOC_HIDE + forced_width = 100, --DOC_HIDE + spacing = 5, --DOC_HIDE + layout = wibox.layout.flex.vertical --DOC_HIDE +} --DOC_HIDE + +for _, color in ipairs {"#ff0000", "#00ff00", "#0000ff", "#ff00ff" } do + local w = --DOC_HIDE + + wibox.widget { + max_value = 29, + border_width = 2, --DOC_HIDE + border_color = color, + margins = 5, --DOC_HIDE + widget = wibox.widget.graph, + } + + l:add(w) --DOC_HIDE + + for _, v in ipairs(data) do --DOC_HIDE + w:add_value(v) --DOC_HIDE + end --DOC_HIDE + + end + +parent:add(l) --DOC_HIDE + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/graph/border_width.lua b/tests/examples/wibox/widget/graph/border_width.lua new file mode 100644 index 00000000..4910fd04 --- /dev/null +++ b/tests/examples/wibox/widget/graph/border_width.lua @@ -0,0 +1,42 @@ +--DOC_GEN_IMAGE --DOC_HIDE +local parent = ... --DOC_HIDE +local wibox = require("wibox") --DOC_HIDE +local beautiful = require("beautiful") --DOC_HIDE + +local data = { --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE +} --DOC_HIDE + +local l = wibox.layout { --DOC_HIDE + forced_height = 100, --DOC_HIDE + forced_width = 100, --DOC_HIDE + spacing = 5, --DOC_HIDE + layout = wibox.layout.flex.vertical --DOC_HIDE +} --DOC_HIDE + +for _, width in ipairs { 1, 2, 4, 10 } do + local w = --DOC_HIDE + + wibox.widget { + max_value = 30, + border_width = width, --DOC_HIDE + border_color = beautiful.border_color, + margins = 5, --DOC_HIDE + widget = wibox.widget.graph, + } + + l:add(w) --DOC_HIDE + + for _, v in ipairs(data) do --DOC_HIDE + w:add_value(v) --DOC_HIDE + end --DOC_HIDE + + end + +parent:add(l) --DOC_HIDE + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/graph/color.lua b/tests/examples/wibox/widget/graph/color.lua new file mode 100644 index 00000000..fe0cc915 --- /dev/null +++ b/tests/examples/wibox/widget/graph/color.lua @@ -0,0 +1,41 @@ +--DOC_GEN_IMAGE --DOC_HIDE +local parent = ... --DOC_HIDE +local wibox = require("wibox") --DOC_HIDE + +local data = { --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE +} --DOC_HIDE + +local l = wibox.layout { --DOC_HIDE + forced_height = 100, --DOC_HIDE + forced_width = 100, --DOC_HIDE + spacing = 5, --DOC_HIDE + layout = wibox.layout.flex.vertical --DOC_HIDE +} --DOC_HIDE + +for _, color in ipairs {"#ff0000", "#00ff00", "#0000ff", "#ff00ff" } do + local w = --DOC_HIDE + + wibox.widget { + max_value = 29, + color = color, + widget = wibox.widget.graph, + border_width = 2, --DOC_HIDE + margins = 5, --DOC_HIDE + } + + l:add(w) --DOC_HIDE + + for _, v in ipairs(data) do --DOC_HIDE + w:add_value(v) --DOC_HIDE + end --DOC_HIDE + + end + +parent:add(l) --DOC_HIDE + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/graph/max_value.lua b/tests/examples/wibox/widget/graph/max_value.lua new file mode 100644 index 00000000..f337d3b3 --- /dev/null +++ b/tests/examples/wibox/widget/graph/max_value.lua @@ -0,0 +1,56 @@ +--DOC_GEN_IMAGE --DOC_HIDE +local parent = ... --DOC_HIDE +local wibox = require("wibox") --DOC_HIDE + +local data = { --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE +} --DOC_HIDE + + +local w1 = --DOC_HIDE +wibox.widget { + max_value = 30, + widget = wibox.widget.graph, +} + +--DOC_NEWLINE + +local w2 = --DOC_HIDE +wibox.widget { + max_value = 10, + widget = wibox.widget.graph, +} + +for _, v in ipairs(data) do --DOC_HIDE + w1:add_value(v) --DOC_HIDE + w2:add_value(v) --DOC_HIDE +end --DOC_HIDE + +parent:add(wibox.layout {--DOC_HIDE + {--DOC_HIDE + {--DOC_HIDE + markup = "With `max_value = 30`",--DOC_HIDE + widget = wibox.widget.textbox,--DOC_HIDE + },--DOC_HIDE + w1,--DOC_HIDE + layout = wibox.layout.fixed.vertical,--DOC_HIDE + },--DOC_HIDE + {--DOC_HIDE + {--DOC_HIDE + markup = "With `max_value = 10`",--DOC_HIDE + widget = wibox.widget.textbox,--DOC_HIDE + },--DOC_HIDE + w2,--DOC_HIDE + layout = wibox.layout.fixed.vertical,--DOC_HIDE + },--DOC_HIDE + + forced_width = 240, --DOC_HIDE + spacing = 5, --DOC_HIDE + layout = wibox.layout.flex.horizontal --DOC_HIDE +}) --DOC_HIDE + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/graph/min_value.lua b/tests/examples/wibox/widget/graph/min_value.lua new file mode 100644 index 00000000..d33506b0 --- /dev/null +++ b/tests/examples/wibox/widget/graph/min_value.lua @@ -0,0 +1,57 @@ +--DOC_GEN_IMAGE --DOC_HIDE +local parent = ... --DOC_HIDE +local wibox = require("wibox") --DOC_HIDE + +local data = { --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE +} --DOC_HIDE + + +local w1 = --DOC_HIDE +wibox.widget { + max_value = 30, + widget = wibox.widget.graph, +} + +--DOC_NEWLINE + +local w2 = --DOC_HIDE +wibox.widget { + min_value = 10, + max_value = 30, + widget = wibox.widget.graph, +} + +for _, v in ipairs(data) do --DOC_HIDE + w1:add_value(v) --DOC_HIDE + w2:add_value(v) --DOC_HIDE +end --DOC_HIDE + +parent:add(wibox.layout {--DOC_HIDE + {--DOC_HIDE + {--DOC_HIDE + markup = "Without `min_value`",--DOC_HIDE + widget = wibox.widget.textbox,--DOC_HIDE + },--DOC_HIDE + w1,--DOC_HIDE + layout = wibox.layout.fixed.vertical,--DOC_HIDE + },--DOC_HIDE + {--DOC_HIDE + {--DOC_HIDE + markup = "With `min_value = 10`",--DOC_HIDE + widget = wibox.widget.textbox,--DOC_HIDE + },--DOC_HIDE + w2,--DOC_HIDE + layout = wibox.layout.fixed.vertical,--DOC_HIDE + },--DOC_HIDE + + forced_width = 240, --DOC_HIDE + spacing = 5, --DOC_HIDE + layout = wibox.layout.flex.horizontal --DOC_HIDE +}) --DOC_HIDE + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/graph/scale1.lua b/tests/examples/wibox/widget/graph/scale1.lua new file mode 100644 index 00000000..5e34d985 --- /dev/null +++ b/tests/examples/wibox/widget/graph/scale1.lua @@ -0,0 +1,56 @@ +--DOC_GEN_IMAGE --DOC_HIDE +local parent = ... --DOC_HIDE +local wibox = require("wibox") --DOC_HIDE + +local data = { --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE +} --DOC_HIDE + + +local w1 = --DOC_HIDE +wibox.widget { + scale = false, + widget = wibox.widget.graph, +} + +--DOC_NEWLINE + +local w2 = --DOC_HIDE +wibox.widget { + scale = true, + widget = wibox.widget.graph, +} + +for _, v in ipairs(data) do --DOC_HIDE + w1:add_value(v) --DOC_HIDE + w2:add_value(v) --DOC_HIDE +end --DOC_HIDE + +parent:add(wibox.layout {--DOC_HIDE + {--DOC_HIDE + {--DOC_HIDE + markup = "scale = false",--DOC_HIDE + widget = wibox.widget.textbox,--DOC_HIDE + },--DOC_HIDE + w1,--DOC_HIDE + layout = wibox.layout.fixed.vertical,--DOC_HIDE + },--DOC_HIDE + {--DOC_HIDE + {--DOC_HIDE + markup = "scale = true",--DOC_HIDE + widget = wibox.widget.textbox,--DOC_HIDE + },--DOC_HIDE + w2,--DOC_HIDE + layout = wibox.layout.fixed.vertical,--DOC_HIDE + },--DOC_HIDE + + forced_width = 210, --DOC_HIDE + spacing = 5, --DOC_HIDE + layout = wibox.layout.flex.horizontal --DOC_HIDE +}) --DOC_HIDE + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/graph/stacked.lua b/tests/examples/wibox/widget/graph/stacked.lua new file mode 100644 index 00000000..62dd9fc8 --- /dev/null +++ b/tests/examples/wibox/widget/graph/stacked.lua @@ -0,0 +1,59 @@ +--DOC_GEN_IMAGE --DOC_HIDE +local parent = ... --DOC_HIDE +local wibox = require("wibox") --DOC_HIDE + +local data = { --DOC_HIDE + {3, 5, 6}, {4, 11,15}, {19,29,17},{17,14,0}, {0,3,1}, {0,0,22}, {17,7,1}, {0,0,5}, --DOC_HIDE + {3, 5, 6}, {4, 11,15}, {19,29,17},{17,14,0}, {0,3,1}, {0,0,22}, {17,7,1}, {0,0,5}, --DOC_HIDE + {3, 5, 6}, {4, 11,15}, {19,29,17},{17,14,0}, {0,3,1}, {0,0,22}, {17,7,1}, {0,0,5}, --DOC_HIDE + {3, 5, 6}, {4, 11,15}, {19,29,17},{17,14,0}, {0,3,1}, {0,0,22}, {17,7,1}, {0,0,5}, --DOC_HIDE + {3, 5, 6}, {4, 11,15}, {19,29,17},{17,14,0}, {0,3,1}, {0,0,22}, {17,7,1}, {0,0,5}, --DOC_HIDE + {3, 5, 6}, {4, 11,15}, {19,29,17},{17,14,0}, {0,3,1}, {0,0,22}, {17,7,1}, {0,0,5}, --DOC_HIDE + {3, 5, 6}, {4, 11,15}, {19,29,17},{17,14,0}, {0,3,1}, {0,0,22}, {17,7,1}, {0,0,5}, --DOC_HIDE + {3, 5, 6}, {4, 11,15}, {19,29,17},{17,14,0}, {0,3,1}, {0,0,22}, {17,7,1}, {0,0,5}, --DOC_HIDE + {3, 5, 6}, {4, 11,15}, {19,29,17},{17,14,0}, {0,3,1}, {0,0,22}, {17,7,1}, {0,0,5}, --DOC_HIDE + {3, 5, 6}, {4, 11,15}, {19,29,17},{17,14,0}, {0,3,1}, {0,0,22}, {17,7,1}, {0,0,5}, --DOC_HIDE + {3, 5, 6}, {4, 11,15}, {19,29,17},{17,14,0}, {0,3,1}, {0,0,22}, {17,7,1}, {0,0,5}, --DOC_HIDE + {3, 5, 6}, {4, 11,15}, {19,29,17},{17,14,0}, {0,3,1}, {0,0,22}, {17,7,1}, {0,0,5}, --DOC_HIDE + {3, 5, 6}, {4, 11,15}, {19,29,17},{17,14,0}, {0,3,1}, {0,0,22}, {17,7,1}, {0,0,5}, --DOC_HIDE + {3, 5, 6}, {4, 11,15}, {19,29,17},{17,14,0}, {0,3,1}, {0,0,22}, {17,7,1}, {0,0,5}, --DOC_HIDE + {3, 5, 6}, {4, 11,15}, {19,29,17},{17,14,0}, {0,3,1}, {0,0,22}, {17,7,1}, {0,0,5}, --DOC_HIDE +} --DOC_HIDE + +local l = wibox.layout { --DOC_HIDE + forced_height = 100, --DOC_HIDE + forced_width = 100, --DOC_HIDE + spacing = 5, --DOC_HIDE + layout = wibox.layout.flex.vertical --DOC_HIDE +} --DOC_HIDE + +local colors = { + "#ff0000", + "#00ff00", + "#0000ff" +} + +--DOC_NEWLINE + +local w = --DOC_HIDE + +wibox.widget { + max_value = 29, + stack = true, + border_width = 2, --DOC_HIDE + stack_colors = colors, + margins = 5, --DOC_HIDE + widget = wibox.widget.graph, +} + +l:add(w) --DOC_HIDE + +for _, v in ipairs(data) do --DOC_HIDE + for group, value in ipairs(v) do --DOC_HIDE + w:add_value(value, group) --DOC_HIDE + end --DOC_HIDE +end --DOC_HIDE + +parent:add(l) --DOC_HIDE + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/graph/step.lua b/tests/examples/wibox/widget/graph/step.lua index 823ff57a..9bf70ee4 100644 --- a/tests/examples/wibox/widget/graph/step.lua +++ b/tests/examples/wibox/widget/graph/step.lua @@ -11,21 +11,36 @@ local data = { --DOC_HIDE 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE } --DOC_HIDE -local w = --DOC_HIDE -wibox.widget { - max_value = 29, - step_width = 3, - step_spacing = 1, - step_shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 2) - end, - widget = wibox.widget.graph -} -parent:add( w ) --DOC_HIDE +local l = wibox.layout { --DOC_HIDE + forced_height = 100, --DOC_HIDE + forced_width = 100, --DOC_HIDE + spacing = 5, --DOC_HIDE + layout = wibox.layout.flex.vertical --DOC_HIDE +} --DOC_HIDE + +for _, width in ipairs {1, 2, 3, 10} do + local w = --DOC_HIDE + + wibox.widget { + max_value = 29, --DOC_HIDE + step_width = width, + step_spacing = 1, + step_shape = function(cr, s_width, height) + gears.shape.rounded_rect(cr, s_width, height, 2) + end, + widget = wibox.widget.graph, + } + + l:add(w) --DOC_HIDE + + for _, v in ipairs(data) do --DOC_HIDE + w:add_value(v) --DOC_HIDE + end --DOC_HIDE + + end + +parent:add(l) --DOC_HIDE -for _, v in ipairs(data) do --DOC_HIDE - w:add_value(v) --DOC_HIDE -end --DOC_HIDE --DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/graph/step_shape.lua b/tests/examples/wibox/widget/graph/step_shape.lua new file mode 100644 index 00000000..797926c4 --- /dev/null +++ b/tests/examples/wibox/widget/graph/step_shape.lua @@ -0,0 +1,55 @@ +--DOC_GEN_IMAGE --DOC_HIDE +local parent = ... --DOC_HIDE +local wibox = require("wibox") --DOC_HIDE +local gears = {shape = require("gears.shape")} --DOC_HIDE + +local data = { --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE +} --DOC_HIDE + + +local l = wibox.layout { --DOC_HIDE + forced_height = 200, --DOC_HIDE + forced_width = 200, --DOC_HIDE + spacing = 5, --DOC_HIDE + layout = wibox.layout.flex.vertical --DOC_HIDE +} --DOC_HIDE + +--DOC_NEWLINE + +local shapes = { + gears.shape.squircle, + gears.shape.octogon, + gears.shape.rounded_bar, + gears.shape.arrow +} + +--DOC_NEWLINE + +for _, shape in ipairs(shapes) do + local w = --DOC_HIDE + + wibox.widget { + max_value = 29, --DOC_HIDE + step_width = 5, + step_spacing = 1, + step_shape = shape, + widget = wibox.widget.graph, + } + + l:add(w) --DOC_HIDE + + for _, v in ipairs(data) do --DOC_HIDE + w:add_value(v) --DOC_HIDE + end --DOC_HIDE + + end + +parent:add(l) --DOC_HIDE + + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/graph/step_spacing.lua b/tests/examples/wibox/widget/graph/step_spacing.lua new file mode 100644 index 00000000..cc9a59fe --- /dev/null +++ b/tests/examples/wibox/widget/graph/step_spacing.lua @@ -0,0 +1,42 @@ +--DOC_GEN_IMAGE --DOC_HIDE +local parent = ... --DOC_HIDE +local wibox = require("wibox") --DOC_HIDE + +local data = { --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE + 3, 5, 6,4, 11,15,19,29,17,17,14,0,0,3,1,0,0, 22, 17,7, 1,0,0,5, --DOC_HIDE +} --DOC_HIDE + + +local l = wibox.layout { --DOC_HIDE + forced_height = 100, --DOC_HIDE + forced_width = 100, --DOC_HIDE + spacing = 5, --DOC_HIDE + layout = wibox.layout.flex.vertical --DOC_HIDE +} --DOC_HIDE + +for _, spacing in ipairs {0, 2, 4, 10} do + local w = --DOC_HIDE + + wibox.widget { + border_width = 2, --DOC_HIDE + margins = 5, --DOC_HIDE + max_value = 29, + step_spacing = spacing, + widget = wibox.widget.graph, + } + + l:add(w) --DOC_HIDE + + for _, v in ipairs(data) do --DOC_HIDE + w:add_value(v) --DOC_HIDE + end --DOC_HIDE + + end + +parent:add(l) --DOC_HIDE + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 From a5c4377901b6bcdf1e64c7fb4316b489b0e003dd Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 28 Mar 2021 02:38:43 -0700 Subject: [PATCH 2/3] Revert "I want to see the error message!!!" This reverts commit 1792780cf339030db2fed81dc6b75e8f6d81c2a8. --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4397c7c5..6c4a971e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -249,9 +249,6 @@ script: travis_run_in_fold "build_in_dir" cmake $CMAKE_ARGS "$SOURCE_DIRECTORY" fi - travis_run_in_fold "make" make ; sleep 5 - - make ; sleep 5 - - make ; sleep 5 - - make ; sleep 5 - | if [ "$TRAVIS_TEST_RESULT" = 0 ]; then travis_run_in_fold "make.install" sudo env PATH=$PATH make install From 743b327348ceb91df648a3b4f2473bf0c47d6193 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 28 Mar 2021 02:38:51 -0700 Subject: [PATCH 3/3] Revert "Another ugly hack to get Travis to show output" This reverts commit 97a60818c480dc5070eda9f8ca2ff3947c42add6. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6c4a971e..e91d1f31 100644 --- a/.travis.yml +++ b/.travis.yml @@ -248,7 +248,7 @@ script: cd "$BUILD_IN_DIR" travis_run_in_fold "build_in_dir" cmake $CMAKE_ARGS "$SOURCE_DIRECTORY" fi - - travis_run_in_fold "make" make ; sleep 5 + - travis_run_in_fold "make" make - | if [ "$TRAVIS_TEST_RESULT" = 0 ]; then travis_run_in_fold "make.install" sudo env PATH=$PATH make install