Update BottomBar to use drawText instead of material.Label
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
parent
99b4db919b
commit
9476f5448a
|
|
@ -145,26 +145,22 @@ func (r *Renderer) drawStatusBar(gtx layout.Context, sb StatusBar) {
|
||||||
|
|
||||||
func (r *Renderer) drawBottomBar(gtx layout.Context, bb BottomBar) {
|
func (r *Renderer) drawBottomBar(gtx layout.Context, bb BottomBar) {
|
||||||
reg := bb.Region()
|
reg := bb.Region()
|
||||||
th := material.NewTheme()
|
|
||||||
th.Shaper = r.shp
|
// BottomBar text at reg.Y (top of bar), using drawText for consistent rendering.
|
||||||
|
// The BottomBar region is at the bottom of the screen with 10DP margin.
|
||||||
|
bottomY := reg.Y
|
||||||
|
|
||||||
// Left: Cursor position
|
// Left: Cursor position
|
||||||
cursorX := reg.X + unit.Dp(8)
|
cursorX := reg.X + unit.Dp(8)
|
||||||
call1 := op.Offset(image.Point{X: int(cursorX), Y: int(reg.Y)}).Push(gtx.Ops)
|
r.drawText(gtx, r.shp, bb.CursorPos, r.theme.FontSize, cursorX, bottomY, color.NRGBA{R: 0, G: 0, B: 0, A: 255})
|
||||||
material.Label(th, r.theme.FontSize, bb.CursorPos).Layout(gtx)
|
|
||||||
call1.Pop()
|
|
||||||
|
|
||||||
// Center: Byte position
|
// Center: Byte position
|
||||||
byteX := reg.X + reg.W/2 - unit.Dp(60) // approximate center
|
byteX := reg.X + reg.W/2 - unit.Dp(60) // approximate center
|
||||||
call2 := op.Offset(image.Point{X: int(byteX), Y: int(reg.Y)}).Push(gtx.Ops)
|
r.drawText(gtx, r.shp, bb.BytePos, r.theme.FontSize, byteX, bottomY, color.NRGBA{R: 0, G: 0, B: 0, A: 255})
|
||||||
material.Label(th, r.theme.FontSize, bb.BytePos).Layout(gtx)
|
|
||||||
call2.Pop()
|
|
||||||
|
|
||||||
// Right: Word wrap button
|
// Right: Word wrap button
|
||||||
wordWrapX := reg.X + reg.W - unit.Dp(80)
|
wordWrapX := reg.X + reg.W - unit.Dp(80)
|
||||||
call3 := op.Offset(image.Point{X: int(wordWrapX), Y: int(reg.Y)}).Push(gtx.Ops)
|
r.drawText(gtx, r.shp, "W:"+boolToString(bb.WordWrap), r.theme.FontSize, wordWrapX, bottomY, color.NRGBA{R: 0, G: 0, B: 0, A: 255})
|
||||||
material.Label(th, r.theme.FontSize, "W:"+boolToString(bb.WordWrap)).Layout(gtx)
|
|
||||||
call3.Pop()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Renderer) drawButton(gtx layout.Context, btn Button) {
|
func (r *Renderer) drawButton(gtx layout.Context, btn Button) {
|
||||||
|
|
@ -323,3 +319,4 @@ func charWidths(gtx layout.Context, shp *text.Shaper, str string, size unit.Sp)
|
||||||
}
|
}
|
||||||
return widths
|
return widths
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user