forked from openlp/openlp
Add Shadow and Outline options to Themes
bzr-revno: 690
This commit is contained in:
commit
e4e06dd23b
@ -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 = 0
|
||||
self._display_outline_size_footer = 0
|
||||
self.theme_name = None
|
||||
self._theme = None
|
||||
self._bg_image_filename = None
|
||||
@ -426,23 +425,25 @@ 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
|
||||
display_outline_size = self._display_outline_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 +465,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),
|
||||
|
@ -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)
|
||||
|
@ -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'))
|
||||
|
@ -121,8 +121,14 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
||||
self.onFontFooterHeightSpinBoxChanged)
|
||||
QtCore.QObject.connect(self.OutlineCheckBox,
|
||||
QtCore.SIGNAL(u'stateChanged(int)'), self.onOutlineCheckBoxChanged)
|
||||
QtCore.QObject.connect(self.ShadowSpinBox,
|
||||
QtCore.SIGNAL(u'editingFinished()'),
|
||||
self.onShadowSpinBoxChanged)
|
||||
QtCore.QObject.connect(self.ShadowCheckBox,
|
||||
QtCore.SIGNAL(u'stateChanged(int)'), self.onShadowCheckBoxChanged)
|
||||
QtCore.QObject.connect(self.OutlineSpinBox,
|
||||
QtCore.SIGNAL(u'editingFinished()'),
|
||||
self.onOutlineSpinBoxChanged)
|
||||
QtCore.QObject.connect(self.SlideTransitionCheckedBox,
|
||||
QtCore.SIGNAL(u'stateChanged(int)'), self.onSlideTransitionCheckedBoxChanged)
|
||||
|
||||
@ -179,7 +185,9 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
||||
unicode(self.theme.display_horizontalAlign),
|
||||
unicode(self.theme.display_verticalAlign),
|
||||
unicode(self.theme.display_wrapStyle),
|
||||
unicode(self.theme.display_slideTransition))
|
||||
unicode(self.theme.display_slideTransition),
|
||||
unicode(self.theme.display_shadow_size),
|
||||
unicode(self.theme.display_outline_size))
|
||||
theme = new_theme.extract_xml()
|
||||
pretty_theme = new_theme.extract_formatted_xml()
|
||||
if self.thememanager.saveTheme(theme_name, theme, pretty_theme,
|
||||
@ -434,6 +442,16 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
||||
self.stateChanging(self.theme)
|
||||
self.previewTheme()
|
||||
|
||||
def onOutlineSpinBoxChanged(self):
|
||||
if self.theme.display_outline_size != self.OutlineSpinBox.value():
|
||||
self.theme.display_outline_size = self.OutlineSpinBox.value()
|
||||
self.previewTheme()
|
||||
|
||||
def onShadowSpinBoxChanged(self):
|
||||
if self.theme.display_shadow_size != self.ShadowSpinBox.value():
|
||||
self.theme.display_shadow_size = self.ShadowSpinBox.value()
|
||||
self.previewTheme()
|
||||
|
||||
def onOutlineColorPushButtonClicked(self):
|
||||
self.theme.display_outline_color = QtGui.QColorDialog.getColor(
|
||||
QtGui.QColor(self.theme.display_outline_color), self).name()
|
||||
@ -565,6 +583,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
||||
else:
|
||||
self.OutlineCheckBox.setChecked(False)
|
||||
self.OutlineColorPushButton.setEnabled(False)
|
||||
self.OutlineSpinBox.setValue(int(self.theme.display_outline_size))
|
||||
|
||||
if self.theme.display_shadow:
|
||||
self.ShadowCheckBox.setChecked(True)
|
||||
@ -572,6 +591,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
||||
else:
|
||||
self.ShadowCheckBox.setChecked(False)
|
||||
self.ShadowColorPushButton.setEnabled(False)
|
||||
self.ShadowSpinBox.setValue(int(self.theme.display_shadow_size))
|
||||
|
||||
if self.theme.display_slideTransition:
|
||||
self.SlideTransitionCheckedBox.setCheckState(QtCore.Qt.Checked)
|
||||
|
@ -1 +1 @@
|
||||
1.9.0-689
|
||||
1.9.0-690
|
||||
|
Loading…
Reference in New Issue
Block a user