Views: 6,701,549 | Homepage | Main | Rules/FAQ | Memberlist | Active users | Last posts | Calendar | Stats | Online users | Search | 03-29-24 01:03 AM |
Guest: |
0 users reading libui notes/ideas for improvement | 1 bot |
Main - Development - libui notes/ideas for improvement | Hide post layouts | New reply |
Arisotura |
| ||
Big fire melon magical melon girl Level: 55 Posts: 121/876 EXP: 1311296 Next: 2893 Since: 03-28-17 From: France Last post: 6 hours ago Last view: 6 hours ago |
So I used libui and botched it to fit my needs...
Functions that return strings As they are, they allocate the string on heap and return a pointer. You get to do cool one-liners, but you need to remember to free the string, and it's not so efficient. Should change those to use stack-allocated string buffers where possible. uiArea handler (why does this use a handler struct instead of hooking individual event handlers?) The handler struct must remain accessible to libui throughout the uiArea's lifetime. Allocating it on stack can be a bad idea, esp. for secondary windows. (solutions: copy the struct to an internal buffer, for example in the uiArea struct. or use individual handlers.) Sizing Under GTK, it is impossible to resize a window smaller than its original size. List of changes that were made to adapt it for melonDS. (and tags showing where it's finished for now) * [Win/GTK] file dialogs: added filter support, added extra parameter for setting starting dir (not supported yet) * [Win/GTK] uiArea: added small API for creating and drawing bitmaps * [Win/GTK] uiArea: botched keyboard input. only getting raw scancodes * [GTK] uiWindow/GTK: fix window sizing to take the menubar into account. kind of a hack tho. * [Win/GTK] uiWindow: add handlers for getting/losing focus and file dragdrop (limited to one file) * [Win/GTK] uiControl: add uiControlSetFocus() * [GTK] uiArea/GTK: make uiAreaQueueRedrawAll() thread-safe * [Win] uiButton: cache ideal size * wip TODO optimize uiBox sizing under Windows. ____________________ Kuribo64 |
andlabs |
| ||
Newcomer Normal user Level: 4 Posts: 1/2 EXP: 137 Next: 142 Since: 10-05-17 Last post: 2363 days ago Last view: 2352 days ago |
Posted by StapleButter On Windows I need to take out a UTF-16 string and convert it to UTF-8, so allocation is going to happen anyway. This is more do-able on the other platforms, of course.
In the event of having multiple Areas that share the same set of events. Think of it as a way of creating your own controls without extending libui.
I could locally copy it.
Your initial window size is not big enough in this case, because it's GTK+ that limits the size on libui's behalf. Of note is that GTK+ tabs ("notebooks") request enough space for the largest tab page at all times, even if that page isn't the active one. You'll have to talk to the GTK+ team about that. Also note that the minimum size of controls is also theme-dependent.
I've wanted to do the filtering, but in one of the OSs if you specify an extension filter in a save dialog, you can't override it. I forget if there were other issues. As for the starting directory, I forget if the OSs take care of that themselves, and if so, which OSs do (or what I would need to do to enable it if not).
This is in the works as part of the uiTable API. Not sure how it will suit melonDS though...
This is deliberate; I wanted uiArea key events to be keyboard layout-independent. This decision is showing its flaws, but I'm not sure yet what I'll do about it. Also note that OS X uses its own scancode list for all keyboards.
I thought I took care of this already, but it's probably a TODO. What hack did you do?
What do you mean by getting or losing focus? And for file drag and drop, I've wanted to put that in both uiArea and uiTable as an extra option and as an API, but that was a distant goal. Not sure about doing it to uiWindow...
What does this do?
All libui functions except uiQueueMain() are not thread-safe (in fact, that's the whole point of uiQueueMain()). What did you do for this function? I wonder if it's the right thing to do in the first place...
Try disabling the WM_CTLCOLOR stuff in windows/parent.cpp or windows/container.cpp (I forget now where it is at present) and seeing if that is the real problem. Other people say it is, but a correct fix that still looks good (as removing that code would make tabs look bad) would require a(nother) major rearchitecture of libui's control hierarchy structure... If it turns out the containers are indeed slow, I can try switching back to the DeferSetWindowPos() system, but I forget if I'm already using that... |
Arisotura |
| ||
Big fire melon magical melon girl Level: 55 Posts: 127/876 EXP: 1311296 Next: 2893 Since: 03-28-17 From: France Last post: 6 hours ago Last view: 6 hours ago |
Posted by andlabs mh, good point. Posted by andlabs mh, I see. Posted by andlabs actually, that issue was due to me using gtk_widget_set_size_request(), that sets a minimum size. (see below) Posted by andlabs It works well under Windows and GTK, not sure about Mac. Windows remembers the last visited directory. GTK doesn't. I didn't end up coding support for it because I wasn't sure how to approach it. Apparently under Windows trying to force the starting directory is deprecated. Posted by andlabs I'd have to know more about this, but the name uiTable implies that it wouldn't really fit melonDS's goals. Posted by andlabs Nah, I meant that libui comes with a whole system for detecting 'good' keys and modifiers and all that. Which is nice if you want to implement text entry I guess. In the case of melonDS, I only need to know when a given key is pressed, and to tell that key apart from other keys, regardless of what it is. (think Left Ctrl vs Right Ctrl) Posted by andlabs The issue under GTK is that the menubar is part of the client area, which is inconsistent with Windows. The original hack was calling gtk_widget_set_size_request() on the window's childHolderWidget. While it sized the client area properly, it also set that as a minimum size. The final hack kicks in after the window is shown: the final menubar height is retrieved and the window height is adjusted accordingly. Posted by andlabs Under Windows, I need to explicitly give focus to my uiArea or it won't receive key events until it's clicked. I need to do so when creating the window, and when it gets focus (is brought to foreground) after having lost it. So I added event hooks to detect that. uiControlSetFocus() gives keyboard focus to a particular control. Posted by andlabs It is called in a g_idle_add() callback if the calling thread isn't the GUI thread. In melonDS, the emulator loop runs in a separate thread, and that thread needs a way to signal the UI to refresh itself. With GTK, doing it directly caused random freezes. Posted by andlabs Will look into it. ____________________ Kuribo64 |
andlabs |
| ||
Newcomer Normal user Level: 4 Posts: 2/2 EXP: 137 Next: 142 Since: 10-05-17 Last post: 2363 days ago Last view: 2352 days ago |
Posted by StapleButterThe plan for uiImage or uiDrawImage (I forget what it's called) is that it stores a bitmap image of a given point size that's backed by one or more representations. Each representation must have the same aspect ratio, but may have different pixel dimensions. libui will automatically pick the best image representation for the target device (so images will scale properly with DPI changes). Actually libui's system is *bad* for text editing, because it's entirely positional. I plan on making a text editing API that integrates tightly with the system. I'm still not sure how your request isn't satisfied by the current API; you just need to determine which of Key, ExtKey, or Modifier is nonzero (in that order), interpret that key, and use Up to see if it's pressed or released. I am currently swallowing knowledge of whether a left or right modifier key is pressed; not sure why I did that or if I should continue to do that... In that case, I would need to subclass some container and implement get_preferreed_width() and get_preferred_height() and call queue_resize() to do the size change. I'm not sure how well this will work the first time or subsequent times... I can add keyboard focus functions, yes. (On Windows a control has to explicitly request keyboard focus.) Then just use uiQueueMain() on all platforms; that's what it's for =P |
Main - Development - libui notes/ideas for improvement | Hide post layouts | New reply |
Page rendered in 0.082 seconds. (2048KB of memory used) MySQL - queries: 27, rows: 82/82, time: 0.021 seconds. Acmlmboard 2.064 (2018-07-20) © 2005-2008 Acmlm, Xkeeper, blackhole89 et al. |