Exemple #1
0
	def get_limit(self, id):
		a = SVGEditor.find_by_id(self.tree, id)
		width, height = 0, 0
		if not hasattr(a, "parent"): a.parent = None
		x, y = SVGEditor.get_translation(a, absolute=True)
		if 'width' in a.attrib:  width = float(a.attrib['width'])
		if 'height' in a.attrib: height = float(a.attrib['height'])
		return x, y, width, height
Exemple #2
0
 def get_limit(self, id):
     a = SVGEditor.find_by_id(self.tree, id)
     width, height = 0, 0
     if not hasattr(a, "parent"): a.parent = None
     x, y = SVGEditor.get_translation(a, absolute=True)
     if 'width' in a.attrib: width = float(a.attrib['width'])
     if 'height' in a.attrib: height = float(a.attrib['height'])
     return x, y, width, height
Exemple #3
0
    def __init__(self, image):
        Gtk.DrawingArea.__init__(self)
        self.connect('size-allocate', self.on_size_allocate)
        self.connect('draw', self.on_draw)

        areas = []
        self.color_button1 = 0.8, 0, 0, 1  # Just random mess,
        self.color_button1_border = 1, 0, 0, 1  # config overrides it anyway
        self.color_button2 = 0.8, 0.8, 0, 1
        self.color_button2_border = 1, 1, 0, 1
        self.color_hilight = 0, 1, 1, 1
        self.color_pressed = 1, 1, 1, 1
        self.color_text = 1, 1, 1, 1

        self.overlay = SVGWidget(image, False)
        self.tree = ET.fromstring(self.overlay.current_svg.encode("utf-8"))
        SVGWidget.find_areas(self.tree, None, areas, get_colors=True)

        self._hilight = ()
        self._pressed = ()
        self._button_images = {}
        self._help_areas = [
            self.get_limit("HELP_LEFT"),
            self.get_limit("HELP_RIGHT")
        ]
        self._help_lines = ([], [])

        # TODO: It would be cool to use user-set font here, but cairo doesn't
        # have glyph replacement and most of default fonts (Ubuntu, Cantarell,
        # similar shit) misses pretty-much everything but letters, notably ↲
        #
        # For that reason, DejaVu Sans is hardcoded for now. On systems
        # where DejaVu Sans is not available, Cairo will automatically fallback
        # to default font.
        self.font_face = "DejaVu Sans"
        # self.font_face = Gtk.Label(label="X").get_style().font_desc.get_family()
        log.debug("Using font %s", self.font_face)

        self.buttons = [Button(self.tree, area) for area in areas]
        background = SVGEditor.find_by_id(self.tree, "BACKGROUND")
        self.set_size_request(*SVGEditor.get_size(background))
        self.overlay.edit().keep("overlay").commit()
        self.overlay.hilight({})
Exemple #4
0
	def __init__(self, image):
		Gtk.DrawingArea.__init__(self)
		self.connect('size-allocate', self.on_size_allocate)
		self.connect('draw', self.on_draw)
		
		areas = []
		self.color_button1 = 0.8, 0, 0, 1			# Just random mess,
		self.color_button1_border = 1, 0, 0, 1		# config overrides it anyway
		self.color_button2 = 0.8, 0.8, 0, 1
		self.color_button2_border = 1, 1, 0, 1
		self.color_hilight = 0, 1, 1, 1
		self.color_pressed = 1, 1, 1, 1
		self.color_text = 1, 1, 1, 1
		
		self.overlay = SVGWidget(image, False)
		self.tree = ET.fromstring(self.overlay.current_svg.encode("utf-8"))
		SVGWidget.find_areas(self.tree, None, areas, get_colors=True)
		
		self._hilight = ()
		self._pressed = ()
		self._button_images = {}
		self._help_areas = [ self.get_limit("HELP_LEFT"), self.get_limit("HELP_RIGHT") ]
		self._help_lines = ( [], [] )
		
		# TODO: It would be cool to use user-set font here, but cairo doesn't
		# have glyph replacement and most of default fonts (Ubuntu, Cantarell,
		# similar shit) misses pretty-much everything but letters, notably ↲
		#
		# For that reason, DejaVu Sans is hardcoded for now. On systems
		# where DejaVu Sans is not available, Cairo will automatically fallback
		# to default font.
		self.font_face = "DejaVu Sans"
		# self.font_face = Gtk.Label(label="X").get_style().font_desc.get_family()
		log.debug("Using font %s", self.font_face)
		
		self.buttons = [ Button(self.tree, area) for area in areas ]
		background = SVGEditor.find_by_id(self.tree, "BACKGROUND")
		self.set_size_request(*SVGEditor.get_size(background))
		self.overlay.edit().keep("overlay").commit()
		self.overlay.hilight({})