D5: ProportionalLayout divide by zero

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

D5: ProportionalLayout divide by zero

Bill Dargel
Ran into a divide by zero walkback while playing with the Splitters on a
System Browser:
    Open a SystemBrowser
    Drag ClassList/Categories splitter all the way to the left
    Drag the "left-most" splitter to the right

-------------------------------------------
Bill Dargel            [hidden email]
Shoshana Technologies
100 West Joy Road, Ann Arbor, MI 48105  USA


Reply | Threaded
Open this post in threaded view
|

Re: D5: ProportionalLayout divide by zero

Bill Dargel
Bill Dargel wrote:

> Ran into a divide by zero walkback while playing with the Splitters on a
> System Browser:
>     Open a SystemBrowser
>     Drag ClassList/Categories splitter all the way to the left
>     Drag the "left-most" splitter to the right

Didn't see any follow up to this message from a couple of weeks ago, so I
thought I'd do my own follow up. <g>

Granted, it's not that big a deal, and normal ;-) users are unlikely to ever
run into it. But, since getting a walkback while merely using a system
browser is always a bit disconcerting, I looked into it. A fix is attached.
I simply added the guard clause:
     (prevSize + nextSize) isZero ifTrue: [^self].
to ProportionalLayout methodsFor>>reposition:to:.

Works for me.

-------------------------------------------
Bill Dargel            [hidden email]
Shoshana Technologies
100 West Joy Road, Ann Arbor, MI 48105  USA


!ProportionalLayout methodsFor!

reposition: aMovedView to: aPoint
        "Private - This will expand/shrink the proportions of
        the two non fixed size views on either side of aMovedView."

        | subviews currentPoint prevView aView nextView totalProportion changeSize
          prevSize nextSize containerView |

        containerView := aMovedView parentView.
        subviews := containerView managedSubViews.
        currentPoint := aMovedView position.

        prevView := self nearestProportionalViewFrom: aMovedView inViews: subviews by: 1 negated.
        nextView := self nearestProportionalViewFrom: aMovedView inViews: subviews by: 1.
        (prevView isNil or: [nextView isNil]) ifTrue: [^self].

        prevSize := self majorDimensionOf: prevView extent.
        nextSize := self majorDimensionOf: nextView extent.
        changeSize := self majorDimensionOf: aPoint - currentPoint.
        changeSize := changeSize positive
                ifTrue: [changeSize min: nextSize - 2]
                ifFalse: [changeSize max: prevSize negated + 2].

        prevSize := prevSize + changeSize.
        nextSize := nextSize - changeSize.
        (prevSize + nextSize) isZero ifTrue: [^self].

        totalProportion := self totalProportionsOf: (Array with: prevView with: nextView).
        self arrangementOf: prevView put: (prevSize / (prevSize + nextSize) * totalProportion).
        self arrangementOf: nextView put: (nextSize / (prevSize + nextSize) * totalProportion).

        prevView basicInvalidateLayout.
        nextView basicInvalidateLayout.! !
!ProportionalLayout categoriesFor: #reposition:to:!operations!private! !

Reply | Threaded
Open this post in threaded view
|

Re: D5: ProportionalLayout divide by zero

Andy Bower
Bill,

> > Ran into a divide by zero walkback while playing with the Splitters on a
> > System Browser:
> >     Open a SystemBrowser
> >     Drag ClassList/Categories splitter all the way to the left
> >     Drag the "left-most" splitter to the right
>
> Didn't see any follow up to this message from a couple of weeks ago, so I
> thought I'd do my own follow up. <g>

We did take a cursory look at the problem but couldn't get it to fail when
following the above steps. Following that disappointment :-) it must have
slipped through the net, sorry.

Thanks for the fix. This is now issue #947 and destined for a fix in the
next patch level.

Best Regards,

Andy Bower
Dolphin Support
http://www.object-arts.com
---
Are you trying too hard?
http://www.object-arts.com/Relax.htm
---


Reply | Threaded
Open this post in threaded view
|

Re: D5: ProportionalLayout divide by zero

Andy Bower
Bill,

> Thanks for the fix. This is now issue #947 and destined for a fix in the
> next patch level.

Sorry that's #937.

Best Regards,

Andy Bower
Dolphin Support
http://www.object-arts.com
---
Are you trying too hard?
http://www.object-arts.com/Relax.htm
---


Reply | Threaded
Open this post in threaded view
|

Re: D5: ProportionalLayout divide by zero

Bill Dargel
In reply to this post by Andy Bower
Andy Bower wrote:

> > > Ran into a divide by zero walkback while playing with the Splitters on a
> > > System Browser:
> > >     Open a SystemBrowser
> > >     Drag ClassList/Categories splitter all the way to the left
> > >     Drag the "left-most" splitter to the right
>
> We did take a cursory look at the problem but couldn't get it to fail when
> following the above steps.

Ah yes. The real key here is "left-most". After dragging the 2nd splitter all
the way to the left, there are actually two splitters practically on top of each
other at the left edge of the window. There aren't any visual clues that there
are two there. If one's mouse isn't too sensitive, there are a number of pixel
positions where it will show the splitter cursor. Grabbing at one of the
left-most positions grabs the splitter that's in the middle of the proportional
layout and causes the WB. Whereas grabbing at one of the pixel positions toward
the right side of the pair of splitters grabs the 2nd splitter, which then
merely drags open the pair of panes.

You're welcome for the fix. And thank you for your responsiveness in accepting
and incorporating such fixes. It's quite refreshing -- other companies could be
well served by emulating you in this regard.

-------------------------------------------
Bill Dargel            [hidden email]
Shoshana Technologies
100 West Joy Road, Ann Arbor, MI 48105  USA