pkulchenko / ZeroBraneStudio

Lightweight Lua-based IDE for Lua with code completion, syntax highlighting, live coding, remote debugger, and code analyzer; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and other Lua interpreters on Windows, macOS, and Linux
http://studio.zerobrane.com/
Other
2.62k stars 518 forks source link

LXQt: toolbar height too small #1068

Closed fbosio closed 4 years ago

fbosio commented 4 years ago

Bug

Information

How to reproduce this issue

Just run zbstudio.sh.

Screenshot of the graphic issue, the toolbar height looks too small

The toolbar height is too small, in such a way that the icons cannot be seen completely.

Workaround

Run the following in a shell

echo 'return {
  onIdleOnce = function(self, app)
    local uimgr = ide:GetUIManager()
    local pane = uimgr:GetPane("toolbar")

    pane.best_size:SetHeight(26)
    uimgr:Update()
  end
}' > ~/.zbstudio/packages/lxqttoolbarworkaround.lua

Then, close and open the IDE again. The toolbar should look well from now on.

Note

I had a look at the ZeroBrain Studio source code, and I think that something is going on with the SettingsRestoreView() function, called in main, but I don't know exactly what.

pkulchenko commented 4 years ago

@fbosio, thank you for the detailed report! I have a couple of questions:

  1. How did it get into this situation? Is it reproducible?
  2. Is the issue fixed if you use View | Default Layout?

I think that something is going on with the SettingsRestoreView() function, called in main, but I don't know exactly what.

If you can reproduce the issue, can you add a couple of ide:Print commands around 442 in src/editor/settings.lua to show besth value, as there is already a workaround for a similar (the same?) problem, but it's not hardcoded to any particular height. I'm curious as to why it may not be catching your case. Thank you.

fbosio commented 4 years ago

@fbosio, thank you for the detailed report!

You're welcome! I really like this project, specially for game development with Löve2D :) (Regarding that, thank you for accepting my pull request).

1. How did it get into this situation? Is it reproducible?

I just cloned the repository and ran the shell script, and the toolbar showed up like that. This graphic issue is persistent, if you close ZeroBrane Studio and open it again, the toolbar will look equally thin.

Here's something more, one may

  1. hide the toolbar by deselecting View > Tool Bar
  2. close the IDE
  3. open it again
  4. show the toolbar by selecting View > Tool Bar

and it will look just fine. But that doesn't fix the thing, because the toolbar will be shown the wrong way again if you close and open the IDE once more. Actually, that's why I made the workaround in the first place.

2. Is the issue fixed if you use View | Default Layout?

Yes, but temporarily. The issue appears again when I close and open the IDE, like above.

If you can reproduce the issue, can you add a couple of ide:Print commands around 442 in src/editor/settings.lua to show besth value, as there is already a workaround for a similar (the same?) problem, but it's not hardcoded to any particular height. I'm curious as to why it may not be catching your case. Thank you.

Glad to read that! And sure, I removed my workaround, added an ide:Print(besth) in src/editor/settings.lua/, line 443, and here's the output when I run zbstudio.sh

The API file must be located in a subdirectory of the API directory.
26

It seems that the layout engine detects the besth value correctly. However, when I run

ide:GetUIManager():GetPane("toolbar").best_size:GetHeight()

in the Local console, I get

10

I found that the uimgrlayout settings override this value on line 445, because I added an

ide:Print(string.match(layout, "toolbar.-(besth=.-);"))  -- edited

in line 433 and got

besth=10;

but I can't find exactly where that's happening right now. Does this help?

fbosio commented 4 years ago

Distributions

I repeated my original test in several virtual machines with differente Ubuntu-based distributions, they all look fine, except Lubuntu. So the issue is clearly caused by something going on with LXQt.

Results

Outputs

So I made a few prints and found that, whatever is causing this issue, is doing it after the onAppLoad event. I looked a bit deeper for event callbacks and found the line 27 of src/editor/gui.lua.

toolbar:BestSize(event:GetSize():GetWidth(), ide:GetToolBar():GetClientSize():GetHeight())

I added an ide:Print(ide:GetToolBar():GetClientSize():GetHeight()) and got this

26
26
1
1
10

Hence, the wxSizeEvent gets here, at some point, a window 'client height' of 1. I added the same print command in Ubuntu, whose desktop environment is GNOME, and the 'client height' is always 26. My hypothesis is that the desktop environment, LXQt, is giving the wrong value to wxWidgets. So maybe this issue belongs to them!

Anyway, thank you, @pkulchenko for your attention!

pkulchenko commented 4 years ago

@fbosio, thank for you the detailed analysis! It does look like the issue is with LXQt, as I couldn't reproduce it on my Ubuntu image.

It may be possible to add a workaround though. What if you replace that line 27 with something like this:

if ide:GetToolBar():GetClientSize():GetHeight() > 1 then
  toolbar:BestSize(event:GetSize():GetWidth(), ide:GetToolBar():GetClientSize():GetHeight())

Does it work better? In fact, it should probably be >= 16, which is the minimal icon size anyway.

fbosio commented 4 years ago

Nice hack, works like a charm!