On 17.11.2008, at 09:55 , Einar Magnús Boson wrote:
Hello everybody. Let me just say that I am kinda new to shoes but
managed to complete an application. Now I was gonna extend it with a
slider but alas! No slider to be seen anywhere.
So I thought I'd make one. Turned out to be tougher than I'd hoped.
Documentation is sparse it seems, and the example Speedometer at http://hackety.org/2008/06/12/martinDemellosGooeyChallenge.html
did not run without some guesswork and patching.
(Specifically I had to change
> @s = speedometer :range => 100, :ticks => 10
to
>@s = speedometer Speedometer, :range => 100, :ticks => 10
)
What this tels me is that I probably have an out of date
installation so instructions on getting "edge shoes" would be welcome.
My actual specific question though, is:
built-in methods can take options like :width => "100%", where do I
tap into the already existing logic to translate strings like that
into numbers to use while painting? Seems awfully redundant and
boring to write that logic myself.
Is there really no documentation?
Einar Magnús Boson
+354-661 1649
[EMAIL PROTECTED]
[EMAIL PROTECTED]
Hi again, part 2 of my monologue.
since I got no reply I continued my investigation. Wrote a helper that
will work for now:
def translate_dimension(dim, parent_dim)
case dim.to_s
when /^\d+$/: dim.to_i # int
when /^-\d+$/: parent_dim.to_i + dim # negative int
when /^(\d+(\.\d+)?)%/: (dim[0..-2].to_f / 100) * parent_dim #
percent
when /^\d+\.\d+$/: dim.to_f * parent_dim # float
else parent_dim # something weird, should maybe throw
exception?
end.to_i
end
puts translate_dimension(10, 100)
# >> 10
puts translate_dimension(-10, 100)
# >> 90
puts translate_dimension("10", 100)
# >> 10
puts translate_dimension("20%", 200)
# >> 40
puts translate_dimension(0.4, 300)
# >> 120
It seems to work.
My problem now is that inside my widget's `initialize` stack.width is
0, owner is nil and parent.width is 0.
only later do the widths take on values. I can't find where to put
the logic to get the width of my container to draw. I tried this:
http://pastie.org/316819
but overriding draw screws up a lot of stuff. Just guessing is not
getting me much further. Now I need help.
How do I get a box to size itself after the parent's size? Are there
no custom widgets out there that are more complicated than the simple
examples.
How is the repaint system set up? I don't get it. See the delay in my
example? And column 2 disappears when I override the draw of Slider...
Thank you for building this neat little framework though! :)
Einar Magnús Boson
+354-661 1649
[EMAIL PROTECTED]
[EMAIL PROTECTED]