return;
m_length = len;
updatePosition();
+ invalidate();
}
void ePositionGauge::setPosition(const pts_t &pos)
updatePosition();
}
+void ePositionGauge::setInOutList(PyObject *list)
+{
+ if (!PyList_Check(list))
+ return;
+ int size = PyList_Size(list);
+ int i;
+
+ m_cue_entries.clear();
+
+ for (i=0; i<size; ++i)
+ {
+ PyObject *tuple = PyList_GetItem(list, i);
+ if (!PyTuple_Check(tuple))
+ continue;
+
+ if (PyTuple_Size(tuple) != 2)
+ continue;
+
+ PyObject *ppts = PyTuple_GetItem(tuple, 0), *ptype = PyTuple_GetItem(tuple, 1);
+ if (!(PyLong_Check(ppts) && PyInt_Check(ptype)))
+ continue;
+
+ pts_t pts = PyLong_AsLongLong(ppts);
+ int type = PyInt_AsLong(ptype);
+ m_cue_entries.insert(cueEntry(pts, type));
+ }
+ invalidate();
+}
+
int ePositionGauge::event(int event, void *data, void *data2)
{
switch (event)
getStyle(style);
style->paintBackground(painter, ePoint(0,0), s);
style->setStyle(painter, eWindowStyle::styleLabel); // TODO - own style
- painter.setForegroundColor(gRGB(0x225b7395));
-
- painter.fill(eRect(0, 10, s.width(), s.height()-14));
+// painter.fill(eRect(0, 10, s.width(), s.height()-20));
+ pts_t in = 0, out = 0;
+
+ std::multiset<cueEntry>::iterator i(m_cue_entries.begin());
+
+ while (1)
+ {
+ if (i == m_cue_entries.end())
+ out = m_length;
+ else {
+ if (i->what == 0) /* in */
+ {
+ in = i++->where;
+ continue;
+ } else if (i->what == 1) /* out */
+ out = i++->where;
+ else /* mark */
+ {
+ int xm = scale(i->where);
+ painter.setForegroundColor(gRGB(0xFF8080));
+ painter.fill(eRect(xm - 2, 0, 4, s.height()));
+ i++;
+ continue;
+ }
+ }
+
+ painter.setForegroundColor(gRGB(0x225b7395));
+ int xi = scale(in), xo = scale(out);
+ painter.fill(eRect(xi, 10, xo-xi, s.height()-14));
+ in = m_length;
+
+ if (i == m_cue_entries.end())
+ break;
+ }
// painter.setForegroundColor(gRGB(0x00000000));
+ painter.setForegroundColor(gRGB(0x225b7395));
painter.fill(eRect(s.width() - 2, 2, s.width() - 1, s.height() - 4));
painter.fill(eRect(0, 2, 2, s.height() - 4));
}
void ePositionGauge::updatePosition()
+{
+ m_pos = scale(m_position);
+ int base = (size().height() - 10) / 2;
+
+ m_point_widget->move(ePoint(m_pos - m_point_center.x(), base - m_point_center.y()));
+}
+
+int ePositionGauge::scale(const pts_t &val)
{
if (!m_length)
- return;
+ return 0;
int width = size().width();
- int x = width * m_position / m_length;
- m_pos = x;
- int base = (size().height() - 10) / 2;
- m_point_widget->move(ePoint(m_pos - m_point_center.x(), base - m_point_center.y()));
+ return width * val / m_length;
}
#define __lib_gui_epositiongauge_h
#include <lib/gui/ewidget.h>
+#include <set>
typedef long long pts_t;
void setInColor(const gRGB &color); /* foreground? */
void setPointer(gPixmap *pixmap, const ePoint ¢er);
+
+ void setInOutList(PyObject *list);
#ifndef SWIG
protected:
int event(int event, void *data=0, void *data2=0);
pts_t m_position, m_length;
int m_pos;
+
+ /* TODO: this is duplicated code from lib/service/servicedvb.h */
+ struct cueEntry
+ {
+ pts_t where;
+ unsigned int what;
+
+ bool operator < (const struct cueEntry &o) const
+ {
+ return what < o.what;
+ }
+ cueEntry(const pts_t &where, unsigned int what) :
+ where(where), what(what)
+ {
+ }
+ };
+
+ std::multiset<cueEntry> m_cue_entries;
+ int scale(const pts_t &val);
#endif
};