Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve color handling #4

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion svg-battery-indicator.el
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
:group 'svg-battery-indicator
:type 'face)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do use a face here, I as a user would expect anything called *-face which controls colouring to be a face, not variable pointing at a symbol for a face. So if we do use a face (which again, I'm not sure we should), it should be something more like:

(defface svg-battery-indicator-stroke '((t :inherit mode-line))
  "Face used for battery image borders."
  :group 'svg-battery-indicator)


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

(defun svg-battery-indicator--battery (base-height base-length nub-width stroke-width rounding-radius)
"Generate a basic battery SVG."
(let ((svg (svg-create (+ nub-width base-length) base-height
Expand Down Expand Up @@ -89,7 +94,7 @@ CHARGING is non-nil a lightning symbol is drawn over the SVG."
'battery-load-critical)
((<= percentage battery-load-low)
'battery-load-low)
(t 'mode-line))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea, but I'm not sure we need to use face.

I used faces for the other colours because I wanted automatic consistency with the standard battery colours, and those are setup as faces. But here, there isn't anything obvious to inherit from. Or in other words: from the users point of view, this is isn't the sort that is usually customised by changing a face. Maybe we should just use a colour value string?

(t svg-battery-indicator-fill-face))
:foreground nil 'inherit)))
;; Fill/percentage rectangle
(let* ((os (* 2 sw))
Expand Down