Disable URL highlight on some widgets and screens

This commit is contained in:
Benau 2021-09-06 14:33:23 +08:00
parent ae98b0cf9b
commit 5d5292787e
5 changed files with 16 additions and 5 deletions

View File

@ -1500,7 +1500,9 @@ namespace GUIEngine
core::rect<s32> tipRect(core::position2d<s32>(0, y_from - text_height),
core::dimension2d<s32>(screen_w, text_height));
GL32_draw2DRectangle(Skin::getColor("tips_background::neutral"), tipRect);
Private::g_font->draw(g_tips_string, tipRect,
std::vector<GlyphLayout> gls;
Private::g_font->initGlyphLayouts(g_tips_string, gls, gui::SF_DISABLE_URL_HIGHLIGHT);
Private::g_font->draw(gls, tipRect,
Skin::getColor("brighttext::neutral"),
true /* hcenter */, true /* vcenter */);
}

View File

@ -953,7 +953,7 @@ void CGUIEditBox::draw()
const s32 realcbgn = m_cursor_pos;
const s32 realcend = m_cursor_pos + (s32)m_composing_text.size();
total.insert(m_cursor_pos, m_composing_text);
font_manager->shape(total, ct);
font_manager->shape(total, ct, gui::SF_DISABLE_URL_HIGHLIGHT);
for (unsigned i = 0; i < ct.size(); i++)
{
GlyphLayout& glyph = ct[i];
@ -1542,7 +1542,7 @@ void CGUIEditBox::updateGlyphLayouts()
m_glyph_layouts);
}
else
font_manager->shape(m_edit_text, m_glyph_layouts);
font_manager->shape(m_edit_text, m_glyph_layouts, gui::SF_DISABLE_URL_HIGHLIGHT);
Text = StringUtils::utf32ToWide(m_edit_text);
#endif
}

View File

@ -590,6 +590,9 @@ void CGUISTKListBox::draw()
int text_width = (textRect.LowerRightCorner.X - textRect.UpperLeftCorner.X);
Font->initGlyphLayouts(Items[i].m_contents[x].m_text,
Items[i].m_contents[x].m_glyph_layouts);
// Remove highlighted link if cache already has it
for (gui::GlyphLayout& gl : Items[i].m_contents[x].m_glyph_layouts)
gl.flags &= ~gui::GLF_URL;
if (Items[i].m_word_wrap)
{
gui::breakGlyphLayouts(Items[i].m_contents[x].m_glyph_layouts,

View File

@ -64,7 +64,10 @@ ServerInfoDialog::ServerInfoDialog(std::shared_ptr<Server> server)
(file_manager->getAsset(FileManager::GUI_ICON, "remove.png"));
loadFromFile("online/server_info_dialog.stkgui");
getWidget<LabelWidget>("title")->setText(server->getName(), true);
LabelWidget* title = getWidget<LabelWidget>("title");
title->setText(server->getName(), true);
// Make sure server name is not clickable for URL
title->getIrrlichtElement<IGUIStaticText>()->setMouseCallback(nullptr);
m_options_widget = getWidget<RibbonWidget>("options");
assert(m_options_widget != NULL);

View File

@ -346,7 +346,8 @@ void NetworkingLobby::addMoreServerInfo(core::stringw info)
const unsigned box_width = m_text_bubble->getDimension().Width;
const float box_height = m_text_bubble->getDimension().Height;
std::vector<GlyphLayout> cur_info;
font_manager->initGlyphLayouts(info, cur_info, gui::SF_DISABLE_CACHE);
font_manager->initGlyphLayouts(info, cur_info, gui::SF_DISABLE_CACHE |
gui::SF_DISABLE_URL_HIGHLIGHT);
gui::IGUIFont* font = GUIEngine::getFont();
gui::breakGlyphLayouts(cur_info, box_width,
font->getInverseShaping(), font->getScale());
@ -978,4 +979,6 @@ void NetworkingLobby::setHeader(const core::stringw& header)
m_header->add();
m_header->setText(header, true);
}
// Make sure server name is not clickable for URL
m_header->getIrrlichtElement<IGUIStaticText>()->setMouseCallback(nullptr);
} // setHeader