Skip to content

Commit

Permalink
remove Size#FitsInto again
Browse files Browse the repository at this point in the history
  • Loading branch information
toaster committed Dec 3, 2019
1 parent 1e3be84 commit 389bd46
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 59 deletions.
5 changes: 0 additions & 5 deletions geometry.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ func (s1 Size) Union(s2 Size) Size {
return NewSize(maxW, maxH)
}

// FitsInto returns whether the current Size fits into another Size or not.
func (s1 Size) FitsInto(s2 Size) bool {
return s1.Width <= s2.Width && s1.Height <= s2.Height
}

// NewSize returns a newly allocated Size of the specified dimensions.
func NewSize(w int, h int) Size {
return Size{w, h}
Expand Down
53 changes: 0 additions & 53 deletions geometry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,59 +39,6 @@ func TestSizeUnion(t *testing.T) {
assert.Equal(t, size3.Height, maxH)
}

func TestSize_FitsInto(t *testing.T) {
tests := map[string]struct {
width int
height int
otherWidth int
otherHeight int
wantFit bool
}{
"fits loose": {
width: 6,
height: 9,
otherWidth: 42,
otherHeight: 13,
wantFit: true,
},
"fits perfectly": {
width: 17,
height: 71,
otherWidth: 17,
otherHeight: 71,
wantFit: true,
},
"too wide": {
width: 42,
height: 9,
otherWidth: 6,
otherHeight: 13,
wantFit: false,
},
"too tall": {
width: 6,
height: 13,
otherWidth: 42,
otherHeight: 9,
wantFit: false,
},
"too big": {
width: 42,
height: 13,
otherWidth: 6,
otherHeight: 9,
wantFit: false,
},
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
s1 := NewSize(tt.width, tt.height)
s2 := NewSize(tt.otherWidth, tt.otherHeight)
assert.EqualValues(t, tt.wantFit, s1.FitsInto(s2))
})
}
}

func TestPosition_Add(t *testing.T) {
pos1 := NewPos(10, 10)
pos2 := NewPos(25, 25)
Expand Down
2 changes: 1 addition & 1 deletion widget/scroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ func (s *ScrollContainer) Scrolled(ev *fyne.ScrollEvent) {
}

func (s *ScrollContainer) updateOffset(deltaX, deltaY int) bool {
if s.Content.Size().FitsInto(s.Size()) {
if s.Content.Size().Width <= s.Size().Width && s.Content.Size().Height <= s.Size().Height {
if s.Offset.X != 0 || s.Offset.Y != 0 {
s.Offset.X = 0
s.Offset.Y = 0
Expand Down

0 comments on commit 389bd46

Please sign in to comment.