X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/ba02fb4aced5868d047a5bffbd2ed87583daee4d..033a2333874297c1c388ecf4532de2bc2b11fb30:/lib/gui/eslider.cpp diff --git a/lib/gui/eslider.cpp b/lib/gui/eslider.cpp index 20b3ab47..bf7a5776 100644 --- a/lib/gui/eslider.cpp +++ b/lib/gui/eslider.cpp @@ -1,6 +1,6 @@ #include -eSlider::eSlider(eWidget *parent): eWidget(parent) +eSlider::eSlider(eWidget *parent): eWidget(parent), m_orientation(orHorizontal), m_start(0) { } @@ -13,22 +13,39 @@ int eSlider::event(int event, void *data, void *data2) ePtr style; gPainter &painter = *(gPainter*)data2; - getStyle(style); style->paintBackground(painter, ePoint(0, 0), size()); - style->setForegroundStyle(painter); + style->setStyle(painter, eWindowStyle::styleLabel); // TODO - own style painter.fill(m_currently_filled); return 0; } case evtChangedSlider: { - - int num_pix = 0; - if (m_min < m_max) - num_pix = size().width() * m_value / (m_max - m_min); + int num_pix = 0, start_pix = 0; gRegion old_currently_filled = m_currently_filled; - m_currently_filled = eRect(0, 0, num_pix, size().height()); + + int pixsize = (m_orientation == orHorizontal) ? size().width() : size().height(); + + if (m_min < m_max) + { + num_pix = pixsize * (m_value - m_start) / (m_max - m_min); + start_pix = pixsize * m_start / (m_max - m_min); + } + + if (start_pix < 0) + { + num_pix += start_pix; + start_pix = 0; + } + + if (num_pix < 0) + num_pix = 0; + + if (m_orientation == orHorizontal) + m_currently_filled = eRect(start_pix, 0, num_pix, size().height()); + else + m_currently_filled = eRect(0, start_pix, size().width(), num_pix); // redraw what *was* filled before and now isn't. invalidate(m_currently_filled - old_currently_filled); @@ -48,6 +65,19 @@ void eSlider::setValue(int value) event(evtChangedSlider); } +void eSlider::setStartEnd(int start, int end) +{ + m_value = end; + m_start = start; + event(evtChangedSlider); +} + +void eSlider::setOrientation(int orientation) +{ + m_orientation = orientation; + event(evtChangedSlider); +} + void eSlider::setRange(int min, int max) { m_min = min;