Esempio n. 1
0
	def build(self):
		panel = wal.HPanel(self)
		self.grad_keeper = wal.HToggleKeeper(panel, GRADIENT_MODES,
								GRADIENT_MODE_ICONS,
								GRADIENT_MODE_NAMES, self.on_grad_mode_change)
		panel.pack(self.grad_keeper)
		panel.pack(wal.HPanel(panel), fill=True, expand=True)

		self.grad_clrs = wal.HToggleKeeper(panel, GRADIENT_CLR_MODES,
								GRADIENT_CLR_ICONS,
								GRADIENT_CLR_NAMES, self.on_clr_mode_change)
		panel.pack(self.grad_clrs)
		panel.pack(wal.HPanel(panel), fill=True, expand=True)

		self.rule_keeper = FillRuleKeeper(panel)
		panel.pack(self.rule_keeper)
		self.pack(panel, fill=True, padding_all=5)
		self.pack(wal.HLine(self), fill=True)

		self.grad_editor = GradientEditor(self, self.dlg, self.cms,
								DEFAULT_STOPS, onchange=self.on_stops_change)
		self.pack(self.grad_editor, fill=True, expand=True, padding=3)
		self.pack(wal.HLine(self), fill=True)

		panel = wal.HPanel(self)
		self.refpanel = FillFillRefPanel(self, self.cms, self.orig_fill,
						deepcopy(self.orig_fill), on_orig=self.set_orig_fill)
		panel.pack(self.refpanel)

		panel.pack(wal.HPanel(panel), fill=True, expand=True)

		self.presets = GradientMiniPalette(panel, self.cms,
										onclick=self.on_presets_select)
		panel.pack(self.presets)
		self.pack(panel, fill=True, padding_all=5)
Esempio n. 2
0
	def build(self):
		panel = wal.HPanel(self)
		self.grad_keeper = wal.HToggleKeeper(panel, GRADIENT_MODES,
								GRADIENT_MODE_ICONS,
								GRADIENT_MODE_NAMES, self.on_grad_mode_change)
		panel.pack(self.grad_keeper)
		panel.pack(wal.HPanel(panel), fill=True, expand=True)

		self.grad_clrs = wal.HToggleKeeper(panel, GRADIENT_CLR_MODES,
								GRADIENT_CLR_ICONS,
								GRADIENT_CLR_NAMES, self.on_clr_mode_change)
		panel.pack(self.grad_clrs)
		panel.pack(wal.HPanel(panel), fill=True, expand=True)

		self.rule_keeper = FillRuleKeeper(panel)
		panel.pack(self.rule_keeper)
		self.pack(panel, fill=True, padding_all=5)
		self.pack(wal.HLine(self), fill=True)

		self.grad_editor = GradientEditor(self, self.dlg, self.cms,
								DEFAULT_STOPS, onchange=self.on_stops_change)
		self.pack(self.grad_editor, fill=True, expand=True, padding=3)
		self.pack(wal.HLine(self), fill=True)

		panel = wal.HPanel(self)
		self.refpanel = FillFillRefPanel(self, self.cms, self.orig_fill,
						deepcopy(self.orig_fill), on_orig=self.set_orig_fill)
		panel.pack(self.refpanel)

		panel.pack(wal.HPanel(panel), fill=True, expand=True)

		self.presets = GradientMiniPalette(panel, self.cms,
										onclick=self.on_presets_select)
		panel.pack(self.presets)
		self.pack(panel, fill=True, padding_all=5)
Esempio n. 3
0
class GradientFill(FillTab):
    name = _('Gradient Fill')
    vector = []
    new_fill = None
    grad_keeper = None
    grad_clrs = None
    rule_keeper = None
    grad_editor = None
    refpanel = None
    presets = None

    def activate(self, fill_style, new_color=None):
        FillTab.activate(self, fill_style)
        mode = sk2const.GRADIENT_LINEAR
        rule = sk2const.FILL_EVENODD
        self.vector = []
        stops = deepcopy(DEFAULT_STOPS)
        if fill_style:
            rule = fill_style[0]
            if fill_style[1] == sk2const.FILL_GRADIENT:
                mode = fill_style[2][0]
                self.vector = deepcopy(fill_style[2][1])
                stops = deepcopy(fill_style[2][2])
            elif fill_style[1] == sk2const.FILL_SOLID:
                if fill_style[2][0] in GRADIENT_CLR_MODES:
                    color0 = deepcopy(fill_style[2])
                    color0[3] = ''
                    if new_color and new_color[0] in GRADIENT_CLR_MODES \
                            and not color0 == new_color:
                        color1 = deepcopy(new_color)
                        if not color0[0] == color1[0]:
                            color1 = self.cms.get_color(color1, color0[0])
                    else:
                        color1 = deepcopy(fill_style[2])
                        color1[2] = 0.0
                        color1[3] = ''
                    stops = [[0.0, color0], [1.0, color1]]
        self.new_fill = [
            rule, sk2const.FILL_GRADIENT, [mode, self.vector, stops]
        ]
        self.update()

    def build(self):
        panel = wal.HPanel(self)
        self.grad_keeper = wal.HToggleKeeper(panel, GRADIENT_MODES,
                                             GRADIENT_MODE_ICONS,
                                             GRADIENT_MODE_NAMES,
                                             self.on_grad_mode_change)
        panel.pack(self.grad_keeper)
        panel.pack(wal.HPanel(panel), fill=True, expand=True)

        self.grad_clrs = wal.HToggleKeeper(panel, GRADIENT_CLR_MODES,
                                           GRADIENT_CLR_ICONS,
                                           GRADIENT_CLR_NAMES,
                                           self.on_clr_mode_change)
        panel.pack(self.grad_clrs)
        panel.pack(wal.HPanel(panel), fill=True, expand=True)

        self.rule_keeper = FillRuleKeeper(panel)
        panel.pack(self.rule_keeper)
        self.pack(panel, fill=True, padding_all=5)
        self.pack(wal.HLine(self), fill=True)

        self.grad_editor = GradientEditor(self,
                                          self.dlg,
                                          self.cms,
                                          DEFAULT_STOPS,
                                          onchange=self.on_stops_change)
        self.pack(self.grad_editor, fill=True, expand=True, padding=3)
        self.pack(wal.HLine(self), fill=True)

        panel = wal.HPanel(self)
        self.refpanel = FillFillRefPanel(self,
                                         self.cms,
                                         self.orig_fill,
                                         deepcopy(self.orig_fill),
                                         on_orig=self.set_orig_fill)
        panel.pack(self.refpanel)

        panel.pack(wal.HPanel(panel), fill=True, expand=True)

        self.presets = GradientMiniPalette(panel,
                                           self.cms,
                                           onclick=self.on_presets_select)
        panel.pack(self.presets)
        self.pack(panel, fill=True, padding_all=5)

    def set_orig_fill(self):
        self.activate(self.orig_fill)

    def on_clr_mode_change(self, mode):
        conv = self.cms.get_cmyk_color
        if mode == uc2const.COLOR_RGB:
            conv = self.cms.get_rgb_color
        elif mode == uc2const.COLOR_GRAY:
            conv = self.cms.get_grayscale_color
        new_stops = []
        for stop in self.new_fill[2][2]:
            new_stops.append([stop[0], conv(stop[1])])
        self.new_fill[2][2] = new_stops
        self.update()

    def on_grad_mode_change(self, mode):
        self.new_fill[2][0] = mode
        self.update()

    def on_stops_change(self):
        self.new_fill[2][2] = self.grad_editor.get_stops()
        self.update()

    def on_presets_select(self, stops):
        self.new_fill[2][2] = stops
        self.update()

    def get_result(self):
        stops = self.grad_editor.get_stops()
        vector = self.vector
        if not self.grad_editor.use_vector():
            vector = []
        grad = [self.grad_keeper.get_mode(), vector, stops]
        return [self.rule_keeper.get_mode(), sk2const.FILL_GRADIENT, grad]

    def update(self):
        self.grad_keeper.set_mode(self.new_fill[2][0])
        self.grad_clrs.set_mode(self.new_fill[2][2][0][1][0])
        self.rule_keeper.set_mode(self.new_fill[0])
        self.grad_editor.set_stops(self.new_fill[2][2])
        self.refpanel.update(self.orig_fill, self.new_fill)
        self.presets.set_stops(self.new_fill[2][2])
Esempio n. 4
0
class GradientFill(FillTab):

	name = _('Gradient Fill')
	vector = []
	new_fill = None

	def activate(self, fill_style, new_color=None):
		FillTab.activate(self, fill_style)
		mode = sk2_const.GRADIENT_LINEAR
		rule = sk2_const.FILL_EVENODD
		self.vector = []
		stops = deepcopy(DEFAULT_STOPS)
		if fill_style:
			rule = fill_style[0]
			if fill_style[1] == sk2_const.FILL_GRADIENT:
				mode = fill_style[2][0]
				self.vector = deepcopy(fill_style[2][1])
				stops = deepcopy(fill_style[2][2])
			elif fill_style[1] == sk2_const.FILL_SOLID:
				if fill_style[2][0] in GRADIENT_CLR_MODES:
					color0 = deepcopy(fill_style[2])
					color0[3] = ''
					if new_color and new_color[0] in GRADIENT_CLR_MODES \
											and not color0 == new_color:
						color1 = deepcopy(new_color)
						if not color0[0] == color1[0]:
							color1 = self.cms.get_color(color1, color0[0])
					else:
						color1 = deepcopy(fill_style[2])
						color1[2] = 0.0
						color1[3] = ''
					stops = [[0.0, color0], [1.0, color1]]
		self.new_fill = [rule, sk2_const.FILL_GRADIENT,
						[mode, self.vector, stops]]
		self.update()

	def build(self):
		panel = wal.HPanel(self)
		self.grad_keeper = wal.HToggleKeeper(panel, GRADIENT_MODES,
								GRADIENT_MODE_ICONS,
								GRADIENT_MODE_NAMES, self.on_grad_mode_change)
		panel.pack(self.grad_keeper)
		panel.pack(wal.HPanel(panel), fill=True, expand=True)

		self.grad_clrs = wal.HToggleKeeper(panel, GRADIENT_CLR_MODES,
								GRADIENT_CLR_ICONS,
								GRADIENT_CLR_NAMES, self.on_clr_mode_change)
		panel.pack(self.grad_clrs)
		panel.pack(wal.HPanel(panel), fill=True, expand=True)

		self.rule_keeper = FillRuleKeeper(panel)
		panel.pack(self.rule_keeper)
		self.pack(panel, fill=True, padding_all=5)
		self.pack(wal.HLine(self), fill=True)

		self.grad_editor = GradientEditor(self, self.dlg, self.cms,
								DEFAULT_STOPS, onchange=self.on_stops_change)
		self.pack(self.grad_editor, fill=True, expand=True, padding=3)
		self.pack(wal.HLine(self), fill=True)

		panel = wal.HPanel(self)
		self.refpanel = FillFillRefPanel(self, self.cms, self.orig_fill,
						deepcopy(self.orig_fill), on_orig=self.set_orig_fill)
		panel.pack(self.refpanel)

		panel.pack(wal.HPanel(panel), fill=True, expand=True)

		self.presets = GradientMiniPalette(panel, self.cms,
										onclick=self.on_presets_select)
		panel.pack(self.presets)
		self.pack(panel, fill=True, padding_all=5)

	def set_orig_fill(self):
		self.activate(self.orig_fill)

	def on_clr_mode_change(self, mode):
		conv = self.cms.get_cmyk_color
		if mode == uc2const.COLOR_RGB:
			conv = self.cms.get_rgb_color
		elif mode == uc2const.COLOR_GRAY:
			conv = self.cms.get_grayscale_color
		new_stops = []
		for stop in self.new_fill[2][2]:
			new_stops.append([stop[0], conv(stop[1])])
		self.new_fill[2][2] = new_stops
		self.update()

	def on_grad_mode_change(self, mode):
		self.new_fill[2][0] = mode
		self.update()

	def on_stops_change(self):
		self.new_fill[2][2] = self.grad_editor.get_stops()
		self.update()

	def on_presets_select(self, stops):
		self.new_fill[2][2] = stops
		self.update()

	def get_result(self):
		stops = self.grad_editor.get_stops()
		vector = self.vector
		if not self.grad_editor.use_vector():vector = []
		grad = [self.grad_keeper.get_mode(), vector, stops]
		return [self.rule_keeper.get_mode(), sk2_const.FILL_GRADIENT, grad]

	def update(self):
		self.grad_keeper.set_mode(self.new_fill[2][0])
		self.grad_clrs.set_mode(self.new_fill[2][2][0][1][0])
		self.rule_keeper.set_mode(self.new_fill[0])
		self.grad_editor.set_stops(self.new_fill[2][2])
		self.refpanel.update(self.orig_fill, self.new_fill)
		self.presets.set_stops(self.new_fill[2][2])