Home » U++ Library support » Slider&ProgressIndicator » Slider with thermometer like scale
|
|
|
Re: Slider with thermometer like scale [message #30089 is a reply to message #30088] |
Wed, 08 December 2010 09:34   |
|
Very pretty!
koldo wrote on Wed, 08 December 2010 02:10 | Hello avpavp and Mirek
I have uploaded to Bazaar/SliderCtrlX the SliderCtrl improved version included by avpavp plus a label formatting function:
Callback2<String&, int> LabelFormat;
For example, if SliderCtrl contains time in seconds, but you want to visualize hour:min:sec format, you would do this:
In the constructor:
slider.LabelFormat = THISBACK(LabelFormatting);
And after that:
void LabelFormatting(String &str, int val) {
str = SecondsToString(val, false);
}
And you would get something like this:

|
|
|
|
|
|
|
|
|
|
|
Re: Slider with thermometer like scale [message #32177 is a reply to message #27646] |
Fri, 29 April 2011 10:37   |
 |
jibe
Messages: 294 Registered: February 2007 Location: France
|
Experienced Member |
|
|
Hi,
If you talk about avpavp, I'm afraid that he doesn't come here anymore... His last visit was on November 10, 2010, almost 6 month.
I think that :
- As avpavp doesn't reply anymore,
- As he put here his code,
- As you put it in bazaar,
- As you made Controls4U, where this enhanced slider could take place,
you should try a last time to contact avpavp by email and consider yourself as main maintener of the package 
For me, I'm busy on other things for now, but I'll try to mix the bazaar version and jerson's one ASAP (I hope to have time in 1 or 2 weeks). I think that there is some good ideas in jerson's version that could easily be included in SliderCtrlX.
|
|
|
Re: Slider with thermometer like scale [message #32197 is a reply to message #32177] |
Sat, 30 April 2011 09:41   |
 |
koldo
Messages: 3432 Registered: August 2008
|
Senior Veteran |
|
|
jibe wrote on Fri, 29 April 2011 10:37 | Hi,
If you talk about avpavp, I'm afraid that he doesn't come here anymore... His last visit was on November 10, 2010, almost 6 month.
I think that :
- As avpavp doesn't reply anymore,
- As he put here his code,
- As you put it in bazaar,
- As you made Controls4U, where this enhanced slider could take place,
you should try a last time to contact avpavp by email and consider yourself as main maintener of the package 
For me, I'm busy on other things for now, but I'll try to mix the bazaar version and jerson's one ASAP (I hope to have time in 1 or 2 weeks). I think that there is some good ideas in jerson's version that could easily be included in SliderCtrlX.
|
Perfect. Prepare the new version and while it waits to be included in main U++, it can be in Controls4U (with the necessary references to the authors ).
Best regards
Iñaki
|
|
|
|
|
Re: Slider with thermometer like scale [message #32364 is a reply to message #27646] |
Fri, 13 May 2011 10:22   |
 |
jibe
Messages: 294 Registered: February 2007 Location: France
|
Experienced Member |
|
|
Hi,
Yes, it's weird... This works well :
JBControlsTest.h :
#ifndef _JBControlsTest_JBControlsTest_h
#define _JBControlsTest_JBControlsTest_h
#include <CtrlLib/CtrlLib.h>
#include <Controls4U/Controls4U.h>
#include <JBControls/SliderCtrlX.h>
using namespace Upp;
class JBControlsTest : public TopWindow {
public:
typedef JBControlsTest CLASSNAME;
JBControlsTest();
SliderCtrlX slider;
};
#endif
JBControlsTest.cpp :
#include "JBControlsTest.h"
JBControlsTest::JBControlsTest()
{
Add(slider.FillColor(Color(255, 85, 0)).SetThickness(3).SetThumbType(4).LeftPosZ(63, 330).TopPosZ(220, 52));
slider.Jump(true);
}
GUI_APP_MAIN
{
JBControlsTest().Run();
}
Just move "Jump", and you get an "Invalid memory access" at run time...
#include "JBControlsTest.h"
JBControlsTest::JBControlsTest()
{
Add(slider.FillColor(Color(255, 85, 0)).SetThickness(3).SetThumbType(4).Jump(true).LeftPosZ(63, 330).TopPosZ(220, 52));
}
GUI_APP_MAIN
{
JBControlsTest().Run();
}
Part of SliderCtrlX.h :
...
private:
...
bool m_bJump; // Jumps directly to mouse pos if click on the scale
...
public:
...
SliderCtrlX& Jump(bool v = false) { m_bJump = v; }
...
Part of SliderCtrlX.cpp :
...
SliderCtrlX::SliderCtrlX()
: m_nMin(0)
, m_nMax(100)
, m_bInverted(false)
, m_nStep(1)
, m_bRound_step(false)
, m_bJump(false)
, m_bUseCustomThumbs( 0 )
, m_nMajorTicks( 10 )
, m_nMinorTicks( 2 )
, m_nMajorTickSize( 30 )
, m_nMinorTickSize( 20 )
, m_nTickPosition( TOP )
, m_nThickness( 2 )
, m_nSliderType( 0 )
, m_nThumbNumber( 1 )
{
...
}
...
void SliderCtrlX::LeftDown(Point pos, dword keyflags)
{
...
else if( m_bJump )
{
m_vValues[0] = ClientToSlider(p);
WhenSlideFinish();
UpdateActionRefresh();
}
...
}
...
... I don't understand...
|
|
|
Re: Slider with thermometer like scale [message #32375 is a reply to message #32364] |
Fri, 13 May 2011 22:32   |
 |
koldo
Messages: 3432 Registered: August 2008
|
Senior Veteran |
|
|
Hello Jibe and Jerson
First jibe version works well in debug and optimal just doing these changes:
In SliderCtrlX.h
SliderCtrlX& Jump(bool v = false) { m_bJump = v; return *this; } // Added return *this;
In SliderCtrlX.cpp, void SliderCtrlX::Paint(Draw& w) method (this line was hard to understand for me ):
w.DrawImage(max( SliderToClient(m_vValues[i]) - ( ( m_bUseCustomThumbs ? m_vThumbImgs[i].GetSize().cx : m_ThumbImg.GetSize().cx ) >> 1 ), 0),
m_nThickness + ((size.cy - ( m_bUseCustomThumbs ? m_vThumbImgs[i].GetSize().cy : (m_ThumbImg.GetSize().cy ))) >> 1), // Added parenthesis
HasCapture() || HasFocus() ? (m_bUseCustomThumbs ? m_vThumbImgsFocus[i] : m_ThumbImg) : (m_bUseCustomThumbs ? m_vThumbImgs[i] : m_ThumbImg));
PD: What is the problem with FillColor ?
Best regards
Iñaki
[Updated on: Fri, 13 May 2011 22:34] Report message to a moderator
|
|
|
|
Re: Slider with thermometer like scale [message #32380 is a reply to message #32375] |
Sat, 14 May 2011 15:39   |
 |
jibe
Messages: 294 Registered: February 2007 Location: France
|
Experienced Member |
|
|
Hi, koldo,
koldo wrote on Fri, 13 May 2011 22:32 | First jibe version works well in debug and optimal just doing these changes:
In SliderCtrlX.h
SliderCtrlX& Jump(bool v = false) { m_bJump = v; return *this; } // Added return *this;
|
So, it was that simple !
I already had a missing "return *this", but it was making an error at run time, so I didn't think about that...
Why the compiler (I'm using GCC, under Linux) does not complains, at least with a warning ? Normally, it should detect that a return statement is needed...
koldo wrote on Fri, 13 May 2011 22:32 | this line was hard to understand for me
|
Yes, it's true ! I kept it from the original version of SliderCtrlX that you put in bazaar, but hesitate to use some intermediate variables... Probably, it's to do to have a more readable code! What do you think ?
koldo wrote on Fri, 13 May 2011 22:32 | What is the problem with FillColor ?
|
Just try to change it from the graphic layout designer : you'll get an "invalid memory access" error.
koldo wrote on Fri, 13 May 2011 22:32 | it hangs in SliderCtrlX& SliderCtrlX::SetThumbType(int n)
|
What could be the reason ? I cannot experiment this, as I'm working under Linux...
|
|
|
|
Goto Forum:
Current Time: Sun Apr 27 00:26:38 CEST 2025
Total time taken to generate the page: 0.01086 seconds
|