Skip to content

Commit

Permalink
Graphepg movement algorithm (#334)
Browse files Browse the repository at this point in the history
* When moving sideways, only refresh the current row

* Fix EPG crash when not using cached EPG

* Improve performance of graph EPG
  • Loading branch information
SimonCapewell authored and RobvanderDoes committed Nov 27, 2018
1 parent 5120ec8 commit 293b069
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 27 deletions.
57 changes: 34 additions & 23 deletions lib/python/Components/EpgList.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ def __init__(self, type = EPG_TYPE_SINGLE, selChangedCB = None, timer = None, ti
self.l.setBuildFunc(self.buildMultiEntry)
elif type == EPG_TYPE_GRAPH or type == EPG_TYPE_INFOBARGRAPH:
self.l.setBuildFunc(self.buildGraphEntry)
if self.type == EPG_TYPE_GRAPH:
value = config.epgselection.graph_servicetitle_mode.value
elif self.type == EPG_TYPE_INFOBARGRAPH:
value = config.epgselection.infobar_servicetitle_mode.value
self.showServiceNumber = "servicenumber" in value
self.showServiceTitle = "servicename" in value
self.showPicon = "picon" in value
else:
assert(type == EPG_TYPE_SIMILAR)
self.l.setBuildFunc(self.buildSimilarEntry)
Expand Down Expand Up @@ -201,6 +208,7 @@ def __init__(self, type = EPG_TYPE_SINGLE, selChangedCB = None, timer = None, ti
self.eventBorderWidth = 1
self.eventNamePadding = 3
self.NumberOfRows = None
self.serviceNumberWidth = 0

def applySkin(self, desktop, screen):
if self.skinAttributes is not None:
Expand Down Expand Up @@ -294,6 +302,16 @@ def applySkin(self, desktop, screen):
self.listWidth = self.instance.size().width()
self.setItemsPerPage()
self.setFontsize()

# cache service number width
if self.showServiceNumber:
if self.type == EPG_TYPE_GRAPH:
font = gFont(self.serviceFontNameGraph, self.serviceFontSizeGraph + config.epgselection.graph_servfs.value)
self.serviceNumberWidth = getTextBoundarySize(self.instance, font, self.instance.size(), "0000" ).width()
elif self.type == EPG_TYPE_INFOBARGRAPH:
font = gFont(self.serviceFontNameGraph, self.serviceFontSizeGraph + config.epgselection.infobar_servfs.value)
self.serviceNumberWidth = getTextBoundarySize(self.instance, font, self.instance.size(), "0000" ).width()

return rc

def getCurrentChangeCount(self):
Expand All @@ -304,11 +322,6 @@ def getCurrentChangeCount(self):
def isSelectable(self, service, service_name, events, picon, channel):
return (events and len(events) and True) or False

def setShowServiceMode(self, value):
self.showServiceNumber = "servicenumber" in value
self.showServiceTitle = "servicename" in value
self.showPicon = "picon" in value

def setTimeFocus(self, time_focus):
self.time_focus = time_focus

Expand Down Expand Up @@ -364,7 +377,6 @@ def getCurrent(self):
if self.type == EPG_TYPE_GRAPH or self.type == EPG_TYPE_INFOBARGRAPH:
if self.cur_service is None:
return None, None
old_service = self.cur_service #(service, service_name, events, picon)
events = self.cur_service[2]
refstr = self.cur_service[0]
if self.cur_event is None or not events or (self.cur_event and events and self.cur_event > len(events)-1):
Expand Down Expand Up @@ -419,19 +431,20 @@ def setTimeFocusFromEvent(self, cur_event):
cur_service = self.l.getCurrentSelection()
if cur_service:
events = cur_service[2]
self.cur_event = max(min(len(events) - 1, cur_event), 0)
event = events[self.cur_event]

# clip the selected event times to the current screen
time_base = self.getTimeBase()
ev_time = max(time_base, event[2])
ev_end_time = min(event[2] + event[3], time_base + self.time_epoch * 60)
if ev_time <= time() < ev_end_time:
# selected event contains the current time, user is interested in current things
self.time_focus = time()
else:
# user is looking at things roughly around the middle of the selected event
self.time_focus = ev_time + (ev_end_time - ev_time) / 2
if events and len(events):
self.cur_event = max(min(len(events) - 1, cur_event), 0)
event = events[self.cur_event]

# clip the selected event times to the current screen
time_base = self.getTimeBase()
ev_time = max(time_base, event[2])
ev_end_time = min(event[2] + event[3], time_base + self.time_epoch * 60)
if ev_time <= time() < ev_end_time:
# selected event contains the current time, user is interested in current things
self.time_focus = time()
else:
# user is looking at things roughly around the middle of the selected event
self.time_focus = ev_time + (ev_end_time - ev_time) / 2
else:
self.cur_event = None
self.selEntry(0)
Expand Down Expand Up @@ -596,16 +609,14 @@ def recalcEntrySize(self):
if self.showPicon:
piconw = config.epgselection.graph_piconwidth.value
if self.showServiceNumber:
font = gFont(self.serviceFontNameGraph, self.serviceFontSizeGraph + config.epgselection.graph_servfs.value)
channelw = getTextBoundarySize(self.instance, font, self.instance.size(), "0000" ).width()
channelw = self.serviceNumberWidth
elif self.type == EPG_TYPE_INFOBARGRAPH:
if self.showServiceTitle:
servicew = config.epgselection.infobar_servicewidth.value
if self.showPicon:
piconw = config.epgselection.infobar_piconwidth.value
if self.showServiceNumber:
font = gFont(self.serviceFontNameGraph, self.serviceFontSizeGraph + config.epgselection.infobar_servfs.value)
channelw = getTextBoundarySize(self.instance, font, self.instance.size(), "0000" ).width()
channelw = self.serviceNumberWidth
w = (channelw + piconw + servicew)
self.service_rect = Rect(0, 0, w, height)
self.event_rect = Rect(w, 0, width - w, height)
Expand Down
4 changes: 0 additions & 4 deletions lib/python/Screens/EpgSelection.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,6 @@ def onCreate(self):
if self.StartBouquet.toString().startswith('1:7:0'):
self.BouquetRoot = True
self.services = self.getBouquetServices(self.StartBouquet)
if self.type == EPG_TYPE_GRAPH:
self['list'].setShowServiceMode(config.epgselection.graph_servicetitle_mode.value)
elif self.type == EPG_TYPE_INFOBARGRAPH:
self['list'].setShowServiceMode(config.epgselection.infobar_servicetitle_mode.value)
self['list'].fillGraphEPG(self.services, self.ask_time)
self['list'].moveToService(serviceref)
self['list'].setCurrentlyPlaying(serviceref)
Expand Down
3 changes: 3 additions & 0 deletions lib/python/Tools/TextBoundary.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from enigma import eLabel

# Note that calling this function will result in a call to invalidate()
# on the instance object. This can be detrimental to UI performance,
# particularly in a complex screen like the graph EPG
def getTextBoundarySize(instance, font, targetSize, text):
dummy = eLabel(instance)
dummy.setFont(font)
Expand Down

0 comments on commit 293b069

Please sign in to comment.