gimu icon indicating copy to clipboard operation
gimu copied to clipboard

MasterWindow.Run wait for events?

Open millerlogic opened this issue 4 years ago • 11 comments

Hi, It looks like it runs at 30 fps regardless of what's going on, but if it used WaitEvents it could allow saving CPU cycles and battery. PostEmptyEvent could be used to break out of the WaitEvents for exit or updates. This makes UI updates somewhat more difficult, requiring an explicit update call to invalidate the current display and force update, but this is fairly common in GUIs. Or at least it seems like a tradeoff the application might want to make.

millerlogic avatar Dec 18 '19 23:12 millerlogic

@millerlogic Thanks for your advice. I'm wrapping more widgets right now. After that I will try to implement this.

AllenDang avatar Dec 19 '19 03:12 AllenDang

@AllenDang There is a PR in imgui main repo https://github.com/ocornut/imgui/pull/2749

Rel1cx avatar Dec 30 '19 09:12 Rel1cx

@Nicify Thanks for the information! I'm currently working on change the backend from nuklear to imgui. Because the auto generated nuklear binding has random crash issue on MacOS, and since cgo cannot provide necessary information it's nearly impossible to fix at this point.

AllenDang avatar Dec 30 '19 09:12 AllenDang

@Nicify I implemented it in imgui version, and it works like magic!!!! The cpu usage is decreased from 10% to 0.4%. Amazing!!!!

AllenDang avatar Dec 30 '19 11:12 AllenDang

@AllenDang Wow, great job!

Rel1cx avatar Dec 30 '19 13:12 Rel1cx

I like this project very much, especially the UI style. At present, this project is just in its infancy. I would like to support this project with bitcoin😊

l0v3R0bber avatar Jan 20 '20 16:01 l0v3R0bber

@l0v3R0bber Thanks! But gimu has a very big issue on the auto-generated cgo wrapper side which will cause random crash. It's nearly unable to fix at this moment unless I manually wrap all nuklear API in future. That's why I created a new project called giu based on imgui which has a very solid and stable wrapper.

AllenDang avatar Jan 22 '20 04:01 AllenDang

hi @AllenDang ,i have got some problem. how to SetString for EditBox and Menu cannot support PopUp func, can it be fix .

sndnvaps avatar Jan 22 '20 06:01 sndnvaps


func AboutMsgBox(w *gimu.Window) {
	gimu.SetFont(w.MasterWindow().GetContext(), customFont)

	opened := w.Popup("关于本程序", nk.PopupStatic, nk.WindowTitle|nk.WindowNoScrollbar|nk.WindowClosable, nk.NkRect(30, 10, 300, 100), func(w *gimu.Window) {
		w.Row(25).Dynamic(1)
		// Custom font

		w.Label("本程序由 sndnvaps<[email protected]>开发", "LC")
		buttonState := w.Button("关闭")
		if buttonState {
			showAboutPopup = false
			w.ClosePopup()
		}
		gimu.SetFont(w.MasterWindow().GetContext(), w.MasterWindow().GetDefaultFont())

	})
	if !opened {
		showAboutPopup = false
	}
}
		// Menu 3
		w.Menu("Help", "CC", 100, 100, func(w *gimu.Window) {
			w.Row(25).Dynamic(1)
			state := w.Button("关于")
			if state {
				showAboutPopup = true
			}
			
				if showAboutPopup {
					AboutMsgBox(w)
				}
			
		})

this code will cause app crash

sndnvaps avatar Jan 22 '20 06:01 sndnvaps

@sndnvaps I strongly suggest to use github.com/AllenDang/giu instead of gimu. Because gimu has random crash issue that I cannot fix at the moment.

AllenDang avatar Jan 22 '20 07:01 AllenDang

@sndnvaps I strongly suggest to use github.com/AllenDang/giu instead of gimu. Because gimu has random crash issue that I cannot fix at the moment.

ok,thanks. i will try it As soon as possible.

sndnvaps avatar Jan 22 '20 07:01 sndnvaps