Skip to content

Commit

Permalink
fix zoom not working in gui
Browse files Browse the repository at this point in the history
  • Loading branch information
olebeck committed Jul 9, 2024
1 parent bd68700 commit e8fe425
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
39 changes: 20 additions & 19 deletions ui/gui/pages/packs/packs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ import (
"sync"

"gioui.org/f32"
"gioui.org/font"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/op/paint"
"gioui.org/unit"
"gioui.org/widget"
"gioui.org/widget/material"
"gioui.org/x/component"
"gioui.org/x/styledtext"
"github.com/bedrock-tool/bedrocktool/ui/gui/mctext"
"github.com/bedrock-tool/bedrocktool/ui/gui/pages"
"github.com/bedrock-tool/bedrocktool/ui/messages"
Expand Down Expand Up @@ -118,7 +120,7 @@ func drawPackEntry(gtx C, th *material.Theme, pack *packEntry) D {
if pack.IsFinished {
size = utils.SizeofFmt(float32(pack.Size))
} else {
size = fmt.Sprintf("%s / %s %.02f%%",
size = fmt.Sprintf("%s / %s %.02f%%",
utils.SizeofFmt(float32(pack.Loaded)),
utils.SizeofFmt(float32(pack.Size)),
float32(pack.Loaded)/float32(pack.Size)*100,
Expand All @@ -145,14 +147,7 @@ func drawPackEntry(gtx C, th *material.Theme, pack *packEntry) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(mctext.Label(th, th.TextSize, pack.Name)),
layout.Rigid(material.Label(th, th.TextSize, pack.Version).Layout),
layout.Rigid(material.LabelStyle{
Text: size,
Color: colorSize,
SelectionColor: MulAlpha(th.Palette.ContrastBg, 0x60),
TextSize: th.TextSize,
Shaper: th.Shaper,
}.Layout),
layout.Rigid(func(gtx C) D {
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
var c color.NRGBA
var t string

Expand All @@ -173,16 +168,22 @@ func drawPackEntry(gtx C, th *material.Theme, pack *packEntry) D {
t = "Downloading"
}

if t != "" {
return material.LabelStyle{
TextSize: th.TextSize,
Color: c,
Text: t,
Shaper: th.Shaper,
}.Layout(gtx)
} else {
return D{}
}
return styledtext.Text(th.Shaper, styledtext.SpanStyle{
Font: font.Font{Typeface: th.Face},
Size: th.TextSize,
Color: colorSize,
Content: size,
}, styledtext.SpanStyle{
Font: font.Font{Typeface: th.Face},
Size: th.TextSize,
Color: th.Fg,
Content: " | ",
}, styledtext.SpanStyle{
Font: font.Font{Typeface: th.Face},
Size: th.TextSize,
Color: c,
Content: t,
}).Layout(gtx, nil)
}),
)
}),
Expand Down
5 changes: 4 additions & 1 deletion ui/gui/pages/worlds/map2.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ func (m *mapInput) Layout(gtx layout.Context) func() {
ev, ok := gtx.Event(pointer.Filter{
Target: m,
Kinds: pointer.Scroll | pointer.Drag | pointer.Press | pointer.Release,
//ScrollBounds: image.Rect(-size.X, -size.Y, size.X, size.Y),
ScrollY: pointer.ScrollRange{
Min: -120,
Max: 120,
},
})
if !ok {
break
Expand Down

0 comments on commit e8fe425

Please sign in to comment.