Skip to content

Commit 65ed918

Browse files
committed
gui: use background color for static message
1 parent 59390c8 commit 65ed918

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

gui.go

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,18 @@ func (g *Gui) Run() error {
159159
case res := <-g.proc.wrk:
160160
if res.done {
161161
g.proc.isDone = true
162-
}
163-
if resizeBothSide {
164-
continue
162+
break
165163
}
166164
g.proc.img = res.img
167165
g.proc.seams = res.carver.Seams
168166
if g.cp.vRes {
169167
g.proc.img = res.carver.RotateImage270(g.proc.img.(*image.NRGBA))
170168
}
169+
170+
if resizeBothSide {
171+
continue
172+
}
173+
171174
w.Invalidate()
172175
}
173176
}
@@ -244,22 +247,38 @@ func (g *Gui) draw(win *app.Window, e system.FrameEvent) {
244247

245248
// Disable the preview mode and warn the user in case the image is resized both horizontally and vertically.
246249
if resizeBothSide {
247-
var msg string
250+
var (
251+
msg string
252+
fgcol color.NRGBA
253+
bgcol color.NRGBA
254+
)
248255

249256
if !g.proc.isDone {
250257
msg = "Preview is not available while the image is resized both horizontally and vertically!"
258+
bgcol = color.NRGBA{R: 245, G: 228, B: 215, A: 0xff}
259+
fgcol = color.NRGBA{R: 3, G: 18, B: 14, A: 0xff}
251260
} else {
252-
msg = "Done, you might close this window!"
261+
msg = "Done, you may close this window!"
262+
bgcol = color.NRGBA{R: 15, G: 139, B: 141, A: 0xff}
263+
fgcol = color.NRGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
264+
253265
}
254-
displayMessage(g.ctx, msg)
266+
displayMessage(e, g.ctx, bgcol, fgcol, msg)
255267
}
256268
e.Frame(g.ctx.Ops)
257269
}
258270

259271
// displayMessage show a static message when the image is resized both horizontally and vertically.
260-
func displayMessage(ctx layout.Context, msg string) {
272+
func displayMessage(e system.FrameEvent, ctx layout.Context, bgcol, fgcol color.NRGBA, msg string) {
261273
var th = material.NewTheme(gofont.Collection())
262-
th.Palette.Fg = color.NRGBA{R: 0, A: 0xFF}
274+
th.Palette.Fg = fgcol
275+
paint.ColorOp{Color: bgcol}.Add(ctx.Ops)
276+
277+
rect := image.Rectangle{
278+
Max: image.Point{X: e.Size.X, Y: e.Size.Y},
279+
}
280+
defer clip.Rect(rect).Push(ctx.Ops).Pop()
281+
paint.PaintOp{}.Add(ctx.Ops)
263282

264283
layout.Flex{
265284
Axis: layout.Horizontal,

0 commit comments

Comments
 (0)