Quantcast

Introduce bar widgets

Scott Sibley [08-23-10 - 07:47]
Introduce bar widgets
Filename
Modules/LCDDisplay.lua
config.lua
diff --git a/Modules/LCDDisplay.lua b/Modules/LCDDisplay.lua
index b6de5c9..46f13f7 100644
--- a/Modules/LCDDisplay.lua
+++ b/Modules/LCDDisplay.lua
@@ -7,6 +7,7 @@ local LibCore = LibStub("StarLibCore-1.0")
 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 LayoutOptions = LibStub("StarLibLayoutOptions-1.0")

 local _G = _G
diff --git a/config.lua b/config.lua
index 993b9f6..2b053be 100644
--- a/config.lua
+++ b/config.lua
@@ -43,19 +43,19 @@ StarTip.config = {
 		},
 		[5] = {
 			[1] = "widget_mem_label",
-			[10] = "widget_mem"
+			[10] = "widget_mem",
+			[20] = "widget_mem_bar"
 		},
 		[6] = {
 			[1] = "widget_cpu_label",
-			[10] = "widget_cpu"
+			[10] = "widget_cpu",
+			[20] = "widget_cpu_bar"
 		},
 		["transition"] = "U"
     },
 	["widget_name_label"] = {
 		type = "text",
 		value = 'return "Name:"',
-		prefix = '',
-		postfix = '',
 		precision = 0xbabe,
 		align = ALIGN_RIGHT,
 		cols = 9,
@@ -113,17 +113,28 @@ StarTip.config = {
 	["widget_mem"] = {
 		type = "text",
 		value = [[
-mem, percent, memdiff, totalMem, totaldiff = GetMemUsage("StarTip")
+mem = GetMemUsage("StarTip")
 if mem then
-    if totaldiff == 0 then totaldiff = 1 end
-    memperc = memdiff / totaldiff * 100
-    return memshort(tonumber(format("%.2f", mem))) .. " (" .. format("%.2f", memperc) .. "%)"
+    return memshort(tonumber(format("%.2f", mem)))
 end
 ]],
-		cols = 20,
+		cols = 10,
 		update = 1000,
 		dontRtrim = true
 	},
+	["widget_mem_bar"] = {
+		type = "bar",
+		expression = [[
+mem, percent, memdiff, totalMem, totaldiff = GetMemUsage("StarTip")
+if mem then
+    if totaldiff == 0 then totaldiff = 1 end
+    return memdiff / totaldiff * 100
+end
+]],
+		min = "return 0",
+		max = "return 100",
+		length = 10
+	},
 	["widget_cpu_label"] = {
 		type = "text",
 		value = "return 'CPU:'",
@@ -133,17 +144,28 @@ end
 	["widget_cpu"] = {
 		type = "text",
 		value = [[
-cpu, percent, cpudiff, totalCPU, totaldiff = GetCPUUsage("StarTip")
+cpu = GetCPUUsage("StarTip")
 if cpu then
-    if totaldiff == 0 then totaldiff = 1 end
-    cpuperc = cpudiff / totaldiff * 100
-    return timeshort(cpu) .. " (" .. format("%.2f", cpuperc)  .. "%)"
+    return timeshort(cpu)
 end
 ]],
-		cols = 20,
+		cols = 10,
 		update = 1000,
 		dontRtrim = true
 	},
+	["widget_cpu_bar"] = {
+		type = "bar",
+		expression = [[
+cpu, percent, cpudiff, totalCPU, totaldiff = GetCPUUsage("StarTip")
+if cpu then
+    if totaldiff == 0 then totaldiff = 1 end
+    return cpudiff / totaldiff * 100
+end
+]],
+		min = "return 0",
+		max = "return 100",
+		length = 10
+	},
 	["widget_icon_blob"] = {
 		["bitmap"] = {
     		["row1"] = ".....|.....|.....",