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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/gui/guiFormSpecMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3633,7 +3633,7 @@ void GUIFormSpecMenu::drawMenu()
NULL, m_client, IT_ROT_HOVERED);
}

/* TODO find way to show tooltips on touchscreen */
// On touchscreens, m_pointer is set by GUIModalMenu::preprocessEvent instead.
#ifndef HAVE_TOUCHSCREENGUI
m_pointer = RenderingEngine::get_raw_device()->getCursorControl()->getPosition();
#endif
Expand Down
21 changes: 14 additions & 7 deletions src/gui/guiInventoryList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ void GUIInventoryList::draw()
(i / m_geom.X) * m_slot_spacing.Y);
core::rect<s32> rect = imgrect + base_pos + p;
ItemStack item = ilist->getItem(item_i);
ItemStack orig_item = item;

bool selected = selected_item
&& m_invmgr->getInventory(selected_item->inventoryloc) == inv
Expand Down Expand Up @@ -147,13 +148,19 @@ void GUIInventoryList::draw()
// Draw item stack
drawItemStack(driver, m_font, item, rect, &AbsoluteClippingRect,
client, rotation_kind);
// Add hovering tooltip
if (hovering && !selected_item) {
std::string tooltip = item.getDescription(client->idef());
if (m_fs_menu->doTooltipAppendItemname())
tooltip += "\n[" + item.name + "]";
m_fs_menu->addHoveredItemTooltip(tooltip);
}
}

// Add hovering tooltip
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;
#endif
if (show_tooltip) {
std::string tooltip = orig_item.getDescription(client->idef());
if (m_fs_menu->doTooltipAppendItemname())
tooltip += "\n[" + orig_item.name + "]";
m_fs_menu->addHoveredItemTooltip(tooltip);
}
}

Expand Down