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: 3459 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: 3459 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...
|
|
|
|
|
|
| Re: Slider with thermometer like scale [message #32398 is a reply to message #32383] |
Mon, 16 May 2011 08:34   |
 |
jibe
Messages: 294 Registered: February 2007 Location: France
|
Experienced Member |
|
|
Hello, koldo,
| koldo wrote on Sat, 14 May 2011 21:32 | Hello
About the return *this;, it has been reported that gcc options in TheIDE could check more warnings like this . It is very simple to add it to TheIDE
|
And it has never been done ? This kind of warning is very important... I lost a lot of time with that, as I was not looking there, being sure that I should have get a warning...
| koldo wrote on Sat, 14 May 2011 21:32 | About the FillColor, I change it in layout designer without problems...
|
That's weird... With 3412 under Ubuntu 10.04, I can't get it working... Well, I'll verify the return statements
| koldo wrote on Sat, 14 May 2011 21:32 | About the hanging in MinGW, do you mean that in Linux it works now well? It is very strange.
|
Mmm... What I mean is that I didn't try with Mingw, as I work under Linux and cannot test windows exes. Under Linux with Gcc, it's working well.
If I can, I'll try on a windows computer, or with wine...
|
|
|
|
|
|
|
|
| Re: Slider with thermometer like scale [message #32607 is a reply to message #32600] |
Fri, 27 May 2011 15:26   |
 |
jibe
Messages: 294 Registered: February 2007 Location: France
|
Experienced Member |
|
|
Hi,
| koldo wrote on Thu, 26 May 2011 22:41 | Just do this change or similar to avoid MSVC complains
|
Done.
Koldo, if you want to put it in Controls4U, no problem for me. More : I think that it could be good to have all enhanced controls in one library. About other authors :
- I used indirectly avpavp's code, as I took your version of SliderCtrlX
- I took many ideas from jeson's version, but no code,
- No other authors for StarIndicator, but I picked some parts of code from ProgressIndicator in CtrlLib.
| jibe wrote on Thu, 26 May 2011 19:06 | BTW : I wanted to have a hand cursor when it goes on the thumb. How can I do that ?
|
If somebody has an idea... I can't find a simple way to do that...
[Updated on: Fri, 27 May 2011 15:45] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Re: Slider with thermometer like scale [message #32798 is a reply to message #32790] |
Fri, 10 June 2011 08:17   |
 |
jibe
Messages: 294 Registered: February 2007 Location: France
|
Experienced Member |
|
|
Hi,
| koldo wrote on Thu, 09 June 2011 12:44 | The thumb in the beginning touches the end of the control, but at the end there is a little gap between it and the end of the control.
|
Yes, I don't understand why... I think that I could make it more symetric, but not a clean way... So, I left it like this, waiting for a good solution...
| koldo wrote on Thu, 09 June 2011 12:44 | changing a little bit the authors list of course
|
Did I miss somebody ? If so, I'm very sorry...
BTW : I'm looking for somebody better than me in graphics designing to make better thumbs for SliderCtrlX and better stars for StarIndicator. Any help or suggestion will be appreciated 
|
|
|
|
|
|
| Re: Slider with thermometer like scale [message #32802 is a reply to message #32800] |
Fri, 10 June 2011 15:27   |
 |
jibe
Messages: 294 Registered: February 2007 Location: France
|
Experienced Member |
|
|
Hi, koldo,
| koldo wrote on Fri, 10 June 2011 10:11 | See this:

It happens the same to the horizontal ones.
|
Excuse me, I'm not sure to understand what you mean... Is it about this ?
| koldo wrote on Thu, 09 June 2011 12:44 | The thumb in the beginning touches the end of the control, but at the end there is a little gap between it and the end of the control.
|
I know that there is this little gap, but don't know why and don't know how to avoid it in a clean way... I think that I could do so that there is a symetric gap, but not a clean way : this is the reason why I didn't do anything about it...
If you were showing me another problem, please explain as I don't see...
-----------
Here is a new version, with enhancements on StarIndicator :
- More readable text
- Possibility to show value/votes permanently
- Possibility to show or not the total (ie : 3.6/5 or only 3.6)
- Possibility to show the percent or the value/5 (ie : 2.5 or 50%)
[Updated on: Mon, 13 June 2011 21:23] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Re: Slider with thermometer like scale [message #34558 is a reply to message #34553] |
Tue, 29 November 2011 09:07   |
 |
koldo
Messages: 3459 Registered: August 2008
|
Senior Veteran |
|
|
Hello Jibe
I have tried new StarIndicator version and it works well for me.
It is rather easy to translate the Paint function to Painter. If you want I can do a simple version for you to extend it when you learn more.
One comment about comments . For example
StarIndicator& StarIndicator::SetVotes(int n)
/***********************************************************************************************
* Sets the number of votes and the associated color
* virtual - public
**********************************************************************************************/
{
m_nVotes=n;
if (n<0) SetColor(LtCyan);
else if (n < m_nVotesLow) SetColor(Color(255,128,128));
else if (n < m_nVotesHigh) SetColor(Yellow);
else SetColor(LtGreen);
Refresh();
return *this;
}
If I were you I would move all the comments like this to a .tpp help file. This way they will be accessible to help system and they will appear in web .
Best regards
Iñaki
[Updated on: Tue, 29 November 2011 09:08] Report message to a moderator
|
|
|
|
| Re: Slider with thermometer like scale [message #34560 is a reply to message #27646] |
Tue, 29 November 2011 10:58   |
 |
jibe
Messages: 294 Registered: February 2007 Location: France
|
Experienced Member |
|
|
Hi, koldo,
Don't know what to do about that... I will first have to know what is painter exactly and how to use it (Some "getting starting doc would be usefull ! Is there some doc that you could advice to me ?).
For now, in the last version I sent yesterday, it seems not so bad. I'm using iml images. If Painter cannot use iml images, I'm afraid that it will be a lot of changes. Are we sure that the result will be really better ?
Another thing : I tried yesterday to compile your PaiterSvgDemo, but I got an error (with 4205) in line 506 of ParseSvg.cpp. Seems not serious (conversion requested), but as I have not so much time for now, I didn't check why there is this error. I'm afraid that it hides another one...
EDIT : Pls see next post...
[Updated on: Tue, 29 November 2011 11:24] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Sun May 31 07:18:09 GMT+2 2026
Total time taken to generate the page: 0.01264 seconds
|