Skip to content

Commit a956a32

Browse files
committed
Fix placement process for notification messages
1 parent 229119c commit a956a32

File tree

3 files changed

+734
-17
lines changed

3 files changed

+734
-17
lines changed

editor/editor.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ func (e *Editor) showFontErrors() {
477477
for _, fontError := range e.fontErrors {
478478
go e.pushNotification(
479479
NotifyWarn,
480-
5,
480+
6,
481481
fmt.Sprintf("The specified font family '%s' was not found on this system.", fontError),
482482
notifyOptionArg([]*NotifyButton{}),
483483
)
@@ -737,6 +737,7 @@ func (e *Editor) resizeMainWindow() {
737737
cws := e.workspaces[e.active]
738738
windowWidth, windowHeight, _, _ := cws.updateSize()
739739
e.windowSize = [2]int{windowWidth, windowHeight}
740+
e.relocateNotifications()
740741

741742
if !editor.config.Editor.WindowGeometryBasedOnFontmetrics {
742743
return

editor/notification.go

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func notifyOptionArg(b []*NotifyButton) NotifyOptionArg {
4848

4949
func newNotification(l NotifyLevel, p int, message string, options ...NotifyOptionArg) *Notification {
5050
e := editor
51+
e.isDisplayNotifications = true
5152

5253
widget := widgets.NewQWidget(nil, 0)
5354
layout := widgets.NewQVBoxLayout()
@@ -307,22 +308,6 @@ func (n *Notification) hideNotification() {
307308
}
308309
}
309310

310-
func (e *Editor) showNotifications() {
311-
e.notifyStartPos = core.NewQPoint2(e.width-e.notificationWidth-10, e.height-30)
312-
var x, y int
313-
var newNotifications []*Notification
314-
for _, item := range e.notifications {
315-
x = e.notifyStartPos.X()
316-
y = e.notifyStartPos.Y() - item.widget.Height() - 4
317-
item.widget.Move2(x, y)
318-
item.statusReset()
319-
e.notifyStartPos = core.NewQPoint2(x, y)
320-
newNotifications = append(newNotifications, item)
321-
}
322-
e.notifications = newNotifications
323-
e.isDisplayNotifications = true
324-
}
325-
326311
func (e *Editor) hideNotifications() {
327312
var newNotifications []*Notification
328313
for _, item := range e.notifications {
@@ -335,6 +320,24 @@ func (e *Editor) hideNotifications() {
335320
e.isDisplayNotifications = false
336321
}
337322

323+
func (e *Editor) relocateNotifications() {
324+
if !e.isDisplayNotifications {
325+
return
326+
}
327+
328+
geometry := e.window.Geometry()
329+
width := geometry.Width()
330+
height := geometry.Height()
331+
e.notifyStartPos = core.NewQPoint2(width-e.notificationWidth-10, height-30)
332+
var x, y int
333+
for _, item := range e.notifications {
334+
x = e.notifyStartPos.X()
335+
y = e.notifyStartPos.Y() - item.widget.Height() - 5
336+
item.widget.Move2(x, y)
337+
e.notifyStartPos = core.NewQPoint2(x, y)
338+
}
339+
}
340+
338341
func (n *Notification) statusReset() {
339342
n.isHide = false
340343
n.isMoved = false

0 commit comments

Comments
 (0)