Status on GUI skinning...

tsj tsj at unimelb.edu.au
Wed Jun 9 22:16:56 EDT 2010


On 10/06/10 11:42 AM, "Simon Lord" <slord at karbonized.com> wrote:

> So I downloaded Oliver's stack sample for a custom VERTICAL scrollbar
> which does exactly what I wanted.  Problem is he took out the
> horizontal scrollbar and I can't figure out how to get it to work
> (again, the math).
> 
> So before I start crying profusely I just thought I'd ask if RunRev
> allows for easily skinning scrollbars.
> 
> If not then the begging shall begging...

Hi Simon - here's some code for a simple 'iPhone style' vertical scrollbar
that can be scrolled with your mouse's scroll wheel. Yes it's only for a
vertical scrollbar but it should be easily adapted for a horizontal
scrollbar and has the advantage that their is only one moving part (well,
two if you add a horizontal bar as well). All you should have to do to
modify it for a horizontal scrollbar is to substitute formattedWidth for
formatted height, width for height, left for top bottom for right, hScroll
for scroll etc.

Hope there's something useful to you in there.

Terry...

As always, watch out for wrapped lines.

# script of the group that is being scrolled

on resizeControl
   put the rect of me into tRect
   put the height of me into tH
   put the formattedHeight of me into tFH
   put tFH-4 into tMax
   set the height of grc "scroller" to  min(tFH-4,round(tH*(tH/tFH))-4)
   set the top of grc "scroller" to (item 2 of tRect)+2
   set the height of me to tH
   set the top of me to (item 2 of tRect)
   set the visible of grc "scroller" to (the height of grc "scroller" <
tMax)
end resizeControl

on rawkeydown theCode
   switch theCode
      case 65308
         set the scroll of me to (the scroll of me)+10
         break
      case 65309
         set the scroll of me to (the scroll of me)-10
         break
   end switch
   switch theCode
      case 65308
      case 65309
         put (the scroll of me)/(the formattedHeight of me - the height of
me) into tRatio
         set the top of grc "scroller" to round(tRatio*(the height of me -
the height of grc "scroller"))+the top of me
         set the blendlevel of grc "scroller" to 0
         if not(the pendingMessages contains "hideScroller") then
            repeat for each line tMessage in the pendingMessages
               if tMessage contains "hideScroller" then
                  cancel item 1 of tMessage
               end if
            end repeat
         end if
         send "hideScroller" to me in 1 sec
         break
   end switch  
end rawkeydown

on hideScroller
   set the blendLevel of grc "scroller" to 100
end hideScroller

# script of the vertical 'scrollbar' (grc "scroller")

on mouseEnter
   put false into pDown
   set the blendlevel of me to 0
end mouseEnter

on mouseLeave
   set the blendLevel of me to 100
end mouseLeave

local pDown, pYoffset, pMin, pMax, pH, pGrpT, pGrpB, pGrpH, pFGrpH,
pMaxScroll

on mouseDown
   put the top of (the owner of me) into pGrpT
   put the bottom of (the owner of me) into pGrpB
   put the height of (the owner of me) into pGrpH
   put the formattedHeight of (the owner of me) into pFGrpH
   put the mouseV - the top of me into pYOffset
   put the height of me into pH
   put pGrpH-pH into pMax
   put pFGrpH-pGrpH into pMaxScroll
   put true into pDown
end mouseDown

on mouseUp
   put false into pDown
end mouseUp

on mouseRelease
   put false into pDown
end mouseRelease

on mouseMove x,y
   --put false into pDown
   if pDown then
      put y-pYOffset into tY
      set the top of me to min(pGrpB-pH,max(pGrpT,tY))
      put (the top of me - pGrpT)/pMax into tRatio
      set the scroll of (the owner of me) to round(tRatio*pMaxScroll)
   end if
end mouseMove

> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the Use-livecode mailing list