Skip to content

Commit

Permalink
Merge branch 'release/v1.2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Jan 29, 2020
2 parents 00dbd12 + 6ba97e5 commit 5bd5252
Show file tree
Hide file tree
Showing 26 changed files with 386 additions and 103 deletions.
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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.2.2 - Ongoing
## 1.2.2 - 29 January 2020

### Added

Expand All @@ -12,16 +12,23 @@ More detailed release notes can be found on the [releases page](https://github.c

### Changed

* Scale calculations are now relative to system scale - the default "1" matches the system
* Update scale on Linux to be "auto" by default (and numbers are relative to 96DPI standard) (#595)
* When auto scaling check the monitor in the middle of the window, not top left
* bundled files now have a standard header to optimise some tools like go report card
* Shortcuts are now handled by the event queue - fixed possible deadlock

### Fixed

* Corrected visual behaviour of extended widgets including Entry, Select, Check and Radio
* Entries that are extended would crash on right click.
* Scroll horizontally when holding shift key (#579)
* Updating text and calling refresh for widget doesn't work (#607)
* Corrected visual behaviour of extended widgets including Entry, Select, Check, Radio and Icon (#615)
* Entries and Selects that are extended would crash on right click.
* PasswordEntry created from Entry with Password = true has no revealer
* Dialog width not always sufficient for title
* Pasting unicode characters could panic (#597)
* Setting theme before application start panics on macOS (#626)
* MenuItem type conflicts with other projects (#632)


## 1.2.1 - 24 December 2019
Expand Down
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://godoc.org/fyne.io/fyne" title="GoDoc Reference" rel="nofollow"><img src="https://img.shields.io/badge/go-documentation-blue.svg?style=flat" alt="GoDoc Reference"></a>
<a href="https://github.com/fyne-io/fyne/releases/tag/v1.2.1" title="1.2.1 Release" rel="nofollow"><img src="https://img.shields.io/badge/version-1.2.1-blue.svg?style=flat" alt="1.2.1 release"></a>
<a href="https://github.com/fyne-io/fyne/releases/tag/v1.2.2" title="1.2.2 Release" rel="nofollow"><img src="https://img.shields.io/badge/version-1.2.2-blue.svg?style=flat" alt="1.2.2 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>
<a href='https://fossfi.sh/support-fyneio'><img src='https://img.shields.io/badge/$-support_us-orange.svg?labelWidth=20&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAkCAYAAADPRbkKAAAABmJLR0QA7wAyAD/CTveyAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAAB3RJTUUH4wMVCQ4LeuPReAAABDFJREFUWMPVmX9oVWUYxz/3tr5jbX9oYiZWSmNgoYYlUVqraYvIamlCg8pqUBTZr38qMhZZ0A8oIqKIiLJoJtEIsR+zki1mGqQwZTYkImtlgk5Wy7jPnbv90XPgcD3n3Lvdy731wOGc+77nec73Oe/zfp/nOTeVy+WolphZC3CVH9N9OAsMAzuBLkkHkmykKu2AmQGsAjYAC4pQ+QJ4WNJg1R0ws3pgI3DTJFVPAM8AGyRNVMUBB98DLCvBzLtAh6QTwUC6gmGzuUTwAGuBR8MD6QpFzwPAypi5v4HXgRXAEg+vLQm2njSzCyoWQmbWAPwAzIqY/gm4UdJAhN5qoAuojdCbAD4BVlViBdbGgJ8A2gPwZtZsZvea2XwASd1AZ4zNNHA90FgJB9ri6FHStw7+WaAPeA3YbWaBzovAiF/nfMUC+QD4sRIOLIkZ73Hws4BHQuOneY7A2aY/CHdgL3AtsBhYD9TVVMCB0+O2h59nRJBJfej6WOj6Bj8C2VcpFoqSC/38PbArb24zQDabBWhOsFFbNAuZ2UygxZcvcHwPsEPScILecaAuYmoUaJR01MymAU8AFzm7vCxp3MxagW0xpv8EzinogLPC40A7cGpMKHQB6yX9FqE/ACyKMb8VWC0pG6E3D+gF5sbo9km6Ml0A/N3Ad8BtMeABBNwB9JrZ7Ij5PQmPuA7YZWZXmFnan1ljZrf65p2boDuQmInNrAN4I29DJUmT02C+bCtiL/QCo2Y2BIwB7wFzCuj1xGZiM7vcb9gOTAMunUTZMVPSkZCtJuBAmQngIHCupImaCPApoBVokvSrj7UDm4o0Pg84Evo97EkoVUYHXgjK6pNWwB1I5dfdZtbtjUghWSppZ0ivDvirjA4MAosCfCeFhaRcPvhQLV6QbYGhvLHZZQRvwO1hfJNJZFu9qkySNyUdyxu7pkzgc8BDknZPuSMzs8XA58AZEdPbgTZJY3ld2GABOixWXpH0YMk9sZlN96zZ6hn2F+AdYFM4IZlZLfBRQiMzGXlaUmdFmnpPSC3A814alCJjwDpJG+NuqCkC0HzgLi+L651RvgTeAu4ELnHazAJnedkwpwzvoh+4RdLPid+FMpnMDElHY8CvAd4GGiKmR4A1DvwpYHkZabLTO7KCkgYeiwG/3Iu0hoQ6fwvwh6QVwFKn2tEpgB4BPgSaJS0oFnywAnuB5yR15bHNV6HPfUnyqaSVIV0BlwEXe51zNtAYehGHgMNOyfu9F+iXND6V5UplMplXgfuAj4HPgIXAPcXsj5CcKelwNbqiVCaTOd/jrhRZJumbajiQlrQf6OZ/KkEpsQ74vQQ7w1V1QNIh4Gbg+BRs9BXi6kqsAJK+Bq52hihWxoH7/wshFDixw786vF9kmm+TtK+aDsTWQma2EOjg379/zgNO8akh73NfknSw2pv4H3Ayg0FmbTMRAAAAAElFTkSuQmCC' alt='Support Fyne.io' /></a>
<br />
Expand Down
2 changes: 1 addition & 1 deletion canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Canvas interface {
Scale() float32
// SetScale sets ths scale for this canvas only, overriding system and user settings.
//
// Deprecated: SetScale will be replaced by system wide settings in the future
// Deprecated: Settings are now calculated solely on the user configuration and system setup.
SetScale(float32)

Overlay() CanvasObject
Expand Down
2 changes: 1 addition & 1 deletion cmd/fyne/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (i *installer) install() error {
i.installDir = filepath.Join(os.Getenv("ProgramFiles"), p.name)
runAsAdminWindows("mkdir", "\"\""+filepath.Join(os.Getenv("ProgramFiles"), p.name)+"\"\"")
default:
return errors.New("Unsupported terget operating system \"" + p.os + "\"")
return errors.New("Unsupported target operating system \"" + p.os + "\"")
}
}

Expand Down
7 changes: 7 additions & 0 deletions cmd/fyne/internal/mobile/binres/binres.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,13 @@ func UnmarshalXML(r io.Reader, withIcon bool) (*XML, error) {
},
Value: fmt.Sprintf("%v", MinSDK),
},
{
Name: xml.Name{
Space: androidSchema,
Local: "targetSdkVersion",
},
Value: "28",
},
},
}
e := xml.EndElement{Name: xml.Name{Local: "uses-sdk"}}
Expand Down
1 change: 1 addition & 0 deletions device.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Device interface {
Orientation() DeviceOrientation
IsMobile() bool
HasKeyboard() bool
SystemScale() float32
}

// CurrentDevice returns the device information for the current hardware (via the driver)
Expand Down
20 changes: 7 additions & 13 deletions internal/driver/glfw/canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,16 @@ func (c *glCanvas) Scale() float32 {

// SetScale sets the render scale for this specific canvas
//
// Deprecated: SetScale will be replaced by system wide settings in the future
func (c *glCanvas) SetScale(scale float32) {
c.setScaleValue(scale)

c.context.RescaleContext()
}

func (c *glCanvas) setScaleValue(scale float32) {
if scale == fyne.SettingsScaleAuto {
c.scale = c.detectedScale
} else if scale == 0 {
// Deprecated: Settings are now calculated solely on the user configuration and system setup.
func (c *glCanvas) SetScale(_ float32) {
if !c.context.(*window).visible {
return
} else {
c.scale = scale
}

c.scale = c.context.(*window).calculatedScale()
c.setDirty(true)

c.context.RescaleContext()
}

func (c *glCanvas) OnTypedRune() func(rune) {
Expand Down
3 changes: 0 additions & 3 deletions internal/driver/glfw/canvas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func Test_glCanvas_SetContent(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
w := d.CreateWindow("Test").(*window)
w.Canvas().SetScale(1)
w.SetPadded(tt.padding)
if tt.menu {
w.SetMainMenu(fyne.NewMainMenu(fyne.NewMenu("Test", fyne.NewMenuItem("Test", func() {}))))
Expand Down Expand Up @@ -118,7 +117,6 @@ func Test_glCanvas_ChildMinSizeChangeAffectsAncestorsUpToRoot(t *testing.T) {
func Test_glCanvas_ChildMinSizeChangeAffectsAncestorsUpToScroll(t *testing.T) {
w := d.CreateWindow("Test").(*window)
c := w.Canvas().(*glCanvas)
c.SetScale(1)
leftObj1 := canvas.NewRectangle(color.Black)
leftObj1.SetMinSize(fyne.NewSize(50, 50))
leftObj2 := canvas.NewRectangle(color.Black)
Expand Down Expand Up @@ -156,7 +154,6 @@ func Test_glCanvas_ChildMinSizeChangeAffectsAncestorsUpToScroll(t *testing.T) {
func Test_glCanvas_ChildMinSizeChangesInDifferentScrollAffectAncestorsUpToScroll(t *testing.T) {
w := d.CreateWindow("Test").(*window)
c := w.Canvas().(*glCanvas)
c.SetScale(1)
leftObj1 := canvas.NewRectangle(color.Black)
leftObj1.SetMinSize(fyne.NewSize(50, 50))
leftObj2 := canvas.NewRectangle(color.Black)
Expand Down
14 changes: 13 additions & 1 deletion internal/driver/glfw/device.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package glfw

import "fyne.io/fyne"
import (
"runtime"

"fyne.io/fyne"
)

type glDevice struct {
}
Expand All @@ -19,3 +23,11 @@ func (*glDevice) IsMobile() bool {
func (*glDevice) HasKeyboard() bool {
return true // TODO actually check - we could be in tablet mode
}

func (*glDevice) SystemScale() float32 {
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
return 1.0
}

return fyne.SettingsScaleAuto
}
6 changes: 3 additions & 3 deletions internal/driver/glfw/menu_darwin.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

extern void menu_callback(int);

@interface MenuItem : NSObject {
@interface FyneMenuItem : NSObject {

}
@end

@implementation MenuItem
@implementation FyneMenuItem
- (void) tapped:(id) sender {
menu_callback([sender tag]);
}
Expand All @@ -30,7 +30,7 @@ void createDarwinMenu(const char* label) {
}

void addDarwinMenuItem(const char* label, int id) {
MenuItem* tapper = [[MenuItem alloc] init]; // we cannot release this or the menu does not function...
FyneMenuItem* tapper = [[FyneMenuItem alloc] init]; // we cannot release this or the menu does not function...

NSMenuItem* item = [[NSMenuItem alloc] initWithTitle:[NSString stringWithUTF8String:label]
action:@selector(tapped:) keyEquivalent:@""];
Expand Down
73 changes: 47 additions & 26 deletions internal/driver/glfw/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,16 @@ func (w *window) SetOnClosed(closed func()) {
}

func (w *window) getMonitorForWindow() *glfw.Monitor {
xOff := w.xpos + (w.width / 2)
yOff := w.ypos + (w.height / 2)

for _, monitor := range glfw.GetMonitors() {
x, y := monitor.GetPos()

if x > w.xpos || y > w.ypos {
if x > xOff || y > yOff {
continue
}
if x+monitor.GetVideoMode().Width <= w.xpos || y+monitor.GetVideoMode().Height <= w.ypos {
if x+monitor.GetVideoMode().Width <= xOff || y+monitor.GetVideoMode().Height <= yOff {
continue
}

Expand All @@ -285,7 +288,7 @@ func (w *window) getMonitorForWindow() *glfw.Monitor {
return monitor
}

func (w *window) selectScale() float32 {
func (w *window) userScale() float32 {
env := os.Getenv("FYNE_SCALE")

if env != "" && env != "auto" {
Expand All @@ -298,20 +301,30 @@ func (w *window) selectScale() float32 {

if env != "auto" {
setting := fyne.CurrentApp().Settings().Scale()
switch setting {
case fyne.SettingsScaleAuto:
// fall through
case 0.0:
if env == "" {
return 1.0
}
// fall through
default:
if setting != fyne.SettingsScaleAuto && setting != 0.0 {
return setting
}
}

return w.detectScale()
return 1.0 // user preference for auto is now passed as 1 so the system auto is picked up
}

func calculateScale(user, system, detected float32) float32 {
if user == fyne.SettingsScaleAuto {
user = 1.0
}

if system == fyne.SettingsScaleAuto {
system = detected
}

return system * user
}
func (w *window) calculatedScale() float32 {
val := calculateScale(w.userScale(), fyne.CurrentDevice().SystemScale(), w.detectScale())
val = float32(math.Round(float64(val*10.0))) / 10.0

return val
}

func (w *window) detectScale() float32 {
Expand All @@ -323,7 +336,7 @@ func (w *window) detectScale() float32 {
if dpi > 1000 || dpi < 10 {
dpi = 96
}
return float32(math.Round(float64(dpi)/144.0*10.0)) / 10.0
return float32(float64(dpi) / 96.0)
}

func (w *window) Show() {
Expand Down Expand Up @@ -434,22 +447,16 @@ func (w *window) destroy(d *gLDriver) {
}

func (w *window) moved(viewport *glfw.Window, x, y int) {
if w.canvas.scale != w.canvas.detectedScale {
return
}

// save coordinates
w.xpos, w.ypos = x, y
scale := w.canvas.scale
newScale := w.detectScale()
if scale == newScale {
forceWindowRefresh(w)

newDetected := w.detectScale()
if w.canvas.detectedScale == newDetected {
return
}

w.canvas.detectedScale = newScale
w.canvas.setScaleValue(newScale)
w.rescaleOnMain()
w.canvas.detectedScale = newDetected
go w.canvas.SetScale(fyne.SettingsScaleAuto) // scale value is ignored
}

func (w *window) resized(viewport *glfw.Window, width, height int) {
Expand Down Expand Up @@ -683,6 +690,11 @@ func (w *window) mouseScrolled(viewport *glfw.Window, xoff float64, yoff float64
})
switch wid := co.(type) {
case fyne.Scrollable:
if runtime.GOOS != "darwin" && xoff == 0 &&
(viewport.GetKey(glfw.KeyLeftShift) == glfw.Press ||
viewport.GetKey(glfw.KeyRightShift) == glfw.Press) {
xoff, yoff = yoff, xoff
}
ev := &fyne.ScrollEvent{}
ev.DeltaX = int(xoff * scrollSpeed)
ev.DeltaY = int(yoff * scrollSpeed)
Expand Down Expand Up @@ -1056,6 +1068,15 @@ func (w *window) RescaleContext() {

func (w *window) rescaleOnMain() {
w.fitContent()
if w.fullScreen {
w.width, w.height = w.viewport.GetSize()
scaledFull := fyne.NewSize(
internal.UnscaleInt(w.canvas, w.width),
internal.UnscaleInt(w.canvas, w.height))
w.canvas.Resize(scaledFull)
return
}

size := w.canvas.size.Union(w.canvas.MinSize())
newWidth, newHeight := w.screenSize(size)
w.viewport.SetSize(newWidth, newHeight)
Expand Down Expand Up @@ -1114,7 +1135,7 @@ func (d *gLDriver) CreateWindow(title string) fyne.Window {
ret.canvas.painter.Init()
ret.canvas.context = ret
ret.canvas.detectedScale = ret.detectScale()
ret.canvas.scale = ret.selectScale()
ret.canvas.scale = ret.calculatedScale()
ret.SetIcon(ret.icon)
d.windows = append(d.windows, ret)

Expand Down
Loading

0 comments on commit 5bd5252

Please sign in to comment.