Fancied up the text window with pango. Added lots of font options and

effects.

Fixed some bugs with resizing a window when it's not draggable and
resizing a window when the max size is (-1, -1)
This commit is contained in:
Joey Payne 2014-02-06 08:00:24 -07:00
commit 5854cfee86
3 changed files with 195 additions and 65 deletions

View file

@ -117,6 +117,8 @@ class Size(StructureBase):
return Size(self.width*other, self.height*other)
def area(self):
if self.width < 0 or self.height < 0:
return -1
return self.width*self.height
def __iter__(self):
@ -124,21 +126,7 @@ class Size(StructureBase):
yield self.height
class BorderRadius(StructureBase):
def __init__(self, *args, **kwargs):
values = self._parse_value(args)
self.topleft = kwargs.get('topleft', values[0])
self.topright = kwargs.get('topright', values[1])
self.bottomright = kwargs.get('bottomright', values[2])
self.bottomleft = kwargs.get('bottomleft', values[3])
def __iter__(self):
yield self.topleft
yield self.topright
yield self.bottomright
yield self.bottomleft
class FourValueStructure(StructureBase):
@classmethod
def _parse_value(cls, value):
f = lambda *args: args
@ -161,6 +149,36 @@ class BorderRadius(StructureBase):
return cls(*cls._parse_value(value))
class BorderRadius(FourValueStructure):
def __init__(self, *args, **kwargs):
values = self._parse_value(args)
self.topleft = kwargs.get('topleft', values[0])
self.topright = kwargs.get('topright', values[1])
self.bottomright = kwargs.get('bottomright', values[2])
self.bottomleft = kwargs.get('bottomleft', values[3])
def __iter__(self):
yield self.topleft
yield self.topright
yield self.bottomright
yield self.bottomleft
class Padding(FourValueStructure):
def __init__(self, *args, **kwargs):
values = self._parse_value(args)
self.top = kwargs.get('top', values[0])
self.right = kwargs.get('right', values[1])
self.bottom = kwargs.get('bottom', values[2])
self.left = kwargs.get('left', values[3])
def __iter__(self):
yield self.top
yield self.right
yield self.bottom
yield self.left
class Color(StructureBase):
def __init__(self, r=0, g=0, b=0, a=1):
self.r = float(r)
@ -265,6 +283,26 @@ class Rectangle(StructureBase):
def size(self, size):
self._size = Size.from_value(size)
def contains(self, other):
other = Rectangle.from_value(other)
if self.intersects_with(other.position) and\
self.intersects_with(other.position + other.size - [1,1]):
return True
return False
def intersection(self, other):
other = Rectangle.from_value(other)
if other.contains(self):
return self
elif self.contains(other):
return other
if self.intersects_with(other.position):
return Rectangle(other.position, self.position + self.size - other.position)
elif other.intersects_with(self.position):
return Rectangle(self.position, other.position + other.size - self.position)
else:
return Rectangle()
def intersects_with(self, position):
"""Checks if the position is within the bounds of the rectangle including the edges"""
pos = Position.from_value(position)