Example #1
0
	def build(self):
		panel = wal.HPanel(self)
		self.pattern_clrs = wal.HToggleKeeper(panel, GRADIENT_CLR_MODES,
								GRADIENT_CLR_ICONS,
								GRADIENT_CLR_NAMES, self.on_clr_mode_change)
		panel.pack(self.pattern_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)

		default_pattern_def = [sk2_const.PATTERN_IMG, '' + DEFAULT_PATTERN,
					deepcopy([sk2_const.CMYK_BLACK, sk2_const.CMYK_WHITE]),
					[] + sk2_const.NORMAL_TRAFO]
		self.pattern_editor = PatternEditor(self, self.dlg, self.cms,
						default_pattern_def, onchange=self.on_pattern_change)
		self.pack(self.pattern_editor, fill=True, expand=True, padding_all=5)


		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 = PatternMiniPalette(panel, self.cms,
										onclick=self.on_presets_select)
		panel.pack(self.presets)
		self.pack(panel, fill=True, padding_all=5)
Example #2
0
	def build(self):
		panel = wal.HPanel(self)
		self.pattern_clrs = wal.HToggleKeeper(panel, GRADIENT_CLR_MODES,
								GRADIENT_CLR_ICONS,
								GRADIENT_CLR_NAMES, self.on_clr_mode_change)
		panel.pack(self.pattern_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)

		default_pattern_def = [sk2_const.PATTERN_IMG, '' + DEFAULT_PATTERN,
					deepcopy([sk2_const.CMYK_BLACK, sk2_const.CMYK_WHITE]),
					[] + sk2_const.NORMAL_TRAFO]
		self.pattern_editor = PatternEditor(self, self.dlg, self.cms,
						default_pattern_def, onchange=self.on_pattern_change)
		self.pack(self.pattern_editor, fill=True, expand=True, padding_all=5)


		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 = PatternMiniPalette(panel, self.cms,
										onclick=self.on_presets_select)
		panel.pack(self.presets)
		self.pack(panel, fill=True, padding_all=5)
Example #3
0
class PatternFill(FillTab):
    name = _('Pattern Fill')
    new_fill = None
    pattern_clrs = None
    rule_keeper = None
    refpanel = None
    presets = None
    pattern_editor = None

    def activate(self, fill_style, new_color=None):
        FillTab.activate(self, fill_style)
        rule = sk2const.FILL_EVENODD
        pattern_type = sk2const.PATTERN_IMG
        pattern = DEFAULT_PATTERN
        image_style = deepcopy([sk2const.CMYK_BLACK, sk2const.CMYK_WHITE])
        trafo = [] + sk2const.NORMAL_TRAFO
        transforms = [] + sk2const.PATTERN_TRANSFORMS

        if fill_style:
            rule = fill_style[0]
            if fill_style[1] == sk2const.FILL_PATTERN:
                pattern_type = fill_style[2][0]
                pattern = deepcopy(fill_style[2][1])
                if len(fill_style[2]) > 2:
                    image_style = deepcopy(fill_style[2][2])
                if len(fill_style[2]) > 3:
                    trafo = [] + fill_style[2][3]
                if len(fill_style[2]) > 4:
                    transforms = [] + fill_style[2][4]
                else:
                    transforms = []
            elif fill_style[1] == sk2const.FILL_SOLID:
                if fill_style[2][0] in GRADIENT_CLR_MODES:
                    color0 = deepcopy(fill_style[2])
                    color0[3] = ''
                    color1 = deepcopy(sk2const.CMYK_WHITE)
                    if not color0[0] == color1[0]:
                        color1 = self.cms.get_color(color1, color0[0])
                    color1[3] = ''
                    image_style = [color0, color1]

        color0 = image_style[0]
        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])
            color1[3] = ''
            image_style[1] = color1

        self.new_fill = [
            rule, sk2const.FILL_PATTERN,
            [pattern_type, pattern, image_style, trafo, transforms]
        ]
        self.update()

    def build(self):
        panel = wal.HPanel(self)
        self.pattern_clrs = wal.HToggleKeeper(panel, GRADIENT_CLR_MODES,
                                              GRADIENT_CLR_ICONS,
                                              GRADIENT_CLR_NAMES,
                                              self.on_clr_mode_change)
        panel.pack(self.pattern_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)

        default_pattern_def = [
            sk2const.PATTERN_IMG, DEFAULT_PATTERN,
            deepcopy([sk2const.CMYK_BLACK, sk2const.CMYK_WHITE]),
            [] + sk2const.NORMAL_TRAFO
        ]
        self.pattern_editor = PatternEditor(self,
                                            self.dlg,
                                            self.cms,
                                            default_pattern_def,
                                            onchange=self.on_pattern_change)
        self.pack(self.pattern_editor, fill=True, expand=True, padding_all=5)

        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 = PatternMiniPalette(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):
        image_style = deepcopy(self.new_fill[2][2])
        image_style[0] = self.cms.get_color(image_style[0], mode)
        image_style[1] = self.cms.get_color(image_style[1], mode)
        self.new_fill[2][2] = image_style
        self.update()

    def on_presets_select(self, pattern):
        self.new_fill[2][1] = pattern
        self.new_fill[2][0] = sk2const.PATTERN_IMG
        self.update()

    def on_pattern_change(self, pattern_def):
        self.new_fill[2] = deepcopy(pattern_def)
        self.update()

    def get_result(self):
        return self.new_fill

    def update(self):
        self.pattern_clrs.set_mode(self.new_fill[2][2][0][0])
        self.rule_keeper.set_mode(self.new_fill[0])
        self.pattern_editor.set_pattern_def(self.new_fill[2])
        self.refpanel.update(self.orig_fill, self.new_fill)
        self.pattern_clrs.set_visible(
            self.new_fill[2][0] == sk2const.PATTERN_IMG)
Example #4
0
class PatternFill(FillTab):

	name = _('Pattern Fill')

	def activate(self, fill_style, new_color=None):
		FillTab.activate(self, fill_style)
		rule = sk2_const.FILL_EVENODD
		pattern_type = sk2_const.PATTERN_IMG
		pattern = '' + DEFAULT_PATTERN
		image_style = deepcopy([sk2_const.CMYK_BLACK, sk2_const.CMYK_WHITE])
		trafo = [] + sk2_const.NORMAL_TRAFO
		transforms = [] + sk2_const.PATTERN_TRANSFORMS

		if fill_style:
			rule = fill_style[0]
			if fill_style[1] == sk2_const.FILL_PATTERN:
				pattern_type = fill_style[2][0]
				pattern = deepcopy(fill_style[2][1])
				if len(fill_style[2]) > 2:
					image_style = deepcopy(fill_style[2][2])
				if len(fill_style[2]) > 3:
					trafo = [] + fill_style[2][3]
				if len(fill_style[2]) > 4:
					transforms = [] + fill_style[2][4]
				else:
					transforms = []
			elif fill_style[1] == sk2_const.FILL_SOLID:
				if fill_style[2][0] in GRADIENT_CLR_MODES:
					color0 = deepcopy(fill_style[2])
					color0[3] = ''
					color1 = deepcopy(sk2_const.CMYK_WHITE)
					if not color0[0] == color1[0]:
						color1 = self.cms.get_color(color1, color0[0])
					color1[3] = ''
					image_style = [color0, color1]

		color0 = image_style[0]
		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])
			color1[3] = ''
			image_style[1] = color1

		self.new_fill = [rule, sk2_const.FILL_PATTERN,
						[pattern_type, pattern, image_style, trafo, transforms]]
		self.update()


	def build(self):
		panel = wal.HPanel(self)
		self.pattern_clrs = wal.HToggleKeeper(panel, GRADIENT_CLR_MODES,
								GRADIENT_CLR_ICONS,
								GRADIENT_CLR_NAMES, self.on_clr_mode_change)
		panel.pack(self.pattern_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)

		default_pattern_def = [sk2_const.PATTERN_IMG, '' + DEFAULT_PATTERN,
					deepcopy([sk2_const.CMYK_BLACK, sk2_const.CMYK_WHITE]),
					[] + sk2_const.NORMAL_TRAFO]
		self.pattern_editor = PatternEditor(self, self.dlg, self.cms,
						default_pattern_def, onchange=self.on_pattern_change)
		self.pack(self.pattern_editor, fill=True, expand=True, padding_all=5)


		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 = PatternMiniPalette(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):
		image_style = deepcopy(self.new_fill[2][2])
		image_style[0] = self.cms.get_color(image_style[0], mode)
		image_style[1] = self.cms.get_color(image_style[1], mode)
		self.new_fill[2][2] = image_style
		self.update()

	def on_presets_select(self, pattern):
		self.new_fill[2][1] = pattern
		self.new_fill[2][0] = sk2_const.PATTERN_IMG
		self.update()

	def on_pattern_change(self, pattern_def):
		self.new_fill[2] = deepcopy(pattern_def)
		self.update()

	def get_result(self):
		return self.new_fill

	def update(self):
		self.pattern_clrs.set_mode(self.new_fill[2][2][0][0])
		self.rule_keeper.set_mode(self.new_fill[0])
		self.pattern_editor.set_pattern_def(self.new_fill[2])
		self.refpanel.update(self.orig_fill, self.new_fill)
		self.pattern_clrs.set_visible(self.new_fill[2][0] == sk2_const.PATTERN_IMG)