Quantcast

Histogram widget

Scott Sibley [08-25-10 - 00:42]
Histogram widget
Filename
Modules/LCDDisplay.lua
config.lua
diff --git a/Modules/LCDDisplay.lua b/Modules/LCDDisplay.lua
index 46f13f7..7dbd105 100644
--- a/Modules/LCDDisplay.lua
+++ b/Modules/LCDDisplay.lua
@@ -8,6 +8,7 @@ local LibLCDText = LibStub("StarLibLCDText-1.0")
 local LibDriverQTip = LibStub("StarLibDriverQTip-1.0")
 local WidgetText = LibStub("StarLibWidgetText-1.0")
 local WidgetBar = LibStub("StarLibWidgetBar-1.0")
+local WidgetHistogram = LibStub("StarLibWidgetHistogram-1.0")
 local LayoutOptions = LibStub("StarLibLayoutOptions-1.0")

 local _G = _G
@@ -258,7 +259,7 @@ function mod:RebuildOpts()
 				options.widgets.args.bar.args[k:gsub(" ", "_")] = {
 					name = k,
 					type = "group",
-					args = {}, --WidgetBar:GetOptions(StarTip, v, k)},
+					args = WidgetBar:GetOptions(StarTip, v, k),
 					order = 1
 				}
 				options.widgets.args.bar.args[k:gsub(" ", "_")].args.delete = {
@@ -274,7 +275,7 @@ function mod:RebuildOpts()
 				options.widgets.args.histogram.args[k:gsub(" ", "_")] = {
 					name = k,
 					type = "group",
-					args = {}, --WidgetHistogram:GetOptions(StarTip, v, k)},
+					args = WidgetHistogram:GetOptions(StarTip, v, k),
 					order = 1
 				}
 				options.widgets.args.histogram.args[k:gsub(" ", "_")].args.delete = {
diff --git a/config.lua b/config.lua
index 27948b5..0ef9a3f 100644
--- a/config.lua
+++ b/config.lua
@@ -18,7 +18,7 @@ StarTip.config = {
 		["widgets"] = {"widget_key_up", "widget_key_down"},
 		["transition_speed"] = 50,
 		["refresh_rate"] = 25,
-		["layouts"] = {"layout_startip"}
+		["layouts"] = {"layout_histogram", "layout_startip"}
     },
 	["layout_blank"] = {
 		["keyless"] = 1,
@@ -53,6 +53,11 @@ StarTip.config = {
 		},
 		["transition"] = "U"
     },
+	["layout_histogram"] = {
+		[1] = {
+			[1] = "widget_mem_histogram"
+		}
+	},
 	["widget_name_label"] = {
 		type = "text",
 		value = 'return "Name:"',
@@ -135,6 +140,20 @@ end
 		max = "return 100",
 		length = 10
 	},
+	["widget_mem_histogram"] = {
+		type = "histogram",
+		expression = [[
+mem, percent, memdiff, totalMem, totaldiff = GetMemUsage("StarTip")
+if mem then
+    if totaldiff == 0 then return 0 end
+    return memdiff / totaldiff * 100
+end
+]],
+		min = "return 0",
+		max = "return 100",
+		width = 30,
+		height = 6
+	},
 	["widget_cpu_label"] = {
 		type = "text",
 		value = "return 'CPU:'",
@@ -166,6 +185,20 @@ end
 		max = "return 100",
 		length = 10
 	},
+	["widget_cpu_histogram"] = {
+		type = "histogram",
+		expression = [[
+cpu, percent, cpudiff, totalCPU, totaldiff = GetCPUUsage("StarTip")
+if cpu then
+    if totaldiff == 0 then return 0 end
+    return cpudiff / totaldiff * 100
+end
+]],
+		min = "return 0",
+		max = "return 100",
+		width = 30,
+		height = 6
+	},
 	["widget_icon_blob"] = {
 		["bitmap"] = {
     		["row1"] = ".....|.....|.....",