Skip to content

Commit

Permalink
Convert -face variables to be faces
Browse files Browse the repository at this point in the history
  • Loading branch information
swflint committed Jun 29, 2024
1 parent 30bbe6f commit 834e4ad
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions svg-battery-indicator.el
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,13 @@
:group 'svg-battery-indicator
:type 'integer)

(defcustom svg-battery-indicator-stroke-face 'mode-line
"Face used for battery image borders."
:group 'svg-battery-indicator
:type 'face)
(defface svg-battery-indicator-stroke-face '((t :inherit mode-line))
"Face used to draw battery indicator edges."
:group 'svg-battery-indicator)

(defcustom svg-battery-indicator-fill-face 'mode-line-inactive
(defface svg-battery-indicator-fill-face '((t :inherit mode-line-inactive))
"Face used to fill battery image based on percent."
:group 'svg-battery-indicator
:type 'face)
:group 'svg-battery-indicator)

(defun svg-battery-indicator--battery (base-height base-length lug-width stroke-width rounding-radius)
"Generate a basic battery outline.
Expand All @@ -58,15 +56,15 @@ will be drawn with STROKE-WIDTH wide strokes, and corners rounded
by ROUNDING-RADIUS."
(let ((svg (svg-create (+ lug-width base-length) base-height
:stroke-width stroke-width
:stroke-color (face-attribute svg-battery-indicator-stroke-face :foreground nil 'inherit))))
:stroke-color (face-attribute 'svg-battery-indicator-stroke-face :foreground nil 'inherit))))
;; Base rectangle
(svg-rectangle svg lug-width 0 base-length base-height
:fill "transparent"
:rx rounding-radius :ry rounding-radius)
;; End `nub'
(let ((height (round (* 0.5 base-height))))
(svg-rectangle svg 0 (/ (- base-height height) 2) lug-width height
:fill (face-attribute svg-battery-indicator-stroke-face :foreground nil 'inherit)
:fill (face-attribute 'svg-battery-indicator-stroke-face :foreground nil 'inherit)
:stroke-width 0
:rx 2 :ry 2))
svg))
Expand All @@ -86,7 +84,7 @@ If CHARGING is non-nil a lightning symbol is drawn over the SVG."

(if (stringp percentage)
(svg-text svg "?"
:fill (face-attribute svg-battery-indicator-stroke-face :foreground nil 'inherit)
:fill (face-attribute 'svg-battery-indicator-stroke-face :foreground nil 'inherit)
:font-weight "bold"
:font-size (- base-height stroke-width)
:stroke-width 0
Expand All @@ -99,7 +97,7 @@ If CHARGING is non-nil a lightning symbol is drawn over the SVG."
'battery-load-critical)
((<= percentage battery-load-low)
'battery-load-low)
(t svg-battery-indicator-fill-face))
(t 'svg-battery-indicator-fill-face))
:foreground nil 'inherit)))
;; Fill/percentage rectangle
(let* ((os (* 2 stroke-width)) ;TODO: Rename, what does `os' stand for?
Expand Down

0 comments on commit 834e4ad

Please sign in to comment.