slider size [message #55541] |
Mon, 27 August 2007 07:53  |
Loren Anderson
Messages: 22 Registered: August 2007
|
Junior Member |
|
|
Hi all, I'm having a problem getting sliders to be the correct size.
I want the sliders to contain all the integers between the minimum and
the maximum keywords I supply. For high maximum values (big sliders),
it will skip numbers. I have gotten around this by adding extra size
to the widget, like this:
sliderID = Widget_Slider(tlbID, /Drag, minimum = 0, maximum =300,
xsize = 336)
36 pixels seems to be the magic number. I'd like to make this a
platform independent. I'm running Linux. Is this just some strange
Motif thing?
|
|
|
Re: slider size [message #55621 is a reply to message #55541] |
Wed, 29 August 2007 21:50  |
Andrew Cool
Messages: 219 Registered: January 1996
|
Senior Member |
|
|
On Aug 29, 10:34 pm, Loren Anderson <andersl...@yahoo.com> wrote:
> Thanks! That's a very cool little program. I'll have to try out all
> the options, but I still seem to have the same problem - if I want
> each mouse drag of one pixel to be one step, the slider size specified
> with "XSIZE" isn't large enough. For example, in this call to
> descrete_slider,
>
> Slider = DISCRETE_SLIDER(tlbID,/DRAG,/step, increment = 1, MIN = 1,
> MAX = 400, XSIZE = 400)
>
> the slider will skip a bunch of values (6, 17, 28, etc).
>
> In thinking about this for a while, I have come up with two solutions
> 1) Just make the XSize larger than I need (37 pixels for my machine -
> maybe more for windows (?)). Then I could use the descrete_slider
> program.
> 2) Somehow find out how much larger the slider needs to be by creating
> a slider and using tlb_get_size, then resizing the slider
> appropriately. This should work, but I can't seem to figure it out.
>
> What I'm worried about is that the sliders may have different sizes on
> different machines, not just on different platforms, which is why #2
> would be better. #1 would be a lot easier though!
>
> -Loren
> the slider will skip a bunch of values (6, 17, 28, etc).
Shouldn't happen if you click on the left/right buttons that
Discrete_Slider adds,
*when* you use the /END_BUTTONS or /STEP_BUTTONS keywords - I forget
off hand which does what...
Use those buttons, and leave the IDL ones alone, and you'll be in
Heaven...
Andrew
|
|
|
Re: slider size [message #55637 is a reply to message #55541] |
Wed, 29 August 2007 06:44  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Loren Anderson writes:
> In thinking about this for a while, I have come up with two solutions
> 1) Just make the XSize larger than I need (37 pixels for my machine -
> maybe more for windows (?)). Then I could use the descrete_slider
> program.
> 2) Somehow find out how much larger the slider needs to be by creating
> a slider and using tlb_get_size, then resizing the slider
> appropriately. This should work, but I can't seem to figure it out.
>
> What I'm worried about is that the sliders may have different sizes on
> different machines, not just on different platforms, which is why #2
> would be better. #1 would be a lot easier though!
IDL is not the perfect software for the overly-anal. You can
take my word for it!
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: slider size [message #55638 is a reply to message #55541] |
Wed, 29 August 2007 06:34  |
Loren Anderson
Messages: 22 Registered: August 2007
|
Junior Member |
|
|
Thanks! That's a very cool little program. I'll have to try out all
the options, but I still seem to have the same problem - if I want
each mouse drag of one pixel to be one step, the slider size specified
with "XSIZE" isn't large enough. For example, in this call to
descrete_slider,
Slider = DISCRETE_SLIDER(tlbID,/DRAG,/step, increment = 1, MIN = 1,
MAX = 400, XSIZE = 400)
the slider will skip a bunch of values (6, 17, 28, etc).
In thinking about this for a while, I have come up with two solutions
1) Just make the XSize larger than I need (37 pixels for my machine -
maybe more for windows (?)). Then I could use the descrete_slider
program.
2) Somehow find out how much larger the slider needs to be by creating
a slider and using tlb_get_size, then resizing the slider
appropriately. This should work, but I can't seem to figure it out.
What I'm worried about is that the sliders may have different sizes on
different machines, not just on different platforms, which is why #2
would be better. #1 would be a lot easier though!
-Loren
|
|
|
Re: slider size [message #55648 is a reply to message #55541] |
Tue, 28 August 2007 19:56  |
Andrew Cool
Messages: 219 Registered: January 1996
|
Senior Member |
|
|
On Aug 29, 2:04 am, Loren Anderson <andersl...@yahoo.com> wrote:
>> What about SCROLL=1 and then clicking to the left/right of the slider
>> drag-thing once you are near your range?
>
> Yes, that works well, but I'd really like to be able to control it
> from the slider itself. I know I'm bring picky....
Loren,
Check the Help template below out. If it looks helpful, you can
download
discrete_slider.pro from :-
http://www.cool.id.au/IDL/discrete_slider.pro
Basically Discrete_slider adds a separate left and right button that
shunts
the slider value by the amount that you specify, in the format that
you specify.
Note that this program dates from 1993, and will probably give people
like David conniptions, or at least severe indigestion ;-)
Cheers,
Andrew
;+
;******************** HIGH FREQUENCY RADAR DIVISION, SRL
**********************
;*************************** Ionospheric Effects
*******************************
;
;HELP
;1 DISCRETE_SLIDER
; The CW_FSLIDER returns values to an accuracy of 0.000001. For many
; applications however we need the incremental step to be a pre-
determined,
; or 'discrete' floating point amount, e.g. a slider for frequency in
MHz
; ranging from 5.00 MHz to 10.00 MHz, stepping every 0.2 MHz.
;
; Users should supply an appropriate FORMAT statement to match the
step
; increment, i.e. for an increment of 0.1, a format of F4.1 might
suffice.
;
; If the FORMAT statement specifies an INTEGER format, then the
returned
; value is converted to type INTEGER.
;
;2 Setting_min_max
; DISCRETE_SLIDER allows the minimum and maximum values to be set at
any
; time with the WIDGET_CONTROL command, by supplying a structure as
input
; to the SET_VALUE keyword, e.g. :-
;
; value_st = {bot:100,top:500,inc:50,format:'(i3)',value:350}
;
; WIDGET_CONTROL,base,SET_VALUE=value_st
;
;=========================================================== ==============
;
; WARNING
;
; NOTE : The INCREMENT value is carried in the STATE structure by
; adding a new field to the 'state' and thus the 'state'
; structure as used by Compound widgets. This may yet cause
; compatibility problems with other Compound widgets that
; use the original definition of the state structure.
;
; A.D. COOL 22-JUL-93
; The DRAG keyword setting is now also carried in the STATE
structure.
; Glen Conboy 29-JUN-94
;
;=========================================================== ==============
;
;2 Examples
;
; MHz_Slider = DISCRETE_SLIDER(base,/DRAG,$
; /step,$
; increment = 0.2 ,$
; format = '(F4.1)' ,$
; MIN = 5.0 ,$
; MAX = 45.0 ,$
; /frame ,$
; XSIZE = 300 ,$
; UVALUE = "MHz" ,$
; VALUE = 20.0 ,$
; TITLE = "Frequency (MHz)")
;
; MHz_Slider = DISCRETE_SLIDER(base,/DRAG,$
; /step,$
; increment = 1.0 ,$
; format = '(I2)' ,$
; MIN = 5.0 ,$
; MAX = 45.0 ,$
; /frame ,$
; XSIZE = 300 ,$
; UVALUE = "MHz" ,$
; VALUE = 20.0 ,$
; TITLE = "Frequency (MHz)")
;
;
;
;2 KEYWORDS
; END_BUTTONS - Include single step increment/decrement buttons
; to left and right of the slider (at the ENDs).
; STEP_BUTTONS - Include single step increment/decrement buttons
; to left and right of printed value.
; INCREMENT - The discrete floating point amount by which the
; value is to change.
; DRAG - Zero if events should only be generated when the mouse
; is released. Non-zero if events should be generated
; continuously when the sliders are adjusted. Note: On slow
; systems, /DRAG performance can be inadequate. The default
; is DRAG=0.
; FORMAT - Provides the format in which the slider value is
displayed.
; This should be a format as accepted by the STRING procedure.
; The default is FORMAT='(G13.6)'
; TIME_FORMAT - Overides FORMAT keyword. Slider value is in the
format
; hh:mm. Assumes 00:00 to 23:59
; HALF_HOUR - Sets time_format slider to 30 minute intervals,
; otherwise defaults to 15 minute intervals
; TIME_INTERVAL - together with TIME_FORMAT, specifies how many
intervals in one hour.
; e.g. 12 intervals = 5 minute
spacing, 4 intervals = 15 minute jumps
; FRAME - Nonzero to have a frame drawn around the widget. The
; default is FRAME=0.
; MAXIMUM - Maximum value of slider (default=100).
; MINIMUM - Minimum value of slider (default=0).
; SUPPRESS_VALUE - If true, the current slider value is not
displayed.
; (default is to display value).
; TITLE - Title of slider (Default is no title).
; UVALUE - Supplies the user value for the widget.
; VALUE - Initial value of slider
; The default is horizontal.
; XSIZE - For horizontal sliders, sets the length.
; FONT - Obvious!!
;
|
|
|
Re: slider size [message #55662 is a reply to message #55541] |
Tue, 28 August 2007 10:04  |
Loren Anderson
Messages: 22 Registered: August 2007
|
Junior Member |
|
|
> What about SCROLL=1 and then clicking to the left/right of the slider
> drag-thing once you are near your range?
Yes, that works well, but I'd really like to be able to control it
from the slider itself. I know I'm bring picky....
|
|
|
Re: slider size [message #55673 is a reply to message #55541] |
Mon, 27 August 2007 16:20  |
mankoff
Messages: 131 Registered: March 2004
|
Senior Member |
|
|
On Aug 27, 10:53 am, Loren Anderson <andersl...@yahoo.com> wrote:
> Hi all, I'm having a problem getting sliders to be the correct size.
> I want the sliders to contain all the integers between the minimum and
> the maximum keywords I supply. For high maximum values (big sliders),
> it will skip numbers. I have gotten around this by adding extra size
> to the widget, like this:
>
> sliderID = Widget_Slider(tlbID, /Drag, minimum = 0, maximum =300,
> xsize = 336)
>
> 36 pixels seems to be the magic number. I'd like to make this a
> platform independent. I'm running Linux. Is this just some strange
> Motif thing?
What about SCROLL=1 and then clicking to the left/right of the slider
drag-thing once you are near your range?
|
|
|
Re: slider size [message #55674 is a reply to message #55541] |
Mon, 27 August 2007 11:15  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Loren Anderson writes:
> For the record, the left/right keys work for me, not up/down.
Well, there you go. No wonder it's not documented. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: slider size [message #55675 is a reply to message #55541] |
Mon, 27 August 2007 10:54  |
Loren Anderson
Messages: 22 Registered: August 2007
|
Junior Member |
|
|
> There is no way (that I know) to force the slider values.
This seems so strange to me! Is this what IDL intended, or is it some
kind of bug? The problem only occurs with the larger sliders.
I'll think about the spinner widget, but I'm loath to begin such a
project when the built in sliders work (almost) so well.
For the record, the left/right keys work for me, not up/down.
-Loren
|
|
|
Re: slider size [message #55678 is a reply to message #55541] |
Mon, 27 August 2007 10:30  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Loren Anderson writes:
> Thanks. Is there any known way of forcing all values to be available
> in the slider itself? I already have the text box next to it, and can
> get to any value I want - I just want to be able to use the slider to
> get to them easily - preferably without typing.
There is no way (that I know) to force the slider values.
One alternative, though, might be a "spinner" widget. This
is a compound widget that has a text box, with the value
of the spinner, next to a couple of buttons with images
of up and down arrows on them. When you click the up arrow
the spinner increases by some set increment. (One, in your
case.) If you hold the button down, the increment "spins"
very quickly. It is nearly as fast as a slider for most
applications, and takes up far less space.
This would give you practice building your own
compound widgets. Something every widget programmer ought
to know how to do anyway! :-)
I have one coded up for my Catalyst Library, so I could
help with the "spin it" part of the event handler, if you
get stuck with that.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: slider size [message #55679 is a reply to message #55541] |
Mon, 27 August 2007 10:19  |
rclark
Messages: 12 Registered: September 1992
|
Junior Member |
|
|
When using a slider on an app I'm developing I noticed that, once the
slider is selected by clicking or dragging it, the arrow keys on my
keyboard are also active for moving it. The UP/DOWN keys move the
slider one unit at a time.
This is a freebie from idl, I didn't do anything (that I know of!) to
make this active. And I had already programmed in ONE_UP and ONE_DOWN
buttons next to the slider before I noticed this :-) I haven't seen
it mentioned in the documentation anywhere.
I don't know how it will behave when you're working near or below the
pixel resolution limit. I'm working just with linux/X11/MOTIF so I
don't know if it works on other platforms.
But check and see if it's useful for you.
Richard
|
|
|
Re: slider size [message #55680 is a reply to message #55541] |
Mon, 27 August 2007 10:10  |
Loren Anderson
Messages: 22 Registered: August 2007
|
Junior Member |
|
|
Thanks. Is there any known way of forcing all values to be available
in the slider itself? I already have the text box next to it, and can
get to any value I want - I just want to be able to use the slider to
get to them easily - preferably without typing.
|
|
|
Re: slider size [message #55685 is a reply to message #55541] |
Mon, 27 August 2007 09:14  |
M. Katz
Messages: 69 Registered: May 2005
|
Member |
|
|
You're working close to the limit of the pixel resolution you have.
Your mouse position, for example, is reported as integers. So when you
drag the slider by one single screen pixel, that's your smallest
increment.
I think one way around this problem is to tie together your slider and
a text-entry box that shows the slider value.
When the user enters a value instead of sliding then you
widget_control the slider to the user-specified value. Likewise, when
the user drags the slider, you widget_control the text field to the
new value. This will allow you to reach any value you want, regardless
of the resolution of the slider on the screen.
It's not really much more complex at all, and there are many ways to
do this.
M. Katz
|
|
|