Add Outline and Shadow size options

This commit is contained in:
Tim Bentley 2009-12-15 20:11:52 +00:00
parent 69d818222f
commit 43a99451a3
3 changed files with 59 additions and 31 deletions

View File

@ -43,9 +43,8 @@ class Renderer(object):
self._rect = None
self._debug = 0
self._right_margin = 64 # the amount of right indent
self._shadow_offset = 5
self._shadow_offset_footer = 3
self._outline_offset = 2
self._display_shadow_size_footer = 3
_display_outline_size = 2
self.theme_name = None
self._theme = None
self._bg_image_filename = None
@ -426,23 +425,24 @@ class Renderer(object):
# dont allow alignment messing with footers
if footer:
align = 0
shadow_offset = self._shadow_offset_footer
display_shadow_size = self._display_shadow_size_footer
else:
align = self._theme.display_horizontalAlign
shadow_offset = self._shadow_offset
display_shadow_size = int(self._theme.display_shadow_size)
_display_outline_size = int(self._theme.display_outline_size)
for linenum in range(len(lines)):
line = lines[linenum]
#find out how wide line is
w, h = self._get_extent_and_render(line, footer, tlcorner=(x, y),
draw=False)
if self._theme.display_shadow:
w += shadow_offset
h += shadow_offset
w += display_shadow_size
h += display_shadow_size
if self._theme.display_outline:
# pixels either side
w += 2 * self._outline_offset
w += 2 * _display_outline_size
# pixels top/bottom
h += 2 * self._outline_offset
h += 2 * _display_outline_size
if align == 0: # left align
rightextent = x + w
# shift right from last line's rh edge
@ -464,36 +464,36 @@ class Renderer(object):
# now draw the text, and any outlines/shadows
if self._theme.display_shadow:
self._get_extent_and_render(line, footer,
tlcorner=(x + shadow_offset, y + shadow_offset),
tlcorner=(x + display_shadow_size, y + display_shadow_size),
draw=True, color = self._theme.display_shadow_color)
if self._theme.display_outline:
self._get_extent_and_render(line, footer,
(x + self._outline_offset, y), draw=True,
(x + _display_outline_size, y), draw=True,
color = self._theme.display_outline_color)
self._get_extent_and_render(line, footer,
(x, y + self._outline_offset), draw=True,
(x, y + _display_outline_size), draw=True,
color = self._theme.display_outline_color)
self._get_extent_and_render(line, footer,
(x, y - self._outline_offset), draw=True,
(x, y - _display_outline_size), draw=True,
color = self._theme.display_outline_color)
self._get_extent_and_render(line, footer,
(x - self._outline_offset, y), draw=True,
(x - _display_outline_size, y), draw=True,
color = self._theme.display_outline_color)
if self._outline_offset > 1:
if _display_outline_size > 1:
self._get_extent_and_render(line, footer,
(x + self._outline_offset, y + self._outline_offset),
(x + _display_outline_size, y + _display_outline_size),
draw=True,
color = self._theme.display_outline_color)
self._get_extent_and_render(line, footer,
(x - self._outline_offset, y + self._outline_offset),
(x - _display_outline_size, y + _display_outline_size),
draw=True,
color = self._theme.display_outline_color)
self._get_extent_and_render(line, footer,
(x + self._outline_offset, y - self._outline_offset),
(x + _display_outline_size, y - _display_outline_size),
draw=True,
color = self._theme.display_outline_color)
self._get_extent_and_render(line, footer,
(x - self._outline_offset, y - self._outline_offset),
(x - _display_outline_size, y - _display_outline_size),
draw=True,
color = self._theme.display_outline_color)
self._get_extent_and_render(line, footer,tlcorner=(x, y),

View File

@ -65,8 +65,8 @@ blankthemexml=\
<location override="False" x="10" y="730" width="1024" height="38"/>
</font>
<display>
<shadow color="#000000">True</shadow>
<outline color="#000000">False</outline>
<shadow color="#000000" size="5">True</shadow>
<outline color="#000000" size="2">False</outline>
<horizontalAlign>0</horizontalAlign>
<verticalAlign>0</verticalAlign>
<wrapStyle>0</wrapStyle>
@ -238,7 +238,7 @@ class ThemeXML(object):
background.appendChild(element)
def add_display(self, shadow, shadow_color, outline, outline_color,
horizontal, vertical, wrap, transition):
horizontal, vertical, wrap, transition, shadow_pixel=5, outline_pixel=2):
"""
Add a Display options.
@ -272,12 +272,14 @@ class ThemeXML(object):
# Shadow
element = self.theme_xml.createElement(u'shadow')
element.setAttribute(u'color', shadow_color)
element.setAttribute(u'size', unicode(shadow_pixel))
value = self.theme_xml.createTextNode(shadow)
element.appendChild(value)
background.appendChild(element)
# Outline
element = self.theme_xml.createElement(u'outline')
element.setAttribute(u'color', outline_color)
element.setAttribute(u'size', unicode(outline_pixel))
value = self.theme_xml.createTextNode(outline)
element.appendChild(value)
background.appendChild(element)

View File

@ -410,13 +410,13 @@ class Ui_AmendThemeDialog(object):
self.OptionsLeftLayout.setSpacing(8)
self.OptionsLeftLayout.setMargin(0)
self.OptionsLeftLayout.setObjectName(u'OptionsLeftLayout')
self.ShadowGroupBox = QtGui.QGroupBox(self.OptionsLeftWidget)
self.ShadowGroupBox.setObjectName(u'ShadowGroupBox')
self.verticalLayout = QtGui.QVBoxLayout(self.ShadowGroupBox)
self.OutlineGroupBox = QtGui.QGroupBox(self.OptionsLeftWidget)
self.OutlineGroupBox.setObjectName(u'OutlineGroupBox')
self.verticalLayout = QtGui.QVBoxLayout(self.OutlineGroupBox)
self.verticalLayout.setSpacing(8)
self.verticalLayout.setMargin(8)
self.verticalLayout.setObjectName(u'verticalLayout')
self.OutlineWidget = QtGui.QWidget(self.ShadowGroupBox)
self.OutlineWidget = QtGui.QWidget(self.OutlineGroupBox)
self.OutlineWidget.setObjectName(u'OutlineWidget')
self.OutlineLayout = QtGui.QFormLayout(self.OutlineWidget)
self.OutlineLayout.setMargin(0)
@ -425,16 +425,30 @@ class Ui_AmendThemeDialog(object):
self.OutlineCheckBox = QtGui.QCheckBox(self.OutlineWidget)
self.OutlineCheckBox.setObjectName(u'OutlineCheckBox')
self.OutlineLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.OutlineCheckBox)
self.OutlineSpinBox = QtGui.QSpinBox(self.OutlineWidget)
self.OutlineSpinBox.setObjectName("OutlineSpinBox")
self.OutlineSpinBox.setMaximum(10)
self.OutlineLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.OutlineSpinBox)
self.OutlineSpinBoxLabel = QtGui.QLabel(self.OutlineWidget)
self.OutlineSpinBoxLabel.setObjectName(u'OutlineSpinBoxLabel')
self.OutlineLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.OutlineSpinBoxLabel)
self.OutlineColorLabel = QtGui.QLabel(self.OutlineWidget)
self.OutlineColorLabel.setObjectName(u'OutlineColorLabel')
self.OutlineLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.OutlineColorLabel)
self.OutlineLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.OutlineColorLabel)
self.OutlineColorPushButton = QtGui.QPushButton(self.OutlineWidget)
self.OutlineColorPushButton.setObjectName(u'OutlineColorPushButton')
self.OutlineLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.OutlineColorPushButton)
self.OutlineLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.OutlineColorPushButton)
self.OutlineEnabledLabel = QtGui.QLabel(self.OutlineWidget)
self.OutlineEnabledLabel.setObjectName(u'OutlineEnabledLabel')
self.OutlineLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.OutlineEnabledLabel)
self.verticalLayout.addWidget(self.OutlineWidget)
self.OptionsLeftLayout.addWidget(self.OutlineGroupBox)
self.ShadowGroupBox = QtGui.QGroupBox(self.OptionsLeftWidget)
self.ShadowGroupBox.setObjectName(u'ShadowGroupBox')
self.verticalLayout = QtGui.QVBoxLayout(self.ShadowGroupBox)
self.verticalLayout.setSpacing(8)
self.verticalLayout.setMargin(8)
self.verticalLayout.setObjectName(u'verticalLayout')
self.ShadowWidget = QtGui.QWidget(self.ShadowGroupBox)
self.ShadowWidget.setObjectName(u'ShadowWidget')
self.ShadowLayout = QtGui.QFormLayout(self.ShadowWidget)
@ -444,12 +458,19 @@ class Ui_AmendThemeDialog(object):
self.ShadowCheckBox = QtGui.QCheckBox(self.ShadowWidget)
self.ShadowCheckBox.setObjectName(u'ShadowCheckBox')
self.ShadowLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.ShadowCheckBox)
self.ShadowSpinBox = QtGui.QSpinBox(self.OutlineWidget)
self.ShadowSpinBox.setObjectName("ShadowSpinBox")
self.ShadowSpinBox.setMaximum(10)
self.ShadowLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.ShadowSpinBox)
self.ShadowSpinBoxLabel = QtGui.QLabel(self.OutlineWidget)
self.ShadowSpinBoxLabel.setObjectName(u'ShadowSpinBoxLabel')
self.ShadowLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.ShadowSpinBoxLabel)
self.ShadowColorLabel = QtGui.QLabel(self.ShadowWidget)
self.ShadowColorLabel.setObjectName(u'ShadowColorLabel')
self.ShadowLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.ShadowColorLabel)
self.ShadowLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.ShadowColorLabel)
self.ShadowColorPushButton = QtGui.QPushButton(self.ShadowWidget)
self.ShadowColorPushButton.setObjectName(u'ShadowColorPushButton')
self.ShadowLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.ShadowColorPushButton)
self.ShadowLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.ShadowColorPushButton)
self.ShadowEnabledLabel = QtGui.QLabel(self.ShadowWidget)
self.ShadowEnabledLabel.setObjectName(u'ShadowEnabledLabel')
self.ShadowLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.ShadowEnabledLabel)
@ -640,9 +661,14 @@ class Ui_AmendThemeDialog(object):
self.ThemeTabWidget.setTabText(
self.ThemeTabWidget.indexOf(self.FontFooterTab),
self.trUtf8('Font Footer'))
self.ShadowGroupBox.setTitle(self.trUtf8('Shadow && Outline'))
self.OutlineGroupBox.setTitle(self.trUtf8('Outline'))
self.OutlineSpinBoxLabel.setText(self.trUtf8('Outline Size:'))
self.OutlineSpinBox.setSuffix(self.trUtf8('px'))
self.OutlineColorLabel.setText(self.trUtf8('Outline Color:'))
self.OutlineEnabledLabel.setText(self.trUtf8('Show Outline:'))
self.ShadowGroupBox.setTitle(self.trUtf8('Shadow'))
self.ShadowSpinBoxLabel.setText(self.trUtf8('Shadow Size:'))
self.ShadowSpinBox.setSuffix(self.trUtf8('px'))
self.ShadowColorLabel.setText(self.trUtf8('Shadow Color:'))
self.ShadowEnabledLabel.setText(self.trUtf8('Show Shadow:'))
self.AlignmentGroupBox.setTitle(self.trUtf8('Alignment'))