Skip to content

Commit

Permalink
Use gtx.Dp all around
Browse files Browse the repository at this point in the history
  • Loading branch information
esimov committed Nov 6, 2023
1 parent 5e41c91 commit 7f73f45
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
14 changes: 7 additions & 7 deletions hud.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (h *Hud) ShowControlPanel(gtx layout.Context, th *material.Theme, isActive
}.Op())

paint.FillShape(gtx.Ops, color.NRGBA{A: 20}, clip.Rect{
Max: image.Point{gtx.Constraints.Max.X, gtx.Dp(1)},
Max: image.Point{gtx.Constraints.Max.X, gtx.Dp(unit.Dp(1))},
}.Op())
}

Expand All @@ -164,7 +164,7 @@ func (h *Hud) ShowControlPanel(gtx layout.Context, th *material.Theme, isActive

paint.FillShape(gtx.Ops, color.NRGBA{A: 0xff}, clip.Stroke{
Path: path.End(),
Width: float32(unit.Dp(3)),
Width: float32(gtx.Dp(unit.Dp(3))),
}.Op())
}

Expand All @@ -173,7 +173,7 @@ func (h *Hud) ShowControlPanel(gtx layout.Context, th *material.Theme, isActive
)
paint.FillShape(gtx.Ops, th.ContrastBg, clip.Stroke{
Path: buttonArea.Path(gtx.Ops),
Width: 0.3,
Width: float32(gtx.Dp(unit.Dp(0.2))),
}.Op())

buttonStack := buttonArea.Push(gtx.Ops)
Expand Down Expand Up @@ -278,7 +278,7 @@ func (h *Hud) DrawCtrlBtn(gtx layout.Context, th *material.Theme, isActive bool)
}

progress := h.ctrlBtn.Update(gtx, isActive || h.activator.Hovered())
btnWidth := h.ctrlBtn.Animate(progress) * 2.5
btnWidth := h.ctrlBtn.Animate(progress) * 1.5

var path clip.Path

Expand All @@ -298,7 +298,7 @@ func (h *Hud) DrawCtrlBtn(gtx layout.Context, th *material.Theme, isActive bool)

paint.FillShape(gtx.Ops, color.NRGBA{A: 0xff}, clip.Stroke{
Path: path.End(),
Width: float32(unit.Dp(4)),
Width: float32(gtx.Dp(unit.Dp(2.5))),
}.Op())
}(startX+(spacing*i), offset)
}
Expand All @@ -317,15 +317,15 @@ func (h *Hud) DrawCtrlBtn(gtx layout.Context, th *material.Theme, isActive bool)
defer clip.Outline{Path: path.End()}.Op().Push(gtx.Ops).Pop()
paint.ColorOp{Color: color.NRGBA{A: 0xff}}.Add(gtx.Ops)
paint.PaintOp{}.Add(gtx.Ops)
}(startX+(spacing*i), offset+(spacing*i), float32(unit.Dp(6)))
}(startX+(spacing*i), offset+(spacing*i), float32(gtx.Dp(unit.Dp(4.5))))
}
}

defer clip.Stroke{
Path: clip.UniformRRect(image.Rectangle{
Max: image.Pt(h.btnSize, h.btnSize),
}, gtx.Dp(10)).Path(gtx.Ops),
Width: 2.0 + float32(btnWidth),
Width: 2.0 + float32(gtx.Dp(unit.Dp(btnWidth))),
}.Op().Push(gtx.Ops).Pop()

pointer.CursorPointer.Add(gtx.Ops)
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,11 @@ func loop(w *app.Window) error {
cloth.Reset(startX, startY, hud)
case key.NameF1:
hud.showHelpPanel = !hud.showHelpPanel
hud.isActive = false
}
}
if e.Name == key.NameEscape {
w.Perform(system.ActionClose)
hud.showHelpPanel = false
}
}
}
Expand Down

0 comments on commit 7f73f45

Please sign in to comment.