From 4621e2ba14ebc9c955e3bf669a5c8799f65f46e1 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Mon, 19 Jan 2009 12:55:27 +0100 Subject: make slider orientation configurable into 4 directions --- lib/gui/eslider.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lib/gui/eslider.cpp') diff --git a/lib/gui/eslider.cpp b/lib/gui/eslider.cpp index dd2aac9e..c8b467c9 100644 --- a/lib/gui/eslider.cpp +++ b/lib/gui/eslider.cpp @@ -70,10 +70,14 @@ int eSlider::event(int event, void *data, void *data2) 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); + int val_range = m_max - m_min; + num_pix = (pixsize * (m_value - m_start) + val_range - 1) / val_range; /* properly round up */ + start_pix = (pixsize * m_start + val_range - 1) / val_range; + + if (m_orientation_swapped) + start_pix = pixsize - num_pix - start_pix; } - + if (start_pix < 0) { num_pix += start_pix; @@ -113,9 +117,10 @@ void eSlider::setStartEnd(int start, int end) event(evtChangedSlider); } -void eSlider::setOrientation(int orientation) +void eSlider::setOrientation(int orientation, int swapped) { m_orientation = orientation; + m_orientation_swapped = swapped; event(evtChangedSlider); } -- cgit v1.2.3 From b27feca502bf6d074800a5c49583f88bb588de05 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Mon, 19 Jan 2009 13:49:58 +0100 Subject: default to non-swapped orientation --- lib/gui/eslider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/gui/eslider.cpp') diff --git a/lib/gui/eslider.cpp b/lib/gui/eslider.cpp index c8b467c9..19097ad4 100644 --- a/lib/gui/eslider.cpp +++ b/lib/gui/eslider.cpp @@ -1,7 +1,7 @@ #include eSlider::eSlider(eWidget *parent) - :eWidget(parent), m_have_border_color(false), m_start(0), m_orientation(orHorizontal), m_border_width(0) + :eWidget(parent), m_have_border_color(false), m_start(0), m_orientation(orHorizontal), m_orientation_swapped(0), m_border_width(0) { } -- cgit v1.2.3