Skip to content
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

Make it possible again to see item tooltips on Android #14029

Merged
merged 2 commits into from Nov 25, 2023

Conversation

grorp
Copy link
Member

@grorp grorp commented Nov 23, 2023

This PR is a quick fix so that item tooltips show again on Android. Fixes (<- Github, don't link this please) #13822 (comment), a regression from #13146.

Please test this PR and let me know whether you think that the new behavior of the tooltips makes sense.

To do

This PR is a Ready for Review.

How to test

Play Minetest on a desktop computer. Verify that item tooltips still work the same as before.

Play Minetest on Android. Verify that it is possible to see item tooltips.

Copy link
Member

@srifqi srifqi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR looks good to me.

Minetest-Android-tooltips.mp4

Probably off-topic

There are some problems (outside this PR) that makes it somewhat annoying to use, but those are for another PR. For example, needing to tap back to put it into the original/source slot (which happens quite often in Android, especially with this PR, for seeing tooltip). Maybe making the tooltip stays drawn until the selected stack is put back down? (I do not know how to do it.)

@grorp
Copy link
Member Author

grorp commented Nov 24, 2023

Maybe making the tooltip stays drawn until the selected stack is put back down?

That would be possible, but I'm worried that it would make the tooltips (especially those with a lot of text) too annoying. Also, I find it confusing that the highlight is gone, but the tooltip is still there. If we do this, we should make sure that the highlight stays visible as long as the tooltip is still displayed.

diff --git a/src/gui/guiFormSpecMenu.h b/src/gui/guiFormSpecMenu.h
index 5641e39a9a..8df1caee87 100644
--- a/src/gui/guiFormSpecMenu.h
+++ b/src/gui/guiFormSpecMenu.h
@@ -286,6 +286,8 @@ class GUIFormSpecMenu : public GUIModalMenu
        bool getAndroidUIInput();
 #endif
 
+       v2s32 getPointerPos() { return m_pointer; };
+
 protected:
        v2s32 getBasePos() const
        {
diff --git a/src/gui/guiInventoryList.cpp b/src/gui/guiInventoryList.cpp
index 6f1d28e0b0..86b0f2b798 100644
--- a/src/gui/guiInventoryList.cpp
+++ b/src/gui/guiInventoryList.cpp
@@ -154,7 +154,8 @@ void GUIInventoryList::draw()
                bool show_tooltip = !item.empty() && hovering && !selected_item;
 #ifdef HAVE_TOUCHSCREENGUI
                // Make it possible to see item tooltips on touchscreens
-               show_tooltip |= hovering && selected && m_fs_menu->getSelectedAmount() != 0;
+               show_tooltip |= rect.isPointInside(m_fs_menu->getPointerPos()) &&
+                               selected && m_fs_menu->getSelectedAmount() != 0;
 #endif
                if (show_tooltip) {
                        std::string tooltip = orig_item.getDescription(client->idef());

@srifqi
Copy link
Member

srifqi commented Nov 24, 2023

... but I'm worried that it would make the tooltips (especially those with a lot of text) too annoying.

I agree. That was my random thought on this issue. It is good as it is now for me.


By the way, what does the last commit (db713ab) do?

@grorp
Copy link
Member Author

grorp commented Nov 24, 2023

By the way, what does the last commit (db713ab) do?

  1. I found an outdated TODO comment related to tooltips on Android and replaced it with a useful comment.

  2. I added a check so that no tooltip is drawn if the selected itemstack is empty. I had assumed this was impossible, but it turns out it can happen during "left-dragging to distribute evenly".

    void GUIFormSpecMenu::updateSelectedItem()
    {
    // Don't update when dragging an item
    if (m_selected_item && (m_selected_dragging || m_left_dragging))
    return;
    verifySelectedItem();

    ItemStack GUIFormSpecMenu::verifySelectedItem()
    {
    // If the selected stack has become empty for some reason, deselect it.
    // If the selected stack has become inaccessible, deselect it.
    // If the selected stack has become smaller, adjust m_selected_amount.
    // Return the selected stack.

@SmallJoker SmallJoker merged commit 771da80 into minetest:master Nov 25, 2023
13 checks passed
@SmallJoker
Copy link
Member

👍 LGTM

cx384 pushed a commit to cx384/minetest that referenced this pull request Dec 9, 2023
This change is a quick fix so that item tooltips show again on Android.
@grorp grorp deleted the android-fix-item-tooltips branch December 18, 2023 16:40
kawogi pushed a commit to kawogi/minetest that referenced this pull request Dec 19, 2023
This change is a quick fix so that item tooltips show again on Android.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants