Skip to content

Commit

Permalink
ChannelSection: When width 0 and no picon give full channel name instead
Browse files Browse the repository at this point in the history
  • Loading branch information
littlesat authored and Andy Blackburn committed Oct 17, 2014
1 parent ab9deca commit 20f2276
Showing 1 changed file with 40 additions and 34 deletions.
74 changes: 40 additions & 34 deletions lib/service/listboxservice.cpp
Expand Up @@ -709,10 +709,30 @@ void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const

eRect tmp = area;
int xoffs = 0;
ePtr<gPixmap> piconPixmap;

if (e == celServiceName)
{
//picon stuff
if (isPlayable && PyCallable_Check(m_GetPiconNameFunc))
{
ePyObject pArgs = PyTuple_New(1);
PyTuple_SET_ITEM(pArgs, 0, PyString_FromString(ref.toString().c_str()));
ePyObject pRet = PyObject_CallObject(m_GetPiconNameFunc, pArgs);
Py_DECREF(pArgs);
if (pRet)
{
if (PyString_Check(pRet))
{
std::string piconFilename = PyString_AS_STRING(pRet);
if (!piconFilename.empty())
loadPNG(piconPixmap, piconFilename.c_str());
}
Py_DECREF(pRet);
}
}
xoffs = xoffset;
tmp.setWidth(((!isPlayable || m_column_width == -1) ? tmp.width() : m_column_width) - xoffs);
tmp.setWidth(((!isPlayable || m_column_width == -1 || (!piconPixmap && !m_column_width)) ? tmp.width() : m_column_width) - xoffs);
}

eTextPara *para = new eTextPara(tmp);
Expand All @@ -723,7 +743,7 @@ void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const
{
eRect bbox = para->getBoundBox();

int servicenameWidth = ((!isPlayable || m_column_width == -1) ? bbox.width() : m_column_width);
int servicenameWidth = ((!isPlayable || m_column_width == -1 || (!piconPixmap && !m_column_width)) ? bbox.width() : m_column_width);
m_element_position[celServiceInfo].setLeft(area.left() + servicenameWidth + 8 + xoffs);
m_element_position[celServiceInfo].setTop(area.top());
m_element_position[celServiceInfo].setWidth(area.width() - (servicenameWidth + 8 + xoffs));
Expand All @@ -735,41 +755,27 @@ void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const
if (PyCallable_Check(m_GetPiconNameFunc))
{
eRect area = m_element_position[celServiceInfo];
/* PIcons are usually about 100:60. Make it a
* bit wider in case the icons are diffently
* shaped, and to add a bit of margin between
* icon and text. */
const int iconWidth = area.height() * 9 / 5;
m_element_position[celServiceInfo].setLeft(area.left() + iconWidth);
m_element_position[celServiceInfo].setWidth(area.width() - iconWidth);
area = m_element_position[celServiceName];
xoffs += iconWidth;
ePyObject pArgs = PyTuple_New(1);
PyTuple_SET_ITEM(pArgs, 0, PyString_FromString(ref.toString().c_str()));
ePyObject pRet = PyObject_CallObject(m_GetPiconNameFunc, pArgs);
Py_DECREF(pArgs);
if (pRet)
if (m_column_width || piconPixmap)
{
if (PyString_Check(pRet))
/* PIcons are usually about 100:60. Make it a
* bit wider in case the icons are diffently
* shaped, and to add a bit of margin between
* icon and text. */
const int iconWidth = area.height() * 9 / 5;
m_element_position[celServiceInfo].setLeft(area.left() + iconWidth);
m_element_position[celServiceInfo].setWidth(area.width() - iconWidth);
area = m_element_position[celServiceName];
xoffs += iconWidth;
if (piconPixmap)
{
std::string piconFilename = PyString_AS_STRING(pRet);
if (!piconFilename.empty())
{
ePtr<gPixmap> piconPixmap;
loadPNG(piconPixmap, piconFilename.c_str());
if (piconPixmap)
{
area.moveBy(offset);
painter.clip(area);
painter.blitScale(piconPixmap,
eRect(area.left(), area.top(), iconWidth, area.height()),
area,
gPainter::BT_ALPHABLEND | gPainter::BT_KEEP_ASPECT_RATIO);
painter.clippop();
}
}
area.moveBy(offset);
painter.clip(area);
painter.blitScale(piconPixmap,
eRect(area.left(), area.top(), iconWidth, area.height()),
area,
gPainter::BT_ALPHABLEND | gPainter::BT_KEEP_ASPECT_RATIO);
painter.clippop();
}
Py_DECREF(pRet);
}
}

Expand Down

0 comments on commit 20f2276

Please sign in to comment.