From: Felix Domke Date: Fri, 24 Feb 2006 22:31:39 +0000 (+0000) Subject: add cutlist support to position gauge X-Git-Tag: 2.6.0~4000 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/6db80bf969c97136e1d83db775b6f6cb68b2a614 add cutlist support to position gauge --- diff --git a/lib/gui/epositiongauge.cpp b/lib/gui/epositiongauge.cpp index e16d2226..75b592d2 100644 --- a/lib/gui/epositiongauge.cpp +++ b/lib/gui/epositiongauge.cpp @@ -22,6 +22,7 @@ void ePositionGauge::setLength(const pts_t &len) return; m_length = len; updatePosition(); + invalidate(); } void ePositionGauge::setPosition(const pts_t &pos) @@ -46,6 +47,35 @@ void ePositionGauge::setPointer(gPixmap *pixmap, const ePoint ¢er) 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; ipaintBackground(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::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)); @@ -88,14 +150,19 @@ int ePositionGauge::event(int event, void *data, void *data2) } 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; } diff --git a/lib/gui/epositiongauge.h b/lib/gui/epositiongauge.h index 6f72fe80..0fa704c3 100644 --- a/lib/gui/epositiongauge.h +++ b/lib/gui/epositiongauge.h @@ -2,6 +2,7 @@ #define __lib_gui_epositiongauge_h #include +#include typedef long long pts_t; @@ -17,6 +18,8 @@ public: 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); @@ -31,6 +34,25 @@ private: 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 m_cue_entries; + int scale(const pts_t &val); #endif };