-
-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decouple planner buttons #4868
Decouple planner buttons #4868
Conversation
@dodomorandi I remember exactly that everything worked as it should, when I checked this a couple of weeks ago. |
@dodomorandi it worked well when every button had unique tooltip, i.e. it was:
Then I renamed all the tooltips to
And everything became bad. |
@Gliese852 is this something that's already being refactored in your other PR? |
@fluffyfreak no |
A couple of discoveries. There was an issue related to clipping rectangle that sometimes made The second thing is that I was trying to use |
are they? IIRC icons.decrease != icons.increase |
Yes, Sorry, I was not clear enough: all decrease icons share the same texture, and all the increase icons do the same. |
@dodomorandi what if we do like this:
these changes seem to solve the problem? |
Holy cow, you are totally right! This demonstrates how I am unable to get how ImGui works... Thank you so much, you easily solved what was driving me nuts. I will update the description of the PR, force push with your changes and, obviously, credit you 😉 |
51656f0
to
e559ef0
Compare
Patch kindly suggested by Gliese852
e559ef0
to
7e11dbb
Compare
Very glad I could help! |
Current behavior
Orbit planner buttons changes the value all together when using left and right arrow buttons. This is obviously unintended.
Desired behavior
Reason of the issue
PiGui::ButtonImageSized
uses the texture id as the button id. However, left and right arrow buttons share the same texture, leading to this issue. This maybe could be happening with other buttons as well.@Gliese852 clearly showed that the issue was related to the ID of the tooltip, nothing related to
PiGui::ButtonImageSized
.I am not sure this issue have been already reported, I am not able to find it. If someone can give me some feedback, it can be opened or we can just solve the whole thing in this PR.
## Status of the PRThe think that the best way to handle this situation is have an optional string that can be passed to the function in order to generate a different ID for the ImGui Item. I followed the typical hashing approach to combine hash together in order to mix the texture id with passed string.In order to pass an optional string to the function I needed to use an alternative version ofLuaPull
, and instead of doing that just forconst char*
, I decided to implement a poor man'soptional
type and create a genericLuaPullOpt
function. Side note: I did not create the function for boolean types because, by default,lua_toboolean
returnsfalse
in case the value wasnil
. Maybe it should be implemented anyway, in order to distinguishnil
fromfalse
, let me know what you think.In any case, I am still struggling with the buttons, probably because of my inexperience withImGui
. I am not able to increment/decrement while keeping the mouse pressed. I changed a bit the return value ofPiGui::ButtonImageSized
in order to returnpressed
,hovered
andheld
properties, but I am still struggling to obtain the desired behavior. Moreover, using onlypressed
value, the factor buttons don't work at all (why???). Maybe it is just something silly that I am missing, so I decided to create this PR in draft mode and, hopefully, get some feedback and help.Oh, don't worry: if it is possible to make things work without using😞hovered
andheld
properties, I will be very happy to restore the return value ofPiGui::ButtonImageSized
and the related functions -- I was just trying to find something that could workEDIT: the issue is solvable in a much simpler way than I thought, thank you @Gliese852.