Add different background image modes
stretch_and_fill, scale_and_fit, scale_and_crop, tiling
This commit is contained in:
parent
403bf540d0
commit
21529cec6c
|
@ -216,6 +216,7 @@ DEFAULTS = {
|
||||||
'background_darkness' : 0.5,
|
'background_darkness' : 0.5,
|
||||||
'background_type' : 'solid',
|
'background_type' : 'solid',
|
||||||
'background_image' : '',
|
'background_image' : '',
|
||||||
|
'background_image_mode' : 'stretch_and_fill',
|
||||||
'backspace_binding' : 'ascii-del',
|
'backspace_binding' : 'ascii-del',
|
||||||
'delete_binding' : 'escape-sequence',
|
'delete_binding' : 'escape-sequence',
|
||||||
'color_scheme' : 'grey_on_black',
|
'color_scheme' : 'grey_on_black',
|
||||||
|
|
|
@ -1135,17 +1135,35 @@ class Terminal(Gtk.VBox):
|
||||||
|
|
||||||
# save cairo context
|
# save cairo context
|
||||||
cr.save()
|
cr.save()
|
||||||
|
|
||||||
# draw background image
|
# draw background image
|
||||||
|
image_mode = self.config['background_image_mode']
|
||||||
|
|
||||||
rect = self.vte.get_allocation()
|
rect = self.vte.get_allocation()
|
||||||
xratio = float(rect.width) / float(self.background_image.get_width())
|
xratio = float(rect.width) / float(self.background_image.get_width())
|
||||||
yratio = float(rect.height) / float(self.background_image.get_height())
|
yratio = float(rect.height) / float(self.background_image.get_height())
|
||||||
|
if image_mode == 'stretch_and_fill':
|
||||||
cr.scale(xratio, yratio)
|
cr.scale(xratio, yratio)
|
||||||
|
elif image_mode == 'scale_and_fit':
|
||||||
|
ratio = min(xratio, yratio)
|
||||||
|
cr.scale(ratio, ratio)
|
||||||
|
elif image_mode == 'scale_and_crop':
|
||||||
|
ratio = max(xratio, yratio)
|
||||||
|
cr.scale(ratio, ratio)
|
||||||
|
|
||||||
|
# TODO add image alignment
|
||||||
|
|
||||||
cr.set_source_surface(self.background_image)
|
cr.set_source_surface(self.background_image)
|
||||||
cr.get_source().set_filter(cairo.Filter.FAST)
|
cr.get_source().set_filter(cairo.Filter.FAST)
|
||||||
|
if image_mode == 'tiling':
|
||||||
|
cr.get_source().set_extend(cairo.Extend.REPEAT)
|
||||||
|
|
||||||
cr.paint()
|
cr.paint()
|
||||||
|
|
||||||
# draw transparent monochrome layer
|
# draw transparent monochrome layer
|
||||||
Gdk.cairo_set_source_rgba(cr, self.bgcolor)
|
Gdk.cairo_set_source_rgba(cr, self.bgcolor)
|
||||||
cr.paint()
|
cr.paint()
|
||||||
|
|
||||||
# restore cairo context
|
# restore cairo context
|
||||||
cr.restore()
|
cr.restore()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue