示例#1
0
 def _paint_palette_layout(self, cr):
     if self._palette is None:
         return
     state = self.get_state_flags()
     style = self.get_style_context()
     bg_rgba = style.get_background_color(state)
     bg_col = RGBColor.new_from_gdk_rgba(bg_rgba)
     dx, dy = self.get_painting_offset()
     self._palette.render(cr, rows=self._rows, columns=self._columns,
                          swatch_size=self._swatch_size,
                          bg_color=bg_col,
                          offset_x=dx, offset_y=dy,
                          rtl=False)
示例#2
0
 def _paint_palette_layout(self, cr):
     mgr = self.get_color_manager()
     if mgr.palette is None:
         return
     state = self.get_state_flags()
     style = self.get_style_context()
     bg_rgba = style.get_background_color(state)
     bg_col = RGBColor.new_from_gdk_rgba(bg_rgba)
     dx, dy = self.get_painting_offset()
     _palette_render(mgr.palette, cr,
                     rows=self._rows, columns=self._columns,
                     swatch_size=self._swatch_size,
                     bg_color=bg_col,
                     offset_x=dx, offset_y=dy,
                     rtl=False)
示例#3
0
    def _draw_cb(self, widget, cr):
        if self._palette is None:
            return
        alloc = widget.get_allocation()
        w, h = alloc.width, alloc.height
        s_max = 16  # min(w, h)
        s_min = 4
        ncolumns = self._palette.get_columns()
        ncolors = len(self._palette)
        if ncolors == 0:
            return
        if not ncolumns == 0:
            s = w / ncolumns
            s = clamp(s, s_min, s_max)
            s = int(s)
            if s * ncolumns > w:
                ncolumns = 0
        if ncolumns == 0:
            s = math.sqrt(float(w * h) / ncolors)
            s = clamp(s, s_min, s_max)
            s = int(s)
            ncolumns = max(1, int(w / s))
        nrows = int(ncolors // ncolumns)
        if ncolors % ncolumns != 0:
            nrows += 1
        nrows = max(1, nrows)
        dx, dy = 0, 0
        if nrows * s < h:
            dy = int(h - nrows * s) / 2
        if ncolumns * s < w:
            dx = int(w - ncolumns * s) / 2

        state = self.get_state_flags()
        style = self.get_style_context()
        bg_rgba = style.get_background_color(state)
        bg_color = RGBColor.new_from_gdk_rgba(bg_rgba)

        _palette_render(self._palette,
                        cr,
                        rows=nrows,
                        columns=ncolumns,
                        swatch_size=s,
                        bg_color=bg_color,
                        offset_x=dx,
                        offset_y=dy,
                        rtl=False)
示例#4
0
    def _draw_cb(self, widget, cr):
        if self._palette is None:
            return
        alloc = widget.get_allocation()
        w, h = alloc.width, alloc.height
        s_max = 16  # min(w, h)
        s_min = 4
        ncolumns = self._palette.get_columns()
        ncolors = len(self._palette)
        if ncolors == 0:
            return
        if not ncolumns == 0:
            s = w / ncolumns
            s = clamp(s, s_min, s_max)
            s = int(s)
            if s*ncolumns > w:
                ncolumns = 0
        if ncolumns == 0:
            s = math.sqrt(float(w*h) / ncolors)
            s = clamp(s, s_min, s_max)
            s = int(s)
            ncolumns = max(1, int(w / s))
        nrows = int(ncolors // ncolumns)
        if ncolors % ncolumns != 0:
            nrows += 1
        nrows = max(1, nrows)
        dx, dy = 0, 0
        if nrows*s < h:
            dy = int(h - nrows*s) / 2
        if ncolumns*s < w:
            dx = int(w - ncolumns*s) / 2

        state = self.get_state_flags()
        style = self.get_style_context()
        bg_rgba = style.get_background_color(state)
        bg_color = RGBColor.new_from_gdk_rgba(bg_rgba)

        _palette_render(self._palette, cr, rows=nrows, columns=ncolumns,
                        swatch_size=s, bg_color=bg_color,
                        offset_x=dx, offset_y=dy,
                        rtl=False)