コード例 #1
0
 def _GetHilightGlowColor(self):
     if self._colorHiliteGlow:
         return self._colorHiliteGlow
     color = Color(*self._GetHilightColor()).SetBrightness(1.0)
     if color.GetSaturation() > 0.2:
         color.SetSaturation(0.2)
     self._colorHiliteGlow = color.GetRGBA()
     return self._colorHiliteGlow
コード例 #2
0
 def _GetBaseContrastColor(self):
     if self._colorBaseContrast:
         return self._colorBaseContrast
     color = self.GetUIColor(colorType=uiconst.COLORTYPE_UIBASE)
     color = Color(*color)
     b = color.GetBrightness()
     if b < 0.12:
         b += 0.1
         s = color.GetSaturation()
         color.SetSaturation(s * 0.75)
     else:
         b *= 0.8
     self._colorBaseContrast = color.SetBrightness(b).GetRGBA()
     return self._colorBaseContrast
コード例 #3
0
class ColorPicker(ContainerAutoSize):
    default_name = 'ColorPicker'
    default_alignMode = uiconst.TOTOP

    def ApplyAttributes(self, attributes):
        ContainerAutoSize.ApplyAttributes(self, attributes)
        label = attributes.label
        maxValue = attributes.Get('maxValue', 1.0)
        self.colorCallback = attributes.colorCallback
        self.color = Color(*attributes.color)
        self.initialized = False
        Label(parent=self, align=uiconst.TOTOP, text=label, fontsize=20, left=14)
        Button(parent=self, left=4, top=4, align=uiconst.TOPRIGHT, label='Copy to Clipboard', func=self.CopyToClipboard)
        self.r = ValueSelector(parent=self, align=uiconst.TOTOP, height=18, value=self.color.r, maxValue=maxValue, label='R', callback=self.OnRChange)
        self.g = ValueSelector(parent=self, align=uiconst.TOTOP, height=18, value=self.color.g, maxValue=maxValue, label='G', callback=self.OnGChange, padTop=PADTOP)
        self.b = ValueSelector(parent=self, align=uiconst.TOTOP, height=18, value=self.color.b, maxValue=maxValue, label='B', callback=self.OnBChange, padTop=PADTOP)
        h, s, b = self.color.GetHSB()
        self.h = ValueSelector(parent=self, align=uiconst.TOTOP, height=18, value=h, maxValue=1.0, label='H', callback=self.OnHChange, padTop=PADTOP + 14)
        self.s = ValueSelector(parent=self, align=uiconst.TOTOP, height=18, value=s, maxValue=1.0, label='S', callback=self.OnSChange, padTop=PADTOP)
        self.br = ValueSelector(parent=self, align=uiconst.TOTOP, height=18, value=b, maxValue=maxValue, label='B', callback=self.OnBrChange, padTop=PADTOP)
        self.initialized = True

    def UpdateColor(self, color):
        self.color.SetRGB(*color)
        self.UpdateSliders()

    def UpdateSliders(self):
        self.r.SetValue(self.color.r)
        self.g.SetValue(self.color.g)
        self.b.SetValue(self.color.b)
        h, s, br = self.color.GetHSB()
        self.h.SetValue(h)
        self.s.SetValue(s)
        self.br.SetValue(br)

    def UpdateValues(self):
        if not self.initialized:
            return
        self.UpdateSliders()
        self.colorCallback(self.color.GetRGBA())

    def OnRChange(self, slider):
        self.color.SetRGB(slider.GetValue(), self.color.g, self.color.b)
        self.UpdateValues()

    def OnGChange(self, slider):
        self.color.SetRGB(self.color.r, slider.GetValue(), self.color.b)
        self.UpdateValues()

    def OnBChange(self, slider):
        self.color.SetRGB(self.color.r, self.color.g, slider.GetValue())
        self.UpdateValues()

    def OnHChange(self, slider):
        self.color.SetHue(slider.GetValue())
        self.UpdateValues()

    def OnSChange(self, slider):
        self.color.SetSaturation(slider.GetValue())
        self.UpdateValues()

    def OnBrChange(self, slider):
        self.color.SetBrightness(slider.GetValue())
        self.UpdateValues()

    def CopyToClipboard(self, *args):
        data = '(%s, %s, %s)' % self.color.GetRGBRounded()
        blue.win32.SetClipboardData(data)