Skip to content

Commit 4436d40

Browse files
committed
Bring over indicator styling improvements from #13
1 parent fd0ed5a commit 4436d40

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

stackline/window.lua

+23-8
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,19 @@ function Window:process(Icons) -- {{{
8989
local unfocused_color = {white = 0.9, alpha = 0.30}
9090
local focused_color = {white = 0.9, alpha = 0.99}
9191
local padding = 4
92+
local iconPadding = 4
9293
local aspectRatio = 5
93-
local size = 25
94+
local size = 32
9495

95-
local width = showIcons and size or (size / aspectRatio)
96+
local offsetY = 2
97+
local offsetX = 4
9698

99+
local width = showIcons and size or (size / aspectRatio)
97100
local currTabIdx = self.stackIdx
98-
local xval = self.frame.x - (width + padding)
99101

100102
self.canvas_frame = {
101-
x = xval,
102-
y = self.frame.y + 2,
103+
x = self.frame.x - (width + offsetX),
104+
y = self.frame.y + offsetY,
103105
w = self.frame.w,
104106
h = self.frame.h,
105107
}
@@ -111,6 +113,13 @@ function Window:process(Icons) -- {{{
111113
h = size,
112114
}
113115

116+
self.icon_rect = {
117+
x = iconPadding,
118+
y = self.indicator_rect.y + iconPadding,
119+
w = self.indicator_rect.w - (iconPadding * 2),
120+
h = self.indicator_rect.h - (iconPadding * 2),
121+
}
122+
114123
local focused = self:isFocused()
115124

116125
self.color_opts = {
@@ -135,23 +144,29 @@ function Window:draw_indicator() -- {{{
135144

136145
self.indicator = hs.canvas.new(self.canvas_frame)
137146

147+
local showIcons = wsi.getShowIconsState()
138148
local width = self.indicator_rect.w
149+
150+
-- TODO: configurable roundness radius for icons & pills
151+
local radius = showIcons and (self.indicator_rect.w / 4.0) or 3.0
152+
139153
self.indicator:appendElements{
140154
type = "rectangle",
141155
action = "fill",
142156
fillColor = self.color_opts.bg,
143157
frame = self.indicator_rect,
144-
roundedRectRadii = {xRadius = 2.0, yRadius = 2.0},
158+
roundedRectRadii = {xRadius = radius, yRadius = radius},
145159
}
146160

147-
if wsi.getShowIconsState() then
161+
if showIcons then
148162
self.indicator:appendElements{
149163
type = "image",
150164
image = self:iconFromAppName(),
151-
frame = self.indicator_rect,
165+
frame = self.icon_rect,
152166
imageAlpha = self.color_opts.imageAlpha,
153167
}
154168
end
169+
155170
self.indicator:show()
156171
end -- }}}
157172

0 commit comments

Comments
 (0)