Exporting the damn thing
This commit is contained in:
parent
20d8a06508
commit
0de42ad991
|
@ -12,9 +12,9 @@ import (
|
||||||
"fyne.io/fyne/v2/widget"
|
"fyne.io/fyne/v2/widget"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ fyne.Focusable = (*profileBtn)(nil)
|
var _ fyne.Focusable = (*ProfileBtn)(nil)
|
||||||
|
|
||||||
type profileBtn struct {
|
type ProfileBtn struct {
|
||||||
widget.DisableableWidget
|
widget.DisableableWidget
|
||||||
|
|
||||||
OutlineWidth int
|
OutlineWidth int
|
||||||
|
@ -28,37 +28,37 @@ type profileBtn struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// FocusGained is a hook called by the focus handling logic after this object gained the focus.
|
// FocusGained is a hook called by the focus handling logic after this object gained the focus.
|
||||||
func (b *profileBtn) FocusGained() {
|
func (b *ProfileBtn) FocusGained() {
|
||||||
// b.focused = true
|
// b.focused = true
|
||||||
b.Refresh()
|
b.Refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
// FocusLost is a hook called by the focus handling logic after this object lost the focus.
|
// FocusLost is a hook called by the focus handling logic after this object lost the focus.
|
||||||
func (b *profileBtn) FocusLost() {
|
func (b *ProfileBtn) FocusLost() {
|
||||||
// b.focused = false
|
// b.focused = false
|
||||||
b.Refresh()
|
b.Refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TypedRune is a hook called by the input handling logic on text input events if this object is focused.
|
// TypedRune is a hook called by the input handling logic on text input events if this object is focused.
|
||||||
func (b *profileBtn) TypedRune(rune) {
|
func (b *ProfileBtn) TypedRune(rune) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TypedKey is a hook called by the input handling logic on key events if this object is focused.
|
// TypedKey is a hook called by the input handling logic on key events if this object is focused.
|
||||||
func (b *profileBtn) TypedKey(ev *fyne.KeyEvent) {
|
func (b *ProfileBtn) TypedKey(ev *fyne.KeyEvent) {
|
||||||
if ev.Name == fyne.KeySpace {
|
if ev.Name == fyne.KeySpace {
|
||||||
b.Tapped(nil)
|
b.Tapped(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *profileBtn) Resize(s fyne.Size) {
|
func (b *ProfileBtn) Resize(s fyne.Size) {
|
||||||
b.BaseWidget.Resize(s)
|
b.BaseWidget.Resize(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *profileBtn) Disabled() bool {
|
func (b *ProfileBtn) Disabled() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *profileBtn) Tapped(*fyne.PointEvent) {
|
func (b *ProfileBtn) Tapped(*fyne.PointEvent) {
|
||||||
if b.Disabled() {
|
if b.Disabled() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -71,11 +71,11 @@ func (b *profileBtn) Tapped(*fyne.PointEvent) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *profileBtn) CreateRenderer() fyne.WidgetRenderer {
|
func (b *ProfileBtn) CreateRenderer() fyne.WidgetRenderer {
|
||||||
return NewProfileBtnRenderer(b)
|
return NewProfileBtnRenderer(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewProfileBtnRenderer(b *profileBtn) *profileBtnRenderer {
|
func NewProfileBtnRenderer(b *ProfileBtn) *profileBtnRenderer {
|
||||||
r := &profileBtnRenderer{
|
r := &profileBtnRenderer{
|
||||||
canvas.NewRasterFromImage(image.NewRGBA(image.Rect(0, 0, 10, 10))),
|
canvas.NewRasterFromImage(image.NewRGBA(image.Rect(0, 0, 10, 10))),
|
||||||
b,
|
b,
|
||||||
|
@ -84,8 +84,8 @@ func NewProfileBtnRenderer(b *profileBtn) *profileBtnRenderer {
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewProfileBtn() *profileBtn {
|
func NewProfileBtn() *ProfileBtn {
|
||||||
w := &profileBtn{}
|
w := &ProfileBtn{}
|
||||||
w.ExtendBaseWidget(w)
|
w.ExtendBaseWidget(w)
|
||||||
w.OutlineWidth = 0
|
w.OutlineWidth = 0
|
||||||
w.OutlineColor = color.White
|
w.OutlineColor = color.White
|
||||||
|
@ -94,7 +94,7 @@ func NewProfileBtn() *profileBtn {
|
||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *profileBtn) SetProfileResource(r fyne.Resource) {
|
func (b *ProfileBtn) SetProfileResource(r fyne.Resource) {
|
||||||
if r != nil {
|
if r != nil {
|
||||||
i, _, err := image.Decode(bytes.NewReader(r.Content()))
|
i, _, err := image.Decode(bytes.NewReader(r.Content()))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -107,7 +107,7 @@ func (b *profileBtn) SetProfileResource(r fyne.Resource) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *profileBtn) SetMinSize(s fyne.Size) {
|
func (b *ProfileBtn) SetMinSize(s fyne.Size) {
|
||||||
if s.Height > 0 && s.Width > 0 {
|
if s.Height > 0 && s.Width > 0 {
|
||||||
b.minSizeRequested = s
|
b.minSizeRequested = s
|
||||||
b.minSizeOverridden = true
|
b.minSizeOverridden = true
|
||||||
|
@ -116,13 +116,13 @@ func (b *profileBtn) SetMinSize(s fyne.Size) {
|
||||||
b.minSizeOverridden = false
|
b.minSizeOverridden = false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *profileBtn) SetProfileImage(i image.Image) {
|
func (b *ProfileBtn) SetProfileImage(i image.Image) {
|
||||||
b.profileImage = i
|
b.profileImage = i
|
||||||
}
|
}
|
||||||
|
|
||||||
type profileBtnRenderer struct {
|
type profileBtnRenderer struct {
|
||||||
rast *canvas.Raster
|
rast *canvas.Raster
|
||||||
w *profileBtn
|
w *ProfileBtn
|
||||||
}
|
}
|
||||||
|
|
||||||
func min(x, y int) int {
|
func min(x, y int) int {
|
||||||
|
|
Loading…
Reference in New Issue