Fix BottomBar element positioning in renderer
- drawBottomBar now uses element region to position text - Clips to bottom bar region before drawing - Positions cursor position, byte position, word wrap button correctly Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
parent
013416ee08
commit
c452cbef6d
|
|
@ -133,17 +133,32 @@ func (r *Renderer) drawStatusBar(gtx layout.Context, sb StatusBar) {
|
|||
}
|
||||
|
||||
func (r *Renderer) drawBottomBar(gtx layout.Context, bb BottomBar) {
|
||||
reg := bb.Region()
|
||||
th := material.NewTheme()
|
||||
th.Shaper = r.shp
|
||||
|
||||
// Clip to bottom bar region
|
||||
c := clip.Rect{
|
||||
Min: image.Point{X: int(reg.X), Y: int(reg.Y)},
|
||||
Max: image.Point{X: int(reg.X + reg.W), Y: int(reg.Y + reg.H)},
|
||||
}.Push(gtx.Ops)
|
||||
|
||||
// Left: Cursor position
|
||||
cursorX := reg.X + unit.Dp(8)
|
||||
gtx.Constraints.Min.X = int(cursorX)
|
||||
material.Label(th, r.theme.FontSize, bb.CursorPos).Layout(gtx)
|
||||
|
||||
// Center: Byte position
|
||||
byteX := reg.X + reg.W/2 - unit.Dp(60) // approximate center
|
||||
gtx.Constraints.Min.X = int(byteX)
|
||||
material.Label(th, r.theme.FontSize, bb.BytePos).Layout(gtx)
|
||||
|
||||
// Right: Word wrap button
|
||||
wordWrapX := reg.X + reg.W - unit.Dp(120)
|
||||
gtx.Constraints.Min.X = int(wordWrapX)
|
||||
material.Label(th, r.theme.FontSize, "[Word Wrap: "+boolToString(bb.WordWrap)+"]").Layout(gtx)
|
||||
|
||||
c.Pop()
|
||||
}
|
||||
|
||||
func (r *Renderer) drawButton(gtx layout.Context, btn Button) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user