diff options
| author | Fraxinas <andreas.frisch@multimedia-labs.de> | 2008-12-04 11:20:12 +0100 |
|---|---|---|
| committer | Fraxinas <andreas.frisch@multimedia-labs.de> | 2008-12-04 11:20:12 +0100 |
| commit | c69c3febf1582fb1bd170bc4b04132354f574cfc (patch) | |
| tree | 0112d1a9e7863f87fccbdf47e7143feb0498227c /lib/python | |
| parent | e61975a7c2d349bcc5c372c3ca472ce8da28f6fc (diff) | |
| download | enigma2-c69c3febf1582fb1bd170bc4b04132354f574cfc.tar.gz enigma2-c69c3febf1582fb1bd170bc4b04132354f574cfc.zip | |
allow fully customizable dvd menu layout, including automatic thumbnail graphic creation (requires package aio-grab)
Diffstat (limited to 'lib/python')
| -rw-r--r-- | lib/python/Plugins/Extensions/DVDBurn/DVDProject.py | 100 | ||||
| -rw-r--r-- | lib/python/Plugins/Extensions/DVDBurn/DVDTitle.py | 10 | ||||
| -rw-r--r-- | lib/python/Plugins/Extensions/DVDBurn/DreamboxDVD.ddvdp.xml | 14 | ||||
| -rw-r--r-- | lib/python/Plugins/Extensions/DVDBurn/DreamboxDVDtemplate.ddvdp.xml | 23 | ||||
| -rw-r--r-- | lib/python/Plugins/Extensions/DVDBurn/Process.py | 249 | ||||
| -rw-r--r-- | lib/python/Plugins/Extensions/DVDBurn/ProjectSettings.py | 34 | ||||
| -rw-r--r-- | lib/python/Plugins/Extensions/DVDBurn/Text menu boat.ddvdm.xml | 35 | ||||
| -rw-r--r-- | lib/python/Plugins/Extensions/DVDBurn/Thumbs menu clouds.ddvdm.xml | 35 | ||||
| -rw-r--r-- | lib/python/Plugins/Extensions/DVDBurn/TitleCutter.py | 7 | ||||
| -rw-r--r-- | lib/python/Plugins/Extensions/DVDBurn/TitleList.py | 4 | ||||
| -rw-r--r-- | lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py | 45 | ||||
| -rw-r--r-- | lib/python/Plugins/Extensions/DVDBurn/dreamdvd_clouds.jpg | bin | 0 -> 62697 bytes | |||
| -rw-r--r--[-rwxr-xr-x] | lib/python/Plugins/Extensions/DVDBurn/dvdburn.png | bin | 3869 -> 3869 bytes |
13 files changed, 381 insertions, 175 deletions
diff --git a/lib/python/Plugins/Extensions/DVDBurn/DVDProject.py b/lib/python/Plugins/Extensions/DVDBurn/DVDProject.py index 112a221e..b0b8197a 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/DVDProject.py +++ b/lib/python/Plugins/Extensions/DVDBurn/DVDProject.py @@ -1,18 +1,10 @@ from Tools.Directories import fileExists -from Components.config import config, ConfigSubsection, ConfigInteger, ConfigText, ConfigSelection, getConfigListEntry, ConfigSequence +from Components.config import config, ConfigSubsection, ConfigInteger, ConfigText, ConfigSelection, getConfigListEntry, ConfigSequence, ConfigSubList class ConfigColor(ConfigSequence): def __init__(self): ConfigSequence.__init__(self, seperator = "#", limits = [(0,255),(0,255),(0,255)]) -class ConfigPixelvals(ConfigSequence): - def __init__(self): - ConfigSequence.__init__(self, seperator = ",", limits = [(0,200),(0,200),(0,200)]) - -class ConfigPixelvals(ConfigSequence): - def __init__(self): - ConfigSequence.__init__(self, seperator = ",", limits = [(0,200),(0,200),(0,200)]) - class ConfigFilename(ConfigText): def __init__(self): ConfigText.__init__(self, default = "", fixed_size = True, visible_width = False) @@ -35,19 +27,11 @@ class DVDProject: self.settings.titlesetmode = ConfigSelection(choices = [("single", _("Simple titleset (compatibility for legacy players)")), ("multi", _("Complex (allows mixing audio tracks and aspects)"))], default="multi") self.settings.output = ConfigSelection(choices = [("iso", _("Create DVD-ISO")), ("dvd", _("Burn DVD"))]) self.settings.isopath = ConfigText(fixed_size = False, visible_width = 40) - self.settings.dataformat = ConfigSelection(choices = [("iso9660_1", ("ISO9660 Level 1")), ("iso9660_4", ("ISO9660 version 2")), ("udf", ("UDF"))]) - self.settings.menubg = ConfigFilename() - self.settings.menuaudio = ConfigFilename() - self.settings.titleformat = ConfigText(fixed_size = False, visible_width = 40) - self.settings.subtitleformat = ConfigText(fixed_size = False, visible_width = 40) - self.settings.color_headline = ConfigColor() - self.settings.color_highlight = ConfigColor() - self.settings.color_button = ConfigColor() - self.settings.font_face = ConfigFilename() - self.settings.font_size = ConfigPixelvals() - self.settings.space = ConfigPixelvals() + self.settings.dataformat = ConfigSelection(choices = [("iso9660_1", ("ISO9660 Level 1")), ("iso9660_4", ("ISO9660 version 2")), ("udf", ("UDF"))]) + self.settings.menutemplate = ConfigFilename() self.settings.vmgm = ConfigFilename() - self.filekeys = ["vmgm", "menubg", "menuaudio", "font_face", "isopath"] + self.filekeys = ["vmgm", "isopath", "menutemplate"] + self.menutemplate = MenuTemplate() def addService(self, service): import DVDTitle @@ -65,12 +49,30 @@ class DVDProject: list.append('\t<settings ') for key, val in self.settings.dict().iteritems(): list.append( key + '="' + str(val.getValue()) + '" ' ) - list.append(' />\n') + list.append('/>\n') list.append('\t<titles>\n') for title in self.titles: - list.append('\t\t<path>') + list.append('\t\t<title>\n') + list.append('\t\t\t<path>') list.append(stringToXML(title.source.getPath())) list.append('</path>\n') + list.append('\t\t\t<properties ') + audiotracks = [] + for key, val in title.properties.dict().iteritems(): + if type(val) is ConfigSubList: + audiotracks.append('\t\t\t<audiotracks>\n') + for audiotrack in val: + audiotracks.append('\t\t\t\t<audiotrack ') + for subkey, subval in audiotrack.dict().iteritems(): + audiotracks.append( subkey + '="' + str(subval.getValue()) + '" ' ) + audiotracks.append(' />\n') + audiotracks.append('\t\t\t</audiotracks>\n') + else: + list.append( key + '="' + str(val.getValue()) + '" ' ) + list.append('/>\n') + for line in audiotracks: + list.append(line) + list.append('\t\t</title>\n') list.append('\t</titles>\n') list.append('</DreamDVDBurnerProject>\n') @@ -89,6 +91,13 @@ class DVDProject: return False return filename + def load(self, filename): + ret = self.loadProject(filename) + if ret: + ret = self.menutemplate.loadTemplate(self.settings.menutemplate.getValue()) + self.error += self.menutemplate.error + return ret + def loadProject(self, filename): import xml.dom.minidom try: @@ -105,9 +114,9 @@ class DVDProject: if project.nodeType == xml.dom.minidom.Element.nodeType: if project.tagName == 'settings': i = 0 - if project.attributes.length < 11: + if project.attributes.length < len(self.settings.dict()): self.error = "project attributes missing" - raise AttributeError + raise AttributeError while i < project.attributes.length: item = project.attributes.item(i) key = item.name.encode("utf-8") @@ -131,3 +140,44 @@ class DVDProject: self.error += (" in project '%s'") % (filename) return False return True + +class MenuTemplate(DVDProject): + def __init__(self): + self.settings = ConfigSubsection() + self.settings.titleformat = ConfigText(fixed_size = False, visible_width = 40) + self.settings.subtitleformat = ConfigText(fixed_size = False, visible_width = 40) + self.settings.menubg = ConfigFilename() + self.settings.menuaudio = ConfigFilename() + self.settings.dimensions = ConfigSequence(seperator = ',', default = [576,720], limits = [(352,720),(480,576)]) + self.settings.rows = ConfigInteger(default = 4, limits = (1, 10)) + self.settings.cols = ConfigInteger(default = 1, limits = (1, 4)) + self.settings.color_headline = ConfigColor() + self.settings.color_headline = ConfigColor() + self.settings.color_highlight = ConfigColor() + self.settings.color_button = ConfigColor() + self.settings.fontface_headline = ConfigFilename() + self.settings.fontface_title = ConfigFilename() + self.settings.fontface_subtitle = ConfigFilename() + self.settings.fontsize_headline = ConfigInteger(default = 46, limits = (0, 199)) + self.settings.fontsize_title = ConfigInteger(default = 24, limits = (0, 199)) + self.settings.fontsize_subtitle = ConfigInteger(default = 14, limits = (0, 199)) + self.settings.margin_top = ConfigInteger(default = 120, limits = (0, 500)) + self.settings.margin_bottom = ConfigInteger(default = 40, limits = (0, 500)) + self.settings.margin_left = ConfigInteger(default = 56, limits = (0, 500)) + self.settings.margin_right = ConfigInteger(default = 56, limits = (0, 500)) + self.settings.space_rows = ConfigInteger(default = 32, limits = (0, 500)) + self.settings.space_cols = ConfigInteger(default = 24, limits = (0, 500)) + self.settings.prev_page_text = ConfigText(default = "<<<", fixed_size = False) + self.settings.next_page_text = ConfigText(default = ">>>", fixed_size = False) + self.settings.offset_headline = ConfigSequence(seperator = ',', default = [0,0], limits = [(-1,500),(-1,500)]) + self.settings.offset_title = ConfigSequence(seperator = ',', default = [0,0], limits = [(-1,500),(-1,500)]) + self.settings.offset_subtitle = ConfigSequence(seperator = ',', default = [20,0], limits = [(-1,500),(-1,500)]) + self.settings.offset_thumb = ConfigSequence(seperator = ',', default = [40,0], limits = [(-1,500),(-1,500)]) + self.settings.thumb_size = ConfigSequence(seperator = ',', default = [200,158], limits = [(0,576),(-1,720)]) + self.settings.thumb_border = ConfigInteger(default = 2, limits = (0, 20)) + self.filekeys = ["menubg", "menuaudio", "fontface_headline", "fontface_title", "fontface_subtitle"] + + def loadTemplate(self, filename): + ret = DVDProject.loadProject(self, filename) + DVDProject.error = self.error + return ret diff --git a/lib/python/Plugins/Extensions/DVDBurn/DVDTitle.py b/lib/python/Plugins/Extensions/DVDBurn/DVDTitle.py index b1c627aa..660005e6 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/DVDTitle.py +++ b/lib/python/Plugins/Extensions/DVDBurn/DVDTitle.py @@ -51,11 +51,11 @@ class DVDTitle: self.length = info.getLength(service) def initDVDmenuText(self, project, track): - self.properties.menutitle.setValue(self.formatDVDmenuText(project.settings.titleformat.getValue(), track)) - self.properties.menusubtitle.setValue(self.formatDVDmenuText(project.settings.subtitleformat.getValue(), track)) + s = project.menutemplate.settings + self.properties.menutitle.setValue(self.formatDVDmenuText(s.titleformat.getValue(), track)) + self.properties.menusubtitle.setValue(self.formatDVDmenuText(s.subtitleformat.getValue(), track)) def formatDVDmenuText(self, template, track): - properties = self.properties template = template.replace("$i", str(track)) template = template.replace("$t", self.DVBname) template = template.replace("$d", self.DVBdescr) @@ -76,7 +76,7 @@ class DVDTitle: audiolist.append(trackstring) audiostring = ', '.join(audiolist) template = template.replace("$A", audiostring) - + if template.find("$l") >= 0: l = self.length lengthstring = "%d:%02d:%02d" % (l/3600, l%3600/60, l%60) @@ -90,7 +90,7 @@ class DVDTitle: else: template = template.replace("$Y", "").replace("$M", "").replace("$D", "").replace("$T", "") return template - + def produceFinalCuesheet(self): CUT_TYPE_IN = 0 CUT_TYPE_OUT = 1 diff --git a/lib/python/Plugins/Extensions/DVDBurn/DreamboxDVD.ddvdp.xml b/lib/python/Plugins/Extensions/DVDBurn/DreamboxDVD.ddvdp.xml new file mode 100644 index 00000000..2c35e531 --- /dev/null +++ b/lib/python/Plugins/Extensions/DVDBurn/DreamboxDVD.ddvdp.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8" ?> +<DreamDVDBurnProject> + <settings + name="Dreambox DVD record" + authormode="menu_linked" + menutemplate="/usr/lib/enigma2/python/Plugins/Extensions/DVDBurn/Thumbs menu clouds.ddvdm.xml" + titlesetmode="multi" + vmgm="/usr/lib/enigma2/python/Plugins/Extensions/DVDBurn/vmgmdream.mpg" + output="dvd" + isopath="/media/hdd/movie/" + dataformat="iso9660_4" + /> + <titles> </titles> +</DreamDVDBurnProject> diff --git a/lib/python/Plugins/Extensions/DVDBurn/DreamboxDVDtemplate.ddvdp.xml b/lib/python/Plugins/Extensions/DVDBurn/DreamboxDVDtemplate.ddvdp.xml deleted file mode 100644 index 7d8de8ce..00000000 --- a/lib/python/Plugins/Extensions/DVDBurn/DreamboxDVDtemplate.ddvdp.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<DreamDVDBurnerProject> - <settings - name="Dreambox DVD record" - authormode="menu_linked" - titlesetmode="multi" - titleformat="$i. $t" - subtitleformat="$D.$M.$Y, $T $C, $d" - vmgm="/usr/lib/enigma2/python/Plugins/Extensions/DVDBurn/vmgmdream.mpg" - menubg="/usr/lib/enigma2/python/Plugins/Extensions/DVDBurn/dreamdvd_boat.jpg" - menuaudio="/usr/lib/enigma2/python/Plugins/Extensions/DVDBurn/silence.mp2" - color_button="[8, 0, 0]" - color_highlight="[0, 192, 192]" - color_headline="[0, 0, 128]" - font_face="/usr/share/fonts/nmsbd.ttf" - font_size="[46, 24, 14]" - space="[120, 32, 56]" - output="dvd" - isopath="/media/hdd/movie/" - dataformat="iso9660_4" - /> - <titles> </titles> -</DreamDVDBurnerProject> diff --git a/lib/python/Plugins/Extensions/DVDBurn/Process.py b/lib/python/Plugins/Extensions/DVDBurn/Process.py index 750e9d9b..d0c9d3c6 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/Process.py +++ b/lib/python/Plugins/Extensions/DVDBurn/Process.py @@ -455,13 +455,13 @@ class ImagePrepareTask(Task): try: from ImageFont import truetype from Image import open as Image_open - s = self.job.project.settings + s = self.job.project.menutemplate.settings + (width, height) = s.dimensions.getValue() self.Menus.im_bg_orig = Image_open(s.menubg.getValue()) - if self.Menus.im_bg_orig.size != (self.Menus.imgwidth, self.Menus.imgheight): - self.Menus.im_bg_orig = self.Menus.im_bg_orig.resize((720, 576)) - self.Menus.fontsizes = s.font_size.getValue() - fontface = s.font_face.getValue() - self.Menus.fonts = [truetype(fontface, self.Menus.fontsizes[0]), truetype(fontface, self.Menus.fontsizes[1]), truetype(fontface, self.Menus.fontsizes[2])] + if self.Menus.im_bg_orig.size != (width, height): + self.Menus.im_bg_orig = self.Menus.im_bg_orig.resize((width, height)) + self.Menus.fontsizes = [s.fontsize_headline.getValue(), s.fontsize_title.getValue(), s.fontsize_subtitle.getValue()] + self.Menus.fonts = [(truetype(s.fontface_headline.getValue(), self.Menus.fontsizes[0])), (truetype(s.fontface_title.getValue(), self.Menus.fontsizes[1])),(truetype(s.fontface_subtitle.getValue(), self.Menus.fontsizes[2]))] Task.processFinished(self, 0) except: Task.processFinished(self, 1) @@ -480,98 +480,158 @@ class MenuImageTask(Task): def run(self, callback): self.callback = callback - try: - import ImageDraw, Image, os - s = self.job.project.settings - fonts = self.Menus.fonts - im_bg = self.Menus.im_bg_orig.copy() - im_high = Image.new("P", (self.Menus.imgwidth, self.Menus.imgheight), 0) - im_high.putpalette(self.Menus.spu_palette) - draw_bg = ImageDraw.Draw(im_bg) - draw_high = ImageDraw.Draw(im_high) - if self.menu_count == 1: - headline = s.name.getValue().decode("utf-8") - textsize = draw_bg.textsize(headline, font=fonts[0]) - if textsize[0] > self.Menus.imgwidth: - offset = (0 , 20) - else: - offset = (((self.Menus.imgwidth-textsize[0]) / 2) , 20) - draw_bg.text(offset, headline, fill=self.Menus.color_headline, font=fonts[0]) - spuxml = """<?xml version="1.0" encoding="utf-8"?> - <subpictures> - <stream> - <spu - highlight="%s" - transparent="%02x%02x%02x" - start="00:00:00.00" - force="yes" >""" % (self.highlightpngfilename, self.Menus.spu_palette[0], self.Menus.spu_palette[1], self.Menus.spu_palette[2]) - s_top, s_rows, s_left = s.space.getValue() - rowheight = (self.Menus.fontsizes[1]+self.Menus.fontsizes[2]+s_rows) - menu_start_title = (self.menu_count-1)*self.job.titles_per_menu + 1 - menu_end_title = (self.menu_count)*self.job.titles_per_menu + 1 - nr_titles = len(self.job.project.titles) - if menu_end_title > nr_titles: - menu_end_title = nr_titles+1 - menu_i = 0 - for title_no in range( menu_start_title , menu_end_title ): - menu_i += 1 - title = self.job.project.titles[title_no-1] - top = s_top + ( menu_i * rowheight ) - titleText = title.formatDVDmenuText(s.titleformat.getValue(), title_no).decode("utf-8") - draw_bg.text((s_left,top), titleText, fill=self.Menus.color_button, font=fonts[1]) - draw_high.text((s_left,top), titleText, fill=1, font=self.Menus.fonts[1]) - subtitleText = title.formatDVDmenuText(s.subtitleformat.getValue(), title_no).decode("utf-8") - draw_bg.text((s_left,top+36), subtitleText, fill=self.Menus.color_button, font=fonts[2]) - bottom = top+rowheight - if bottom > self.Menus.imgheight: - bottom = self.Menus.imgheight - spuxml += """ - <button name="button%s" x0="%d" x1="%d" y0="%d" y1="%d"/>""" % (str(title_no).zfill(2),s_left,self.Menus.imgwidth,top,bottom ) - if self.menu_count < self.job.nr_menus: - next_page_text = ">>>" - textsize = draw_bg.textsize(next_page_text, font=fonts[1]) - offset = ( self.Menus.imgwidth-textsize[0]-2*s_left, s_top + ( self.job.titles_per_menu * rowheight ) ) - draw_bg.text(offset, next_page_text, fill=self.Menus.color_button, font=fonts[1]) - draw_high.text(offset, next_page_text, fill=1, font=fonts[1]) - spuxml += """ - <button name="button_next" x0="%d" x1="%d" y0="%d" y1="%d"/>""" % (offset[0],offset[0]+textsize[0],offset[1],offset[1]+textsize[1]) - if self.menu_count > 1: - prev_page_text = "<<<" - textsize = draw_bg.textsize(prev_page_text, font=fonts[1]) - offset = ( 2*s_left, s_top + ( self.job.titles_per_menu * rowheight ) ) - draw_bg.text(offset, prev_page_text, fill=self.Menus.color_button, font=fonts[1]) - draw_high.text(offset, prev_page_text, fill=1, font=fonts[1]) - spuxml += """ - <button name="button_prev" x0="%d" x1="%d" y0="%d" y1="%d"/>""" % (offset[0],offset[0]+textsize[0],offset[1],offset[1]+textsize[1]) - del draw_bg - del draw_high - fd=open(self.menubgpngfilename,"w") - im_bg.save(fd,"PNG") - fd.close() - fd=open(self.highlightpngfilename,"w") - im_high.save(fd,"PNG") - fd.close() + #try: + import ImageDraw, Image, os + s = self.job.project.menutemplate.settings + s_top = s.margin_top.getValue() + s_bottom = s.margin_bottom.getValue() + s_left = s.margin_left.getValue() + s_right = s.margin_right.getValue() + s_rows = s.space_rows.getValue() + s_cols = s.space_cols.getValue() + nr_cols = s.cols.getValue() + nr_rows = s.rows.getValue() + thumb_size = s.thumb_size.getValue() + if thumb_size[0]: + from Image import open as Image_open + (s_width, s_height) = s.dimensions.getValue() + fonts = self.Menus.fonts + im_bg = self.Menus.im_bg_orig.copy() + im_high = Image.new("P", (s_width, s_height), 0) + im_high.putpalette(self.Menus.spu_palette) + draw_bg = ImageDraw.Draw(im_bg) + draw_high = ImageDraw.Draw(im_high) + if self.menu_count == 1: + headlineText = self.job.project.settings.name.getValue().decode("utf-8") + headlinePos = self.getPosition(s.offset_headline.getValue(), 0, 0, s_width, s_top, draw_bg.textsize(headlineText, font=fonts[0])) + draw_bg.text(headlinePos, headlineText, fill=self.Menus.color_headline, font=fonts[0]) + spuxml = """<?xml version="1.0" encoding="utf-8"?> + <subpictures> + <stream> + <spu + highlight="%s" + transparent="%02x%02x%02x" + start="00:00:00.00" + force="yes" >""" % (self.highlightpngfilename, self.Menus.spu_palette[0], self.Menus.spu_palette[1], self.Menus.spu_palette[2]) + #rowheight = (self.Menus.fontsizes[1]+self.Menus.fontsizes[2]+thumb_size[1]+s_rows) + menu_start_title = (self.menu_count-1)*self.job.titles_per_menu + 1 + menu_end_title = (self.menu_count)*self.job.titles_per_menu + 1 + nr_titles = len(self.job.project.titles) + if menu_end_title > nr_titles: + menu_end_title = nr_titles+1 + col = 1 + row = 1 + for title_no in range( menu_start_title , menu_end_title ): + title = self.job.project.titles[title_no-1] + col_width = ( s_width - s_left - s_right ) / nr_cols + row_height = ( s_height - s_top - s_bottom ) / nr_rows + left = s_left + ( (col-1) * col_width ) + s_cols/2 + right = left + col_width - s_cols + top = s_top + ( (row-1) * row_height) + s_rows/2 + bottom = top + row_height - s_rows + width = right - left + height = bottom - top + + if bottom > s_height: + bottom = s_height + #draw_bg.rectangle((left, top, right, bottom), outline=(255,0,0)) + im_cell_bg = Image.new("RGBA", (width, height),(0,0,0,0)) + draw_cell_bg = ImageDraw.Draw(im_cell_bg) + im_cell_high = Image.new("P", (width, height), 0) + im_cell_high.putpalette(self.Menus.spu_palette) + draw_cell_high = ImageDraw.Draw(im_cell_high) + + if thumb_size[0]: + thumbPos = self.getPosition(s.offset_thumb.getValue(), 0, 0, width, height, thumb_size) + box = (thumbPos[0], thumbPos[1], thumbPos[0]+thumb_size[0], thumbPos[1]+thumb_size[1]) + try: + thumbIm = Image_open(title.inputfile.rsplit('.',1)[0] + ".png") + im_cell_bg.paste(thumbIm,thumbPos) + except: + draw_cell_bg.rectangle(box, fill=(64,127,127,127)) + border = s.thumb_border.getValue() + if border: + draw_cell_high.rectangle(box, fill=1) + draw_cell_high.rectangle((box[0]+border, box[1]+border, box[2]-border, box[3]-border), fill=0) + + titleText = title.formatDVDmenuText(s.titleformat.getValue(), title_no).decode("utf-8") + titlePos = self.getPosition(s.offset_title.getValue(), 0, 0, width, height, draw_bg.textsize(titleText, font=fonts[1])) + + draw_cell_bg.text(titlePos, titleText, fill=self.Menus.color_button, font=fonts[1]) + draw_cell_high.text(titlePos, titleText, fill=1, font=self.Menus.fonts[1]) + + subtitleText = title.formatDVDmenuText(s.subtitleformat.getValue(), title_no).decode("utf-8") + subtitlePos = self.getPosition(s.offset_subtitle.getValue(), 0, 0, width, height, draw_cell_bg.textsize(subtitleText, font=fonts[2])) + draw_cell_bg.text(subtitlePos, subtitleText, fill=self.Menus.color_button, font=fonts[2]) + + del draw_cell_bg + del draw_cell_high + im_bg.paste(im_cell_bg,(left, top, right, bottom), mask=im_cell_bg) + im_high.paste(im_cell_high,(left, top, right, bottom)) + spuxml += """ - </spu> - </stream> - </subpictures>""" - - f = open(self.spuxmlfilename, "w") - f.write(spuxml) - f.close() - Task.processFinished(self, 0) - except: - Task.processFinished(self, 1) + <button name="button%s" x0="%d" x1="%d" y0="%d" y1="%d"/>""" % (str(title_no).zfill(2),left,right,top,bottom ) + if col < nr_cols: + col += 1 + else: + col = 1 + row += 1 + + top = s_height - s_bottom - s_rows/2 + if self.menu_count < self.job.nr_menus: + next_page_text = s.next_page_text.getValue().decode("utf-8") + textsize = draw_bg.textsize(next_page_text, font=fonts[1]) + pos = ( s_width-textsize[0]-s_right, top ) + draw_bg.text(pos, next_page_text, fill=self.Menus.color_button, font=fonts[1]) + draw_high.text(pos, next_page_text, fill=1, font=fonts[1]) + spuxml += """ + <button name="button_next" x0="%d" x1="%d" y0="%d" y1="%d"/>""" % (pos[0],pos[0]+textsize[0],pos[1],pos[1]+textsize[1]) + if self.menu_count > 1: + prev_page_text = s.prev_page_text.getValue().decode("utf-8") + textsize = draw_bg.textsize(prev_page_text, font=fonts[1]) + pos = ( (s_left+s_cols/2), top ) + draw_bg.text(pos, prev_page_text, fill=self.Menus.color_button, font=fonts[1]) + draw_high.text(pos, prev_page_text, fill=1, font=fonts[1]) + spuxml += """ + <button name="button_prev" x0="%d" x1="%d" y0="%d" y1="%d"/>""" % (pos[0],pos[0]+textsize[0],pos[1],pos[1]+textsize[1]) + del draw_bg + del draw_high + fd=open(self.menubgpngfilename,"w") + im_bg.save(fd,"PNG") + fd.close() + fd=open(self.highlightpngfilename,"w") + im_high.save(fd,"PNG") + fd.close() + spuxml += """ + </spu> + </stream> + </subpictures>""" + + f = open(self.spuxmlfilename, "w") + f.write(spuxml) + f.close() + Task.processFinished(self, 0) + #except: + #Task.processFinished(self, 1) + + def getPosition(self, offset, left, top, right, bottom, size): + pos = [left, top] + if offset[0] != -1: + pos[0] += offset[0] + else: + pos[0] += ( (right-left) - size[0] ) / 2 + if offset[1] != -1: + pos[1] += offset[1] + else: + pos[1] += ( (bottom-top) - size[1] ) / 2 + return tuple(pos) class Menus: def __init__(self, job): self.job = job job.Menus = self - - s = self.job.project.settings - self.imgwidth = 720 - self.imgheight = 576 + s = self.job.project.menutemplate.settings self.color_headline = tuple(s.color_headline.getValue()) self.color_button = tuple(s.color_button.getValue()) @@ -580,10 +640,9 @@ class Menus: ImagePrepareTask(job) nr_titles = len(job.project.titles) - if nr_titles < 6: - job.titles_per_menu = 5 - else: - job.titles_per_menu = 4 + + job.titles_per_menu = s.cols.getValue()*s.rows.getValue() + job.nr_menus = ((nr_titles+job.titles_per_menu-1)/job.titles_per_menu) #a new menu_count every 4 titles (1,2,3,4->1 ; 5,6,7,8->2 etc.) diff --git a/lib/python/Plugins/Extensions/DVDBurn/ProjectSettings.py b/lib/python/Plugins/Extensions/DVDBurn/ProjectSettings.py index b77383cf..85d81706 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/ProjectSettings.py +++ b/lib/python/Plugins/Extensions/DVDBurn/ProjectSettings.py @@ -26,7 +26,10 @@ class FileBrowser(Screen, HelpableScreen): currDir = "/" if self.scope == "project": currDir = self.getDir() - pattern = "(?i)^.*\.(ddvdp\.xml)" + pattern = "(?i)^.*\.(ddvdp\.xml)" + elif self.scope == "menutemplate": + currDir = self.getDir() + pattern = "(?i)^.*\.(ddvdm\.xml)" if self.scope == "menubg": currDir = self.getDir(settings.menubg) pattern = "(?i)^.*\.(jpeg|jpg|jpe|png|bmp)" @@ -137,16 +140,17 @@ class ProjectSettings(Screen,ConfigListScreen): if output == "iso": self.list.append(getConfigListEntry(_("ISO path"), self.settings.isopath)) if authormode.startswith("menu"): - self.list.append(getConfigListEntry(_("Menu")+' '+_("background image"), self.settings.menubg)) - self.list.append(getConfigListEntry(_("Menu")+' '+_("Title"), self.settings.titleformat)) - self.list.append(getConfigListEntry(_("Menu")+' '+_("Subtitles"), self.settings.subtitleformat)) - self.list.append(getConfigListEntry(_("Menu")+' '+_("headline")+' '+_("color"), self.settings.color_headline)) - self.list.append(getConfigListEntry(_("Menu")+' '+_("text")+' '+_("color"), self.settings.color_button)) - self.list.append(getConfigListEntry(_("Menu")+' '+_("highlighted button")+' '+_("color"), self.settings.color_highlight)) - self.list.append(getConfigListEntry(_("Menu")+' '+_("font face"), self.settings.font_face)) - self.list.append(getConfigListEntry(_("Font size")+' ('+_("headline")+', '+_("Title")+', '+_("Subtitles")+')', self.settings.font_size)) - self.list.append(getConfigListEntry(_("Menu")+' '+_("spaces (top, between rows, left)"), self.settings.space)) - self.list.append(getConfigListEntry(_("Menu")+' '+_("Audio"), self.settings.menuaudio)) + self.list.append(getConfigListEntry(_("Menu")+' '+_("template file"), self.settings.menutemplate)) + self.list.append(getConfigListEntry(_("Menu")+' '+_("Title"), self.project.menutemplate.settings.titleformat)) + self.list.append(getConfigListEntry(_("Menu")+' '+_("Subtitles"), self.project.menutemplate.settings.subtitleformat)) + self.list.append(getConfigListEntry(_("Menu")+' '+_("background image"), self.project.menutemplate.settings.menubg)) + #self.list.append(getConfigListEntry(_("Menu")+' '+_("headline")+' '+_("color"), self.settings.color_headline)) + #self.list.append(getConfigListEntry(_("Menu")+' '+_("text")+' '+_("color"), self.settings.color_button)) + #self.list.append(getConfigListEntry(_("Menu")+' '+_("highlighted button")+' '+_("color"), self.settings.color_highlight)) + #self.list.append(getConfigListEntry(_("Menu")+' '+_("font face"), self.settings.font_face)) + #self.list.append(getConfigListEntry(_("Font size")+' ('+_("headline")+', '+_("Title")+', '+_("Subtitles")+')', self.settings.font_size)) + #self.list.append(getConfigListEntry(_("Menu")+' '+_("spaces (top, between rows, left)"), self.settings.space)) + #self.list.append(getConfigListEntry(_("Menu")+' '+_("Audio"), self.settings.menuaudio)) if authormode != "data_ts": self.list.append(getConfigListEntry(_("Titleset mode"), self.settings.titlesetmode)) if self.settings.titlesetmode.getValue() == "single" or authormode == "just_linked": @@ -198,8 +202,16 @@ class ProjectSettings(Screen,ConfigListScreen): self.session.open(MessageBox,text,type = MessageBox.TYPE_ERROR) def FileBrowserClosed(self, path, scope): + if scope == "menutemplate": + if not self.project.menutemplate.loadTemplate(path): + self.session.open(MessageBox,self.project.error,MessageBox.TYPE_ERROR) + else: + print "[ProjectSettings] menu template loaded" + if scope in self.project.filekeys: self.settings.dict()[scope].setValue(path) elif scope == "project": if not self.project.loadProject(path): self.session.open(MessageBox,self.project.error,MessageBox.TYPE_ERROR) + else: + self.initConfigList() diff --git a/lib/python/Plugins/Extensions/DVDBurn/Text menu boat.ddvdm.xml b/lib/python/Plugins/Extensions/DVDBurn/Text menu boat.ddvdm.xml new file mode 100644 index 00000000..0de7f4b6 --- /dev/null +++ b/lib/python/Plugins/Extensions/DVDBurn/Text menu boat.ddvdm.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="utf-8" ?> +<DreamDVDBurnMenu> + <settings + titleformat="$i. $t" + subtitleformat="$D.$M.$Y, $T $C, $d" + menubg="/usr/lib/enigma2/python/Plugins/Extensions/DVDBurn/dreamdvd_boat.jpg" + menuaudio="/usr/lib/enigma2/python/Plugins/Extensions/DVDBurn/silence.mp2" + dimensions="(720, 576)" + rows="5" + cols="1" + color_button="[8, 0, 0]" + color_highlight="[0, 192, 192]" + color_headline="[0, 0, 128]" + fontface_headline="/usr/share/fonts/nmsbd.ttf" + fontface_title="/usr/share/fonts/nmsbd.ttf" + fontface_subtitle="/usr/share/fonts/nmsbd.ttf" + fontsize_headline="46" + fontsize_title="24" + fontsize_subtitle="14" + margin_left="56" + margin_right="56" + margin_top="100" + margin_bottom="70" + space_rows="30" + space_cols="40" + offset_headline="(-1, 40)" + offset_title="(0, 0)" + offset_subtitle="(0, 32)" + offset_thumb="(0, 0)" + thumb_size="(0, 0)" + thumb_border="0" + prev_page_text="«««" + next_page_text="»»»" + /> +</DreamDVDBurnMenu> diff --git a/lib/python/Plugins/Extensions/DVDBurn/Thumbs menu clouds.ddvdm.xml b/lib/python/Plugins/Extensions/DVDBurn/Thumbs menu clouds.ddvdm.xml new file mode 100644 index 00000000..c00c3fee --- /dev/null +++ b/lib/python/Plugins/Extensions/DVDBurn/Thumbs menu clouds.ddvdm.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="utf-8" ?> +<DreamDVDBurnMenu> + <settings + titleformat="$t" + subtitleformat="$d" + menubg="/usr/lib/enigma2/python/Plugins/Extensions/DVDBurn/dreamdvd_clouds.jpg" + menuaudio="/usr/lib/enigma2/python/Plugins/Extensions/DVDBurn/silence.mp2" + dimensions="(720, 576)" + rows="2" + cols="2" + color_button="[8, 0, 0]" + color_highlight="[128, 0, 0]" + color_headline="[128, 0, 0]" + fontface_headline="/usr/share/fonts/nmsbd.ttf" + fontface_title="/usr/share/fonts/nmsbd.ttf" + fontface_subtitle="/usr/share/fonts/nmsbd.ttf" + fontsize_headline="46" + fontsize_title="18" + fontsize_subtitle="12" + margin_left="48" + margin_right="48" + margin_top="100" + margin_bottom="48" + space_rows="24" + space_cols="24" + offset_headline="(-1, 40)" + offset_title="(-1, 144)" + offset_subtitle="(-1, 164)" + offset_thumb="(-1, 0)" + thumb_size="(180, 144)" + thumb_border="2" + prev_page_text="«««" + next_page_text="»»»" + /> +</DreamDVDBurnMenu> diff --git a/lib/python/Plugins/Extensions/DVDBurn/TitleCutter.py b/lib/python/Plugins/Extensions/DVDBurn/TitleCutter.py index 210a3d58..61152e8a 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/TitleCutter.py +++ b/lib/python/Plugins/Extensions/DVDBurn/TitleCutter.py @@ -1,6 +1,7 @@ from Plugins.Extensions.CutListEditor.plugin import CutListEditor from Components.ServiceEventTracker import ServiceEventTracker from enigma import iPlayableService, iServiceInformation +from Tools.Directories import fileExists class TitleCutter(CutListEditor): def __init__(self, session, t): @@ -46,7 +47,12 @@ class TitleCutter(CutListEditor): self.t.properties.aspect.setValue(aspect) self.t.VideoType = service.info().getInfo(iServiceInformation.sVideoType) + def checkAndGrabThumb(self): + if not fileExists(self.t.inputfile.rsplit('.',1)[0] + ".png"): + CutListEditor.grabFrame(self) + def exit(self): + self.checkAndGrabThumb() self.session.nav.stopService() self.close(self.cut_list[:]) @@ -56,4 +62,5 @@ class CutlistReader(TitleCutter): def getPMTInfo(self): TitleCutter.getPMTInfo(self) + TitleCutter.checkAndGrabThumb(self) self.close(self.cut_list[:]) diff --git a/lib/python/Plugins/Extensions/DVDBurn/TitleList.py b/lib/python/Plugins/Extensions/DVDBurn/TitleList.py index 537da0dd..dfb037cc 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/TitleList.py +++ b/lib/python/Plugins/Extensions/DVDBurn/TitleList.py @@ -190,8 +190,8 @@ class TitleList(Screen, HelpableScreen): self["title_label"].text = _("Table of content for collection") + " \"" + self.project.settings.name.getValue() + "\":" def loadTemplate(self): - filename = resolveFilename(SCOPE_PLUGINS)+"Extensions/DVDBurn/DreamboxDVDtemplate.ddvdp.xml" - if self.project.loadProject(filename): + filename = resolveFilename(SCOPE_PLUGINS)+"Extensions/DVDBurn/DreamboxDVD.ddvdp.xml" + if self.project.load(filename): self["error_label"].hide() return True else: diff --git a/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py b/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py index d5ba6c16..63ae6c1f 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py +++ b/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py @@ -8,10 +8,12 @@ from Components.Sources.List import List from Components.Sources.StaticText import StaticText from Components.Sources.Progress import Progress from Components.FileList import FileList -from enigma import eListboxPythonMultiContent, gFont, RT_HALIGN_LEFT +from Components.Pixmap import Pixmap +from enigma import eListboxPythonMultiContent, gFont, RT_HALIGN_LEFT, ePicLoad from Tools.Directories import fileExists, resolveFilename, SCOPE_PLUGINS, SCOPE_FONTS, SCOPE_HDD from Components.config import config, getConfigListEntry, ConfigInteger, ConfigSubsection, ConfigSelection from Components.ConfigList import ConfigListScreen +from Components.AVSwitch import AVSwitch import DVDTitle class TitleProperties(Screen,ConfigListScreen): @@ -23,9 +25,9 @@ class TitleProperties(Screen,ConfigListScreen): <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" /> <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" /> <widget source="key_blue" render="Label" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" /> - <widget name="config" position="10,50" size="540,300" scrollbarMode="showOnDemand" /> - <widget source="serviceinfo_headline" render="Label" position="20,360" size="520,20" font="Regular;20" /> - <widget source="serviceinfo" render="Label" position="20,382" size="520,66" font="Regular;16" /> + <widget source="serviceinfo" render="Label" position="10,46" size="350,144" font="Regular;18" /> + <widget name="thumbnail" position="370,46" size="180,144" alphatest="on" /> + <widget name="config" position="10,206" size="540,228" scrollbarMode="showOnDemand" /> </screen>""" def __init__(self, session, parent, project, title_idx): @@ -37,9 +39,12 @@ class TitleProperties(Screen,ConfigListScreen): self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText(_("OK")) self["key_blue"] = StaticText(_("Edit Title")) - self["serviceinfo_headline"] = StaticText("DVB info:") self["serviceinfo"] = StaticText() + self["thumbnail"] = Pixmap() + self.picload = ePicLoad() + self.picload.PictureData.get().append(self.paintThumbPixmapCB) + self.properties = project.titles[title_idx].properties ConfigListScreen.__init__(self, []) self.properties.crop = DVDTitle.ConfigFixedText("crop") @@ -47,8 +52,6 @@ class TitleProperties(Screen,ConfigListScreen): self.properties.aspect.addNotifier(self.initConfigList) for audiotrack in self.properties.audiotracks: audiotrack.active.addNotifier(self.initConfigList) - - self.initConfigList() self["setupActions"] = ActionMap(["SetupActions", "ColorActions"], { @@ -58,6 +61,8 @@ class TitleProperties(Screen,ConfigListScreen): "cancel": self.cancel, "ok": self.ok, }, -2) + + self.onShown.append(self.update) def initConfigList(self, element=None): try: @@ -79,18 +84,15 @@ class TitleProperties(Screen,ConfigListScreen): self.list.append(getConfigListEntry("DVD " + "widescreen", self.properties.widescreen)) else: self.list.append(getConfigListEntry("DVD " + "widescreen", self.properties.crop)) - - infotext = _("Available format variables") + ":\n$i=" + _("Track") + ", $t=" + _("Title") + ", $d=" + _("Description") + ", $l=" + _("length") + ", $c=" + _("chapters") + ",\n" + _("Record") + " $T=" + _("Begin time") + ", $Y=" + _("year") + ", $M=" + _("month") + ", $D=" + _("day") + ",\n$A=" + _("audio tracks") + ", $C=" + _("Channel") + ", $f=" + _("filename") - self["info"] = StaticText(infotext) - + if len(title.chaptermarks) == 0: self.list.append(getConfigListEntry(_("Auto chapter split every ? minutes (0=never)"), self.properties.autochapter)) - infotext = _("Title") + ': ' + title.DVBname + "\n" + _("Description") + ': ' + title.DVBdescr + "\n" + _("Channel") + ': ' + title.DVBchannel + infotext = "DVB " + _("Title") + ': ' + title.DVBname + "\n" + _("Description") + ': ' + title.DVBdescr + "\n" + _("Channel") + ': ' + title.DVBchannel + '\n' + _("Begin time") + title.formatDVDmenuText(": $D.$M.$Y, $T\n", self.title_idx+1) chaptermarks = title.getChapterMarks(template="$h:$m:$s") chapters_count = len(chaptermarks) if chapters_count >= 1: - infotext += ', ' + str(chapters_count+1) + ' ' + _("chapters") + ' (' - infotext += ' / '.join(chaptermarks) + ')' + infotext += '\n' + str(chapters_count+1) + ' ' + _("chapters") + ': ' + infotext += ' / '.join(chaptermarks) self["serviceinfo"].setText(infotext) self["config"].setList(self.list) except AttributeError: @@ -98,7 +100,22 @@ class TitleProperties(Screen,ConfigListScreen): def editTitle(self): self.parent.editTitle() + + def update(self): + print "[onShown]" self.initConfigList() + self.loadThumb() + + def loadThumb(self): + thumbfile = self.project.titles[self.title_idx].inputfile.rsplit('.',1)[0] + ".png" + sc = AVSwitch().getFramebufferScale() + self.picload.setPara((self["thumbnail"].instance.size().width(), self["thumbnail"].instance.size().height(), sc[0], sc[1], False, 1, "#00000000")) + self.picload.startDecode(thumbfile) + + def paintThumbPixmapCB(self, picInfo=None): + ptr = self.picload.getData() + if ptr != None: + self["thumbnail"].instance.setPixmap(ptr.__deref__()) def changedConfigList(self): self.initConfigList() diff --git a/lib/python/Plugins/Extensions/DVDBurn/dreamdvd_clouds.jpg b/lib/python/Plugins/Extensions/DVDBurn/dreamdvd_clouds.jpg Binary files differnew file mode 100644 index 00000000..aacf25d0 --- /dev/null +++ b/lib/python/Plugins/Extensions/DVDBurn/dreamdvd_clouds.jpg diff --git a/lib/python/Plugins/Extensions/DVDBurn/dvdburn.png b/lib/python/Plugins/Extensions/DVDBurn/dvdburn.png Binary files differindex 7e7adead..7e7adead 100755..100644 --- a/lib/python/Plugins/Extensions/DVDBurn/dvdburn.png +++ b/lib/python/Plugins/Extensions/DVDBurn/dvdburn.png |
