Skip to content

Commit

Permalink
Merge branch 'develop' into feature/gl-driver
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Nov 26, 2018
2 parents 76c2b4f + 6884de1 commit d948247
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 17 deletions.
1 change: 1 addition & 0 deletions driver/efl/canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ func (c *eflCanvas) Focused() fyne.FocusableObject {
return c.focused
}

// fitContent is thread safe - its only every called from the main loop
func (c *eflCanvas) fitContent() {
var w, h C.int
C.ecore_evas_geometry_get(c.window.ee, nil, nil, &w, &h)
Expand Down
7 changes: 4 additions & 3 deletions driver/efl/loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ package efl
// void onKeyDown_cgo(Ecore_Window, void *);
// void onExit_cgo(Ecore_Event_Signal_Exit *);
// void setup_log();
//
import "C"

import (
Expand Down Expand Up @@ -40,7 +41,7 @@ const (
// How many render ops to queue up
renderBufferSize = 1024
// How fast to repaint the screen
renderInterval = time.Second / 120
renderInterval = time.Second / 60
)

var (
Expand Down Expand Up @@ -121,10 +122,10 @@ func renderCycle() {
}
canvas.fitContent()
for obj := range canvas.dirty {
delete(canvas.dirty, obj)

canvas.doRefresh(obj)
}
// clear all the dirty for this canvas
canvas.dirty = make(map[fyne.CanvasObject]bool)
}
}

Expand Down
34 changes: 20 additions & 14 deletions driver/efl/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ package efl
// void force_render();
import "C"

import "log"
import "os"
import "runtime"
import "strconv"
import "unsafe"
import (
"log"
"os"
"runtime"
"strconv"
"unsafe"

import "github.com/fyne-io/fyne"
"github.com/fyne-io/fyne"
)

type window struct {
ee *C.Ecore_Evas
Expand Down Expand Up @@ -53,21 +55,25 @@ func (w *window) Title() string {
}

func (w *window) SetTitle(title string) {
cstr := C.CString(title)
C.ecore_evas_title_set(w.ee, cstr)
C.free(unsafe.Pointer(cstr))
runOnMain(func() {
cstr := C.CString(title)
C.ecore_evas_title_set(w.ee, cstr)
C.free(unsafe.Pointer(cstr))
})
}

func (w *window) FullScreen() bool {
return C.ecore_evas_fullscreen_get(w.ee) != 0
}

func (w *window) SetFullScreen(full bool) {
if full {
C.ecore_evas_fullscreen_set(w.ee, 1)
} else {
C.ecore_evas_fullscreen_set(w.ee, 0)
}
runOnMain(func() {
if full {
C.ecore_evas_fullscreen_set(w.ee, 1)
} else {
C.ecore_evas_fullscreen_set(w.ee, 0)
}
})
}

func (w *window) FixedSize() bool {
Expand Down
11 changes: 11 additions & 0 deletions widget/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ func (e *entryRenderer) cursorPosition() (int, int) {
lineHeight := emptyTextMinSize(e.label.TextStyle).Height

str := e.label.renderer.(*labelRenderer).texts[e.entry.CursorRow].Text
// sanity check, as the underlying entry text can actually change
if e.entry.CursorColumn > len(str) {
e.entry.CursorColumn = len(str)
}
substr := str[0:e.entry.CursorColumn]
subSize := fyne.GetDriver().RenderedTextSize(substr, renderlabel.TextSize, e.label.TextStyle)

Expand Down Expand Up @@ -126,6 +130,13 @@ func (e *Entry) cursorTextPos() int {
}
pos += e.CursorColumn

// Some sanity checks here
if pos > len(e.Text) {
pos = 0
e.CursorColumn = 0
e.CursorRow = 0
}

return pos
}

Expand Down

0 comments on commit d948247

Please sign in to comment.