~umang/indicator-stickynotes/trunk

« back to all changes in this revision

Viewing changes to stickynotes/gui.py

  • Committer: Umang Varma
  • Date: 2015-07-02 16:46:08 UTC
  • Revision ID: git-v1:28723cec46b36f663b8e7bcc84d618bd430c77e2
Tweaked "dark"/"light" color thresholds

Show diffs side-by-side

added added

removed removed

Lines of Context:
186
186
 
187
187
    def update_button_color(self):
188
188
        """Switches between regular and dark icons appropriately"""
189
 
        lightness = sum(colorsys.hsv_to_rgb(*self.note.cat_prop("bgcolor_hsv")))
190
 
        suffix = "-dark" if lightness <= 1 else ""
 
189
        h,s,v = self.note.cat_prop("bgcolor_hsv")
 
190
        # an arbitrary quadratic found by trial and error
 
191
        thresh_sat = 1.05 - 1.7*((v-1)**2)
 
192
        suffix = "-dark" if s >= thresh_sat else ""
191
193
        iconfiles = {"imgAdd":"add", "imgClose":"close", "imgDropdown":"menu",
192
194
                "imgLock":"lock", "imgUnlock":"unlock", "imgResizeR":"resizer"}
193
195
        for img, filename in iconfiles.items():