Fix Y positioning. Expand status bar height.
This commit is contained in:
parent
dc4962a6c4
commit
5da60ac9b3
|
|
@ -3,5 +3,6 @@
|
||||||
"allow": [
|
"allow": [
|
||||||
"Bash(pkill *)"
|
"Bash(pkill *)"
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
|
"$version": 4
|
||||||
}
|
}
|
||||||
|
|
@ -39,7 +39,7 @@ func EditorLayout(screenWidth, screenHeight ui.Dp) []ui.Element {
|
||||||
margin := ui.Dp(10)
|
margin := ui.Dp(10)
|
||||||
|
|
||||||
// Compute StatusBar region
|
// Compute StatusBar region
|
||||||
statusBarHeight := ui.Dp(48)
|
statusBarHeight := ui.Dp(80)
|
||||||
statusBarRegion := ui.Region{
|
statusBarRegion := ui.Region{
|
||||||
X: margin,
|
X: margin,
|
||||||
Y: margin,
|
Y: margin,
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,10 @@ package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
|
||||||
"embed"
|
"embed"
|
||||||
"fmt"
|
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
|
_ "image/png"
|
||||||
|
|
||||||
"gioui.org/f32"
|
"gioui.org/f32"
|
||||||
"gioui.org/layout"
|
"gioui.org/layout"
|
||||||
|
|
@ -128,8 +127,6 @@ func (r *Renderer) drawListView(gtx layout.Context, lv ListView, _ WindowConstra
|
||||||
|
|
||||||
func (r *Renderer) drawStatusBar(gtx layout.Context, sb StatusBar, _ WindowConstraints) {
|
func (r *Renderer) drawStatusBar(gtx layout.Context, sb StatusBar, _ WindowConstraints) {
|
||||||
reg := sb.Region()
|
reg := sb.Region()
|
||||||
th := material.NewTheme()
|
|
||||||
th.Shaper = r.shp
|
|
||||||
|
|
||||||
// Draw light gray background
|
// Draw light gray background
|
||||||
bgColor := color.NRGBA{R: 230, G: 230, B: 230, A: 255}
|
bgColor := color.NRGBA{R: 230, G: 230, B: 230, A: 255}
|
||||||
|
|
@ -147,15 +144,15 @@ func (r *Renderer) drawStatusBar(gtx layout.Context, sb StatusBar, _ WindowConst
|
||||||
Max: image.Point{X: int(r.toPx(reg.X + reg.W)), Y: int(r.toPx(reg.Y + reg.H))},
|
Max: image.Point{X: int(r.toPx(reg.X + reg.W)), Y: int(r.toPx(reg.Y + reg.H))},
|
||||||
}.Push(gtx.Ops)
|
}.Push(gtx.Ops)
|
||||||
|
|
||||||
// Line 1: Filename (truncated with ellipsis if needed)
|
// Line 1: Filename (top at reg.Y + 2dp)
|
||||||
filenameLineY := reg.Y
|
filenameLineY := reg.Y + Dp(2)
|
||||||
|
|
||||||
// Truncate filename only if it doesn't fit
|
// Truncate filename only if it doesn't fit
|
||||||
displayFilename := sb.Filename
|
displayFilename := sb.Filename
|
||||||
availableWidth := int(r.toPx(reg.W - Dp(8) - Dp(40))) // left margin + right icons in DP
|
availableWidth := int(r.toPx(reg.W - Dp(8) - Dp(40))) // left margin + right icons in DP
|
||||||
|
|
||||||
// Layout ellipsis once and get its width
|
// Layout ellipsis once and get its width
|
||||||
th.Shaper.LayoutString(text.Parameters{
|
r.shp.LayoutString(text.Parameters{
|
||||||
PxPerEm: fixed.I(gtx.Sp(r.theme.FontSize)),
|
PxPerEm: fixed.I(gtx.Sp(r.theme.FontSize)),
|
||||||
MinWidth: 0,
|
MinWidth: 0,
|
||||||
MaxWidth: 1000,
|
MaxWidth: 1000,
|
||||||
|
|
@ -163,7 +160,7 @@ func (r *Renderer) drawStatusBar(gtx layout.Context, sb StatusBar, _ WindowConst
|
||||||
}, "...")
|
}, "...")
|
||||||
var ellipsisWidth int
|
var ellipsisWidth int
|
||||||
for {
|
for {
|
||||||
g, ok := th.Shaper.NextGlyph()
|
g, ok := r.shp.NextGlyph()
|
||||||
if !ok {
|
if !ok {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
@ -173,36 +170,32 @@ func (r *Renderer) drawStatusBar(gtx layout.Context, sb StatusBar, _ WindowConst
|
||||||
spaceForText := availableWidth - ellipsisWidth
|
spaceForText := availableWidth - ellipsisWidth
|
||||||
|
|
||||||
// Layout filename, measure widths, and draw in a single pass
|
// Layout filename, measure widths, and draw in a single pass
|
||||||
r.drawTruncatedText(gtx, th.Shaper, displayFilename, r.theme.FontSize, reg.X+Dp(8), filenameLineY, availableWidth, spaceForText, color.NRGBA{R: 0, G: 0, B: 0, A: 255})
|
r.drawTruncatedText(gtx, r.shp, displayFilename, r.theme.FontSize, reg.X+Dp(8), filenameLineY, availableWidth, spaceForText, color.NRGBA{R: 0, G: 0, B: 0, A: 255})
|
||||||
|
|
||||||
// Line 2: Icons — positioned 20DP below filename baseline.
|
// Line 2: Icons (top at reg.Y + 26dp)
|
||||||
iconsLineY := filenameLineY + Dp(32)
|
iconsLineY := reg.Y + Dp(26)
|
||||||
|
|
||||||
// Left side: Cut, Copy, Paste icons (always visible)
|
// Left side: Cut, Copy, Paste icons (always visible)
|
||||||
leftX := reg.X + Dp(8)
|
leftX := reg.X + Dp(8)
|
||||||
iconY := iconsLineY
|
iconY := iconsLineY
|
||||||
|
|
||||||
iconSize := Dp(16)
|
iconSize := Dp(16)
|
||||||
fmt.Printf("[DEBUG drawStatusBar] reg=(%d, %d, %d, %d) filenameLineY=%d iconsLineY=%d iconY=%d iconSize=%d scale=%f\n",
|
// Draw PNG icons at their top-left position (iconY)
|
||||||
reg.X, reg.Y, reg.W, reg.H, filenameLineY, iconsLineY, iconY, iconSize, r.scale)
|
r.drawPng(gtx, r.icons["cut"], leftX, iconY, iconSize, iconSize, color.NRGBA{R: 0, G: 0, B: 0, A: 255})
|
||||||
// Icon Y is baseline position; drawPng uses top-left, so offset by icon height
|
|
||||||
|
|
||||||
// drawPng uses top-left, drawText uses baseline — offset by icon height
|
|
||||||
r.drawPng(gtx, r.icons["cut"], leftX, iconY-iconSize, iconSize, iconSize, color.NRGBA{R: 0, G: 0, B: 0, A: 255})
|
|
||||||
leftX += Dp(36)
|
leftX += Dp(36)
|
||||||
r.drawText(gtx, th.Shaper, "⎘", r.theme.FontSize, leftX, iconY, color.NRGBA{R: 0, G: 0, B: 0, A: 255})
|
r.drawText(gtx, r.shp, "⎘", r.theme.FontSize, leftX, iconY, color.NRGBA{R: 0, G: 0, B: 0, A: 255})
|
||||||
leftX += Dp(36)
|
leftX += Dp(36)
|
||||||
r.drawText(gtx, th.Shaper, "⎘", r.theme.FontSize, leftX, iconY, color.NRGBA{R: 0, G: 0, B: 0, A: 255})
|
r.drawText(gtx, r.shp, "⎘", r.theme.FontSize, leftX, iconY, color.NRGBA{R: 0, G: 0, B: 0, A: 255})
|
||||||
leftX += Dp(12)
|
leftX += Dp(12)
|
||||||
|
|
||||||
// Right side: Conflict (conditional), Search (always visible)
|
// Right side: Conflict (conditional), Search (always visible)
|
||||||
rightX := reg.X + reg.W - Dp(8)
|
rightX := reg.X + reg.W - Dp(8)
|
||||||
if sb.ConflictIcon {
|
if sb.ConflictIcon {
|
||||||
rightX -= Dp(36)
|
rightX -= Dp(36)
|
||||||
r.drawText(gtx, th.Shaper, "⚠", r.theme.FontSize, rightX, iconY, color.NRGBA{R: 0, G: 0, B: 0, A: 255})
|
r.drawText(gtx, r.shp, "⚠", r.theme.FontSize, rightX, iconY, color.NRGBA{R: 0, G: 0, B: 0, A: 255})
|
||||||
}
|
}
|
||||||
rightX -= Dp(36)
|
rightX -= Dp(36)
|
||||||
r.drawText(gtx, th.Shaper, "🔍", r.theme.FontSize, rightX, iconY, color.NRGBA{R: 0, G: 0, B: 0, A: 255})
|
r.drawText(gtx, r.shp, "🔍", r.theme.FontSize, rightX, iconY, color.NRGBA{R: 0, G: 0, B: 0, A: 255})
|
||||||
|
|
||||||
c.Pop()
|
c.Pop()
|
||||||
}
|
}
|
||||||
|
|
@ -405,7 +398,6 @@ type WindowConstraints struct {
|
||||||
// col is the tint color — if alpha < 255, the image is tinted using blendOp.DstIn.
|
// col is the tint color — if alpha < 255, the image is tinted using blendOp.DstIn.
|
||||||
func (r *Renderer) drawPng(gtx layout.Context, img image.Image, x, y Dp, width, height Dp, col color.NRGBA) {
|
func (r *Renderer) drawPng(gtx layout.Context, img image.Image, x, y Dp, width, height Dp, col color.NRGBA) {
|
||||||
if img == nil {
|
if img == nil {
|
||||||
fmt.Printf("[DEBUG drawPng] SKIPPED: img is nil\n")
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -414,8 +406,6 @@ func (r *Renderer) drawPng(gtx layout.Context, img image.Image, x, y Dp, width,
|
||||||
yPx := int(r.toPx(y))
|
yPx := int(r.toPx(y))
|
||||||
wPx := int(r.toPx(width))
|
wPx := int(r.toPx(width))
|
||||||
hPx := int(r.toPx(height))
|
hPx := int(r.toPx(height))
|
||||||
fmt.Printf("[DEBUG drawPng] Dp=(%d, %d, %d, %d) Px=(%d, %d, %d, %d) scale=%f\n",
|
|
||||||
x, y, width, height, xPx, yPx, wPx, hPx, r.scale)
|
|
||||||
|
|
||||||
// Compute destination rectangle
|
// Compute destination rectangle
|
||||||
dst := image.Rect(xPx, yPx, xPx+wPx, yPx+hPx)
|
dst := image.Rect(xPx, yPx, xPx+wPx, yPx+hPx)
|
||||||
|
|
@ -430,6 +420,8 @@ func (r *Renderer) drawPng(gtx layout.Context, img image.Image, x, y Dp, width,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the image
|
// Draw the image
|
||||||
|
stack := op.Offset(image.Pt(xPx, yPx)).Push(gtx.Ops)
|
||||||
paint.NewImageOp(img).Add(gtx.Ops)
|
paint.NewImageOp(img).Add(gtx.Ops)
|
||||||
paint.PaintOp{}.Add(gtx.Ops)
|
paint.PaintOp{}.Add(gtx.Ops)
|
||||||
|
stack.Pop()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user