Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: fyne-io/fyne
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.4.2
Choose a base ref
...
head repository: fyne-io/fyne
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.4.3
Choose a head ref

Commits on Dec 9, 2020

  1. Copy the full SHA
    cc012e8 View commit details
  2. Match aspect lookup against resource name not pointer

    Also update to check file path before image pointer
    andydotxyz committed Dec 9, 2020
    Copy the full SHA
    3bca1ce View commit details

Commits on Dec 11, 2020

  1. iPad fix from upstream

    andydotxyz committed Dec 11, 2020
    Copy the full SHA
    518b553 View commit details
  2. Use position to pixel coordinate mapping for gl Capture (#1644)

    use texture scale during darwin gl capture
    edaniels authored and andydotxyz committed Dec 11, 2020
    Copy the full SHA
    3b14273 View commit details
  3. picked fix from develop

    andydotxyz committed Dec 11, 2020
    Copy the full SHA
    3470c3b View commit details

Commits on Dec 15, 2020

  1. Copy the full SHA
    3dc0677 View commit details

Commits on Dec 18, 2020

  1. Be smarter about downloading packages

    Go modules broke this, so roll back the behaviour and ignore certain errors
    andydotxyz committed Dec 18, 2020
    Copy the full SHA
    d41fe86 View commit details
  2. Copy the full SHA
    5af2ba4 View commit details
  3. Copy the full SHA
    39f2a71 View commit details
  4. Move selected tab when number of tabs reduce

    When a  tab is deleted, the higher index tabs move down one. If the selected is above the one deleted move it also down one  to match the tabs
    adrianre12 committed Dec 18, 2020
    Copy the full SHA
    3c8dde3 View commit details
  5. Copy the full SHA
    c06e195 View commit details

Commits on Dec 19, 2020

  1. Consistant selection behaviour on first tab.

    NewTabContainer selects the first tab. but Append did not select the first tab. This change makes the behaviour the same for both. Append will now select the first added tab.
    adrianre12 committed Dec 19, 2020
    Copy the full SHA
    1b8a3e8 View commit details

Commits on Dec 20, 2020

  1. Fix flakey button test

    andydotxyz committed Dec 20, 2020
    Copy the full SHA
    03a7c6d View commit details
  2. Revert "Consistant selection behaviour on first tab."

    This reverts commit 1b8a3e8.
    adrianre12 committed Dec 20, 2020
    Copy the full SHA
    c620ce4 View commit details
  3. call UpdateNode during Refresh (#1667)

    * Fix tree so it refreshes visible nodes on Refresh()
    
    Fixes #1663
    andydotxyz authored Dec 20, 2020
    Copy the full SHA
    caa1a4d View commit details

Commits on Dec 21, 2020

  1. Copy the full SHA
    f1f4f01 View commit details
  2. Copy the full SHA
    02e2a8a View commit details
  3. Update widget/tabcontainer.go

    Co-authored-by: Stuart Scott <stuart.murray.scott@gmail.com>
    adrianre12 and stuartmscott authored Dec 21, 2020
    Copy the full SHA
    06b84ab View commit details
  4. Copy the full SHA
    f604038 View commit details

Commits on Dec 22, 2020

  1. Copy the full SHA
    bf9b171 View commit details
  2. Copy the full SHA
    a92084c View commit details
  3. Copy the full SHA
    7ac1ff8 View commit details
  4. Copy the full SHA
    374e855 View commit details
  5. Copy the full SHA
    0bf39e3 View commit details

Commits on Dec 23, 2020

  1. Copy the full SHA
    a029ede View commit details

Commits on Dec 24, 2020

  1. Copy the full SHA
    42ec037 View commit details

Commits on Dec 28, 2020

  1. Copy the full SHA
    4b579c7 View commit details
  2. Merge pull request #1670 from adrianre12/#1668-TabContainer-Panic-whe…

    …n-removing-tabs
    
    #1668 tab container panic when removing tabs
    andydotxyz authored Dec 28, 2020
    Copy the full SHA
    6a6e7dd View commit details

Commits on Dec 29, 2020

  1. Copy the full SHA
    ce3893f View commit details
  2. Copy the full SHA
    1e85fda View commit details
  3. Copy the full SHA
    29f4dd4 View commit details
  4. Copy the full SHA
    f76b648 View commit details
  5. Copy the full SHA
    0d5a0a4 View commit details
  6. Merge pull request #1695 from andydotxyz/fix/1682-2

    Support clipping child clips, avoid overflow of nested scroll containers
    andydotxyz authored Dec 29, 2020
    Copy the full SHA
    650aec3 View commit details
  7. Fix missing changelog item

    andydotxyz committed Dec 29, 2020
    Copy the full SHA
    ed0eee9 View commit details

Commits on Dec 30, 2020

  1. Simpler checks for content type

    Co-authored-by: Stuart Scott <stuart.murray.scott@gmail.com>
    andydotxyz and stuartmscott authored Dec 30, 2020
    Copy the full SHA
    e59fa6b View commit details
  2. Fix test broken by merge

    andydotxyz committed Dec 30, 2020
    Copy the full SHA
    43c8b56 View commit details
  3. Merge pull request #1696 from andydotxyz/fix/svgdetection

    Improve detection of SVG from resources in case name was wrong
    andydotxyz authored Dec 30, 2020
    Copy the full SHA
    d251eb8 View commit details
  4. Copy the full SHA
    96c52f7 View commit details
  5. Copy the full SHA
    c24ab45 View commit details
  6. Fix tree test merge issue

    andydotxyz committed Dec 30, 2020
    Copy the full SHA
    8c749b1 View commit details
  7. Prepare for release

    andydotxyz committed Dec 30, 2020
    Copy the full SHA
    08cba21 View commit details
  8. Copy the full SHA
    09bfb6d View commit details
  9. Copy the full SHA
    997f7be View commit details
  10. Copy the full SHA
    4564e78 View commit details
Showing with 664 additions and 322 deletions.
  1. +48 −0 .github/workflows/platform_tests.yml
  2. +0 −1 .github/workflows/static_analysis.yml
  3. +4 −0 .gitignore
  4. +17 −0 CHANGELOG.md
  5. +1 −1 README.md
  6. +3 −3 app/app_darwin.m
  7. +16 −16 cmd/fyne/commands/get.go
  8. +3 −0 cmd/fyne/commands/install.go
  9. +3 −0 cmd/fyne/internal/mobile/build.go
  10. +24 −12 cmd/fyne_demo/tutorials/collection.go
  11. +1 −1 go.mod
  12. +2 −2 go.sum
  13. +81 −0 internal/clip.go
  14. +62 −0 internal/clip_test.go
  15. +13 −9 internal/driver/glfw/canvas.go
  16. +4 −4 internal/driver/glfw/file_test.go
  17. +0 −2 internal/driver/glfw/scale_test.go
  18. +1 −1 internal/driver/gomobile/canvas.go
  19. +1 −0 internal/driver/gomobile/canvas_test.go
  20. +17 −16 internal/driver/gomobile/driver.go
  21. +2 −2 internal/painter/gl/capture.go
  22. +1 −1 internal/painter/gl/painter.go
  23. +30 −5 internal/painter/image.go
  24. +32 −0 internal/painter/image_internal_test.go
  25. +7 −1 internal/painter/svg_cache.go
  26. +0 −20 internal/widget/tree.go
  27. +1 −2 storage/uri.go
  28. +1 −1 theme/icons.go
  29. +1 −1 vendor/github.com/fyne-io/mobile/app/app.go
  30. +10 −11 vendor/github.com/fyne-io/mobile/app/darwin_ios.go
  31. +5 −5 vendor/github.com/fyne-io/mobile/app/darwin_ios.m
  32. +4 −4 vendor/github.com/fyne-io/mobile/app/keyboard.go
  33. +1 −1 vendor/github.com/fyne-io/mobile/app/x11.go
  34. +1 −1 vendor/modules.txt
  35. +16 −12 widget/button_test.go
  36. +12 −0 widget/splitcontainer.go
  37. +58 −0 widget/splitcontainer_test.go
  38. +5 −1 widget/tabcontainer.go
  39. +13 −0 widget/tabcontainer_test.go
  40. BIN widget/testdata/button/disabled.png
  41. BIN widget/testdata/button/initial.png
  42. BIN widget/testdata/tree/refresh_initial.png
  43. BIN widget/testdata/tree/refresh_replaced.png
  44. +17 −12 widget/tree.go
  45. +43 −25 widget/tree_internal_test.go
  46. +103 −149 widget/tree_test.go
48 changes: 48 additions & 0 deletions .github/workflows/platform_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Platform Tests
on: [push, pull_request]

jobs:
platform_tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.12.x, 1.15.x]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- name: Get dependencies
run: sudo apt-get update && sudo apt-get install golang gcc libgl1-mesa-dev libegl1-mesa-dev libgles2-mesa-dev libx11-dev xorg-dev
if: ${{ runner.os == 'Linux' }}

#- name: Verify go modules
# run: |
# if [ "$GO111MODULE" == "on" ]
# then
# # For some reason `git diff-index HEAD` does not work properly if the following line is missing.
# git diff
# # check that go mod tidy does not change go.mod/go.sum
# go mod tidy && git diff-index --quiet HEAD -- || ( echo "go.mod/go.sum not up-to-date"; git diff-index HEAD --; false )
# fi

- name: Tests
run: go test -tags ci ./...

- name: Update coverage
run: |
GO111MODULE=off go get github.com/mattn/goveralls
set -e
go test -tags ci -covermode=atomic -coverprofile=coverage.out ./...
if [ $coverage -lt 69 ]; then echo "Test coverage lowered"; exit 1; fi
if: ${{ runner.os == 'Linux' }}

- name: Update PR Coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out
if: ${{ runner.os == 'Linux' && github.event_name == 'push' }}
1 change: 0 additions & 1 deletion .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: Static Analysis
on: [push, pull_request]

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -3,6 +3,10 @@ cmd/fyne/fyne
cmd/fyne_demo/fyne_demo
cmd/fyne_settings/fyne_settings
cmd/hello/hello
cmd/fyne/fyne.exe
cmd/fyne_demo/fyne_demo.exe
cmd/fyne_settings/fyne_settings.exe
cmd/hello/hello.exe

### Tests
**/testdata/failed
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,23 @@
This file lists the main changes with each version of the Fyne toolkit.
More detailed release notes can be found on the [releases page](https://github.com/fyne-io/fyne/releases).

## 1.4.3 - 4 January 2021

### Fixed

* Fix crash when showing file open dialog on iPadOS
* Fix possible missing icon on initial show of disabled button
* Capturing a canvas on macOS retina display would not capture full resolution
* Fix the release build flag for mobile
* Fix possible race conditions for canvas capture
* Improvements to `fyne get` command downloader
* Fix tree, so it refreshes visible nodes on Refresh()
* TabContainer Panic when removing selected tab (#1668)
* Incorrect clipping behaviour with nested scroll containers (#1682)
* MacOS Notifications are not shown on subsequent app runs (#1699)
* Fix the behavior when dragging the divider of split container (#1618)


## 1.4.2 - 9 December 2020

### Added
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p align="center">
<a href="https://pkg.go.dev/fyne.io/fyne?tab=doc" title="Go API Reference" rel="nofollow"><img src="https://img.shields.io/badge/go-documentation-blue.svg?style=flat" alt="Go API Reference"></a>
<a href="https://github.com/fyne-io/fyne/releases/tag/v1.4.2" title="1.4.2 Release" rel="nofollow"><img src="https://img.shields.io/badge/version-1.4.2-blue.svg?style=flat" alt="1.4.2 release"></a>
<a href="https://github.com/fyne-io/fyne/releases/tag/v1.4.3" title="1.4.3 Release" rel="nofollow"><img src="https://img.shields.io/badge/version-1.4.3-blue.svg?style=flat" alt="1.4.3 release"></a>
<a href='http://gophers.slack.com/messages/fyne'><img src='https://img.shields.io/badge/join-us%20on%20slack-gray.svg?longCache=true&logo=slack&colorB=blue' alt='Join us on Slack' /></a>
<br />
<a href="https://goreportcard.com/report/fyne.io/fyne"><img src="https://goreportcard.com/badge/fyne.io/fyne" alt="Code Status" /></a>
6 changes: 3 additions & 3 deletions app/app_darwin.m
Original file line number Diff line number Diff line change
@@ -22,8 +22,6 @@ - (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center

@end

static int notifyNum = 0;

void sendNSUserNotification(const char *, const char *);

bool isBundled() {
@@ -40,10 +38,12 @@ void sendNotification(const char *title, const char *body) {
if (center.delegate == nil) {
center.delegate = [[FyneUserNotificationCenterDelegate new] autorelease];
}

NSString *uuid = [[NSUUID UUID] UUIDString];
NSUserNotification *notification = [[NSUserNotification new] autorelease];
notification.title = [NSString stringWithUTF8String:title];
notification.informativeText = [NSString stringWithUTF8String:body];
notification.identifier = [NSString stringWithFormat:@"%@-fyne-notify-%d", [[NSBundle mainBundle] bundleIdentifier], ++notifyNum];
notification.identifier = [NSString stringWithFormat:@"%@-fyne-notify-%@", [[NSBundle mainBundle] bundleIdentifier], uuid];
[center scheduleNotification:notification];
}

32 changes: 16 additions & 16 deletions cmd/fyne/commands/get.go
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ var _ Command = (*Getter)(nil)

// Getter is the command that can handle downloading and installing Fyne apps to the current platform.
type Getter struct {
pkg string
icon string
}

// NewGetter returns a command that can handle the download and install of GUI apps built using Fyne.
@@ -28,8 +28,7 @@ func NewGetter() *Getter {

// Get automates the download and install of a named GUI app package.
func (g *Getter) Get(pkg string) error {
g.pkg = pkg
return g.get()
return get(pkg, g.icon)
}

// AddFlags adds available flags to the current flags parser
@@ -49,31 +48,32 @@ func (g *Getter) Run(args []string) {
fmt.Fprintln(os.Stderr, "Missing \"package\" argument to define the application to get")
os.Exit(1)
}
g.pkg = args[0]

err := g.get()
err := get(args[0], g.icon)
if err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
os.Exit(1)
}
}

func (g *Getter) get() error {
path := filepath.Join(goPath(), "src", g.pkg)
// SetIcon allows you to set the app icon path that will be used for the next Get operation.
func (g *Getter) SetIcon(path string) {
g.icon = path
}

cmd := exec.Command("go", "get", "-u", g.pkg)
func get(pkg, icon string) error {
path := filepath.Join(goPath(), "src", pkg)

out, err := cmd.CombinedOutput()
if err != nil {
fmt.Fprintf(os.Stderr, "%s\n", string(out))
return err
}
cmd := exec.Command("go", "get", "-u", "-d", pkg)
cmd.Env = append(os.Environ(), "GO111MODULE=off")

_, err := cmd.CombinedOutput()

if !util.Exists(path) {
return errors.New("Package download not found in expected location")
if !util.Exists(path) { // the error above may be ignorable, unless the path was not found
return err
}

install := &installer{srcDir: path}
install := &installer{srcDir: path, icon: icon, release: true}
err = install.validate()
if err != nil {
return errors.Wrap(err, "Failed to set up installer")
3 changes: 3 additions & 0 deletions cmd/fyne/commands/install.go
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ var _ Command = (*installer)(nil)
type installer struct {
installDir, srcDir, icon, os, appID string
packager *packager
release bool
}

// NewInstaller returns an install command that can install locally built Fyne apps.
@@ -31,6 +32,7 @@ func (i *installer) AddFlags() {
flag.StringVar(&i.installDir, "installDir", "", "A specific location to install to, rather than the OS default")
flag.StringVar(&i.icon, "icon", "Icon.png", "The name of the application icon file")
flag.StringVar(&i.appID, "appID", "", "For ios or darwin targets an appID is required, for ios this must \nmatch a valid provisioning profile")
flag.BoolVar(&i.release, "release", false, "Should this package be installed in release mode? (disable debug etc)")
}

func (i *installer) PrintHelp(indent string) {
@@ -139,5 +141,6 @@ func (i *installer) validate() error {
}
i.packager = &packager{appID: i.appID, os: os, install: true, srcDir: i.srcDir}
i.packager.icon = i.icon
i.packager.release = i.release
return i.packager.validate()
}
3 changes: 3 additions & 0 deletions cmd/fyne/internal/mobile/build.go
Original file line number Diff line number Diff line change
@@ -321,6 +321,9 @@ func goCmdAt(at string, subcmd string, srcs []string, env []string, args ...stri
if targetOS == "darwin" {
tags = append(tags, "ios")
}
if buildRelease {
tags = append(tags, "release")
}
if len(tags) > 0 {
cmd.Args = append(cmd.Args, "-tags", strings.Join(tags, " "))
}
36 changes: 24 additions & 12 deletions cmd/fyne_demo/tutorials/collection.go
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ import (

"fyne.io/fyne"
"fyne.io/fyne/container"
internalWidget "fyne.io/fyne/internal/widget"
"fyne.io/fyne/layout"
"fyne.io/fyne/theme"
"fyne.io/fyne/widget"
@@ -78,17 +77,30 @@ func makeTableTab(_ fyne.Window) fyne.CanvasObject {
}

func makeTreeTab(_ fyne.Window) fyne.CanvasObject {
data := make(map[string][]string)
internalWidget.AddTreePath(data, "A", "B", "C", "abc")
internalWidget.AddTreePath(data, "A", "D", "E", "F", "adef")
internalWidget.AddTreePath(data, "A", "D", "E", "G", "adeg")
internalWidget.AddTreePath(data, "A", "H", "I", "ahi")
internalWidget.AddTreePath(data, "A", "J", "K", "ajk")
internalWidget.AddTreePath(data, "A", "L", "M", "N", "almn")
internalWidget.AddTreePath(data, "A", "O", "ao")
internalWidget.AddTreePath(data, "A", "P", "Q", "R", "apqr")
internalWidget.AddTreePath(data, "A", "S", "T", "U", "astu")
internalWidget.AddTreePath(data, "A", "V", "W", "X", "Y", "Z", "avwxyz")
data := map[string][]string{
"": {"A"},
"A": {"B", "D", "H", "J", "L", "O", "P", "S", "V"},
"B": {"C"},
"C": {"abc"},
"D": {"E"},
"E": {"F", "G"},
"F": {"adef"},
"G": {"adeg"},
"H": {"I"},
"I": {"ahi"},
"O": {"ao"},
"P": {"Q"},
"Q": {"R"},
"R": {"apqr"},
"S": {"T"},
"T": {"U"},
"U": {"astu"},
"V": {"W"},
"W": {"X"},
"X": {"Y"},
"Y": {"Z"},
"Z": {"avwxyz"},
}

tree := widget.NewTreeWithStrings(data)
tree.OnSelected = func(id string) {
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ require (
github.com/akavel/rsrc v0.8.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.4.9
github.com/fyne-io/mobile v0.1.2-0.20201127155338-06aeb98410cc
github.com/fyne-io/mobile v0.1.2
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200625191551-73d3c3675aa3
github.com/godbus/dbus/v5 v5.0.3
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -10,8 +10,8 @@ github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWo
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fyne-io/glfw/v3.3/glfw v0.0.0-20201123143003-f2279069162d h1:WfVxpuVm+5Gr3ipAoWrxV8lJFYkaBWoEwFRrWThWRSU=
github.com/fyne-io/glfw/v3.3/glfw v0.0.0-20201123143003-f2279069162d/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/fyne-io/mobile v0.1.2-0.20201127155338-06aeb98410cc h1:oNo/EXJa9DurC8zmzWDzBCUV3R/b03SWCW/Qftmgpb0=
github.com/fyne-io/mobile v0.1.2-0.20201127155338-06aeb98410cc/go.mod h1:/kOrWrZB6sasLbEy2JIvr4arEzQTXBTZGb3Y96yWbHY=
github.com/fyne-io/mobile v0.1.2 h1:0HaXDtOOwyOTn3Umi0uKVCOgJtfX73c6unC4U8i5VZU=
github.com/fyne-io/mobile v0.1.2/go.mod h1:/kOrWrZB6sasLbEy2JIvr4arEzQTXBTZGb3Y96yWbHY=
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 h1:SCYMcCJ89LjRGwEa0tRluNRiMjZHalQZrVrvTbPh+qw=
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk=
github.com/godbus/dbus/v5 v5.0.3 h1:ZqHaoEF7TBzh4jzPmqVhE/5A1z9of6orkAe5uHoAeME=
81 changes: 81 additions & 0 deletions internal/clip.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package internal

import "fyne.io/fyne"

// ClipStack keeps track of the areas that should be clipped when drawing a canvas.
// If no clips are present then adding one will be added as-is.
// Subsequent items pushed will be completely within the previous clip.
type ClipStack struct {
clips []*ClipItem
}

// Pop removes the current top clip and returns it.
func (c *ClipStack) Pop() *ClipItem {
if len(c.clips) == 0 {
return nil
}

ret := c.clips[len(c.clips)-1]
c.clips = c.clips[:len(c.clips)-1]
return ret
}

// Length returns the number of items in this clip stack. 0 means no clip.
func (c *ClipStack) Length() int {
return len(c.clips)
}

// Push a new clip onto this stack at position and size specified.
// The returned clip item is the result of calculating the intersection of the requested clip and it's parent.
func (c *ClipStack) Push(p fyne.Position, s fyne.Size) *ClipItem {
outer := c.Top()
inner := outer.Intersect(p, s)

c.clips = append(c.clips, inner)
return inner
}

// Top returns the current clip item - it will always be within the bounds of any parent clips.
func (c *ClipStack) Top() *ClipItem {
if len(c.clips) == 0 {
return nil
}

return c.clips[len(c.clips)-1]
}

// ClipItem represents a single clip in a clip stack, denoted by a size and position.
type ClipItem struct {
pos fyne.Position
size fyne.Size
}

// Rect returns the position and size parameters of the clip.
func (i *ClipItem) Rect() (fyne.Position, fyne.Size) {
return i.pos, i.size
}

// Intersect returns a new clip item that is the intersection of the requested parameters and this clip.
func (i *ClipItem) Intersect(p fyne.Position, s fyne.Size) *ClipItem {
ret := &ClipItem{p, s}
if i == nil {
return ret
}

if ret.pos.X < i.pos.X {
ret.pos.X = i.pos.X
ret.size.Width -= i.pos.X - p.X
}
if ret.pos.Y < i.pos.Y {
ret.pos.Y = i.pos.Y
ret.size.Height -= i.pos.Y - p.Y
}

if p.X+s.Width > i.pos.X+i.size.Width {
ret.size.Width = (i.pos.X + i.size.Width) - ret.pos.X
}
if p.Y+s.Height > i.pos.Y+i.size.Height {
ret.size.Height = (i.pos.Y + i.size.Height) - ret.pos.Y
}
return ret
}
Loading