Skip to content

Commit

Permalink
Merge pull request OpenPLi#3644 from Huevos/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
littlesat authored Mar 11, 2023
2 parents 8a2b36d + d714a16 commit e52b876
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 39 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ lib/Makefile
lib/base/eenv.cpp
lib/python/Makefile
lib/python/Components/Makefile
lib/python/Components/Addons/Makefile
lib/python/Components/Converter/Makefile
lib/python/Components/Renderer/Makefile
lib/python/Components/Sources/Makefile
Expand Down
24 changes: 17 additions & 7 deletions lib/gui/elistbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,21 @@ eListbox::eListbox(eWidget *parent) :
eWidget(parent), m_scrollbar_mode(showNever), m_prev_scrollbar_page(-1),
m_content_changed(false), m_enabled_wrap_around(false), m_scrollbar_width(20),
m_top(0), m_selected(0), m_itemheight(25),
m_items_per_page(0), m_selection_enabled(1), m_scrollbar(nullptr)
m_items_per_page(0), m_selection_enabled(1), m_native_keys_bound(false), m_scrollbar(nullptr)
{
memset(static_cast<void*>(&m_style), 0, sizeof(m_style));
m_style.m_text_offset = ePoint(1,1);
// setContent(new eListboxStringContent());

ePtr<eActionMap> ptr;
eActionMap::getInstance(ptr);
ptr->bindAction("ListboxActions", 0, 0, this);
allowNativeKeys(true);
}

eListbox::~eListbox()
{
if (m_scrollbar)
delete m_scrollbar;

ePtr<eActionMap> ptr;
eActionMap::getInstance(ptr);
ptr->unbindAction(this, 0);
allowNativeKeys(false);
}

void eListbox::setScrollbarMode(int mode)
Expand Down Expand Up @@ -65,6 +61,20 @@ void eListbox::setContent(iListboxContent *content)
entryReset();
}

void eListbox::allowNativeKeys(bool allow)
{
if (m_native_keys_bound != allow)
{
ePtr<eActionMap> ptr;
eActionMap::getInstance(ptr);
if (allow)
ptr->bindAction("ListboxActions", 0, 0, this);
else
ptr->unbindAction(this, 0);
m_native_keys_bound = allow;
}
}

bool eListbox::atBegin()
{
if (m_content && !m_selected)
Expand Down
5 changes: 5 additions & 0 deletions lib/gui/elistbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ class eListbox: public eWidget

void setContent(iListboxContent *content);

void allowNativeKeys(bool allow);

/* enum Movement {
moveUp,
moveDown,
Expand Down Expand Up @@ -190,6 +192,9 @@ class eListbox: public eWidget
int m_itemheight;
int m_items_per_page;
int m_selection_enabled;

bool m_native_keys_bound;

ePtr<iListboxContent> m_content;
eSlider *m_scrollbar;
eListboxStyle m_style;
Expand Down
4 changes: 0 additions & 4 deletions lib/python/Components/Addons/GUIAddon.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ def __init__(self):

def connectRelatedElement(self, relatedElementName, container):
self.source = container[relatedElementName]
self.bindKeys(container)
container.onShow.append(self.onContainerShown)

def onContainerShown(self):
pass

def bindKeys(self, container):
pass
4 changes: 3 additions & 1 deletion lib/python/Components/Addons/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
installdir = $(pkglibdir)/python/Components/Addons

install_PYTHON = *.py
install_PYTHON = \
GUIAddon.py \
Pager.py
47 changes: 21 additions & 26 deletions lib/python/Components/Addons/Pager.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
from Components.Addons.GUIAddon import GUIAddon
from skin import parseColor
import math

from enigma import eListbox, eListboxPythonMultiContent, BT_ALIGN_CENTER
from Tools.LoadPixmap import LoadPixmap

from Tools.Directories import resolveFilename, SCOPE_GUISKIN
from skin import parseScale

from Components.MultiContent import MultiContentEntryPixmapAlphaBlend

from Tools.Directories import resolveFilename, SCOPE_GUISKIN
from Tools.LoadPixmap import LoadPixmap


class Pager(GUIAddon):
def __init__(self):
GUIAddon.__init__(self)
self.l = eListboxPythonMultiContent()
self.l_list = []
self.l.setBuildFunc(self.buildEntry)
self.current_index = 0
self.itemHeight = 25
self.sourceHeight = 25
self.pagerForeground = 15774720
self.pagerBackground = 624318628
self.l.setItemHeight(self.itemHeight)
self.l.setItemHeight(25)
self.spacing = 5
self.picDotPage = LoadPixmap(resolveFilename(SCOPE_GUISKIN, "icons/dot.png"))
self.picDotCurPage = LoadPixmap(resolveFilename(SCOPE_GUISKIN, "icons/dotfull.png"))

Expand Down Expand Up @@ -54,17 +50,18 @@ def buildEntry(self, currentPage, pageCount):
size=(pixd_width, pixd_height),
png=self.picDotCurPage if x == currentPage else self.picDotPage,
backcolor=None, backcolor_sel=None, flags=BT_ALIGN_CENTER))
xPos += pixd_width + 5
xPos += pixd_width + self.spacing
return res

def selChange(self, currentPage, pagesCount):
self.l_list = []
self.l_list.append((currentPage, pagesCount))
self.l.setList(self.l_list)
l_list = []
l_list.append((currentPage, pagesCount))
self.l.setList(l_list)

def postWidgetCreate(self, instance):
instance.setSelectionEnable(False)
instance.setContent(self.l)
instance.allowNativeKeys(False)

def getCurrentIndex(self):
if hasattr(self.source, "index"):
Expand Down Expand Up @@ -95,28 +92,26 @@ def initPager(self):
itemHeight = self.getListItemHeight()
items_per_page = listH//itemHeight
if items_per_page > 0:
currentPageIndex = math.floor(current_index/items_per_page)
pagesCount = math.ceil(listCount/items_per_page) - 1
currentPageIndex = current_index//items_per_page
pagesCount = listCount//items_per_page
self.selChange(currentPageIndex,pagesCount)

def applySkin(self, desktop, parent):
attribs = [ ]
for (attrib, value) in self.skinAttributes:
if attrib == "pagerForeground":
self.pagerForeground = parseColor(value).argb()
elif attrib == "pagerBackground":
self.pagerBackground = parseColor(value).argb()
elif attrib == "picPage":
for (attrib, value) in self.skinAttributes[:]:
if attrib == "picPage":
pic = LoadPixmap(resolveFilename(SCOPE_GUISKIN, value))
if pic:
self.picDotPage = pic
elif attrib == "picPageCurrent":
pic = LoadPixmap(resolveFilename(SCOPE_GUISKIN, value))
if pic:
self.picDotCurPage = pic
elif attrib == "itemHeight":
self.l.setItemHeight(parseScale(value))
elif attrib == "spacing":
self.spacing = parseScale(value)
else:
attribs.append((attrib, value))
self.skinAttributes = attribs
return GUIAddon.applySkin(self, desktop, parent)


return GUIAddon.applySkin(self, desktop, parent)
2 changes: 1 addition & 1 deletion lib/python/Components/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
installdir = $(pkglibdir)/python/Components

SUBDIRS = Sources Converter Renderer
SUBDIRS = Sources Converter Renderer Addons

install_PYTHON = \
ActionMap.py PerServiceDisplay.py \
Expand Down

0 comments on commit e52b876

Please sign in to comment.