diff options
Diffstat (limited to 'src/gui/guiHyperText.cpp')
-rw-r--r-- | src/gui/guiHyperText.cpp | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/gui/guiHyperText.cpp b/src/gui/guiHyperText.cpp index 482b74f04..88931cdf9 100644 --- a/src/gui/guiHyperText.cpp +++ b/src/gui/guiHyperText.cpp @@ -107,7 +107,7 @@ ParsedText::ParsedText(const wchar_t *text) m_root_tag.style["underline"] = "false"; m_root_tag.style["halign"] = "left"; m_root_tag.style["color"] = "#EEEEEE"; - m_root_tag.style["hovercolor"] = m_root_tag.style["color"]; + m_root_tag.style["hovercolor"] = "#FF0000"; m_active_tags.push_front(&m_root_tag); m_style = m_root_tag.style; @@ -115,7 +115,6 @@ ParsedText::ParsedText(const wchar_t *text) // Default simple tags definitions StyleList style; - style["hovercolor"] = "#FF0000"; style["color"] = "#0000FF"; style["underline"] = "true"; m_elementtags["action"] = style; @@ -918,20 +917,20 @@ void TextDrawer::place(const core::rect<s32> &dest_rect) // Draw text in a rectangle with a given offset. Items are actually placed in // relative (to upper left corner) coordinates. -void TextDrawer::draw(const core::rect<s32> &dest_rect, +void TextDrawer::draw(const core::rect<s32> &clip_rect, const core::position2d<s32> &dest_offset) { irr::video::IVideoDriver *driver = m_environment->getVideoDriver(); - core::position2d<s32> offset = dest_rect.UpperLeftCorner + dest_offset; + core::position2d<s32> offset = dest_offset; offset.Y += m_voffset; if (m_text.background_type == ParsedText::BACKGROUND_COLOR) - driver->draw2DRectangle(m_text.background_color, dest_rect); + driver->draw2DRectangle(m_text.background_color, clip_rect); for (auto &p : m_text.m_paragraphs) { for (auto &el : p.elements) { core::rect<s32> rect(el.pos + offset, el.dim); - if (!rect.isRectCollided(dest_rect)) + if (!rect.isRectCollided(clip_rect)) continue; switch (el.type) { @@ -948,7 +947,7 @@ void TextDrawer::draw(const core::rect<s32> &dest_rect, if (el.type == ParsedText::ELEMENT_TEXT) el.font->draw(el.text, rect, color, false, true, - &dest_rect); + &clip_rect); if (el.underline && el.drawwidth) { s32 linepos = el.pos.Y + offset.Y + @@ -959,7 +958,7 @@ void TextDrawer::draw(const core::rect<s32> &dest_rect, el.pos.X + offset.X + el.drawwidth, linepos + (el.baseline >> 3)); - driver->draw2DRectangle(color, linerect, &dest_rect); + driver->draw2DRectangle(color, linerect, &clip_rect); } } break; @@ -973,7 +972,7 @@ void TextDrawer::draw(const core::rect<s32> &dest_rect, irr::core::rect<s32>( core::position2d<s32>(0, 0), texture->getOriginalSize()), - &dest_rect, 0, true); + &clip_rect, 0, true); } break; case ParsedText::ELEMENT_ITEM: { @@ -983,7 +982,7 @@ void TextDrawer::draw(const core::rect<s32> &dest_rect, drawItemStack( m_environment->getVideoDriver(), - g_fontengine->getFont(), item, rect, &dest_rect, + g_fontengine->getFont(), item, rect, &clip_rect, m_client, IT_ROT_OTHER, el.angle, el.rotation ); } break; @@ -1054,12 +1053,14 @@ void GUIHyperText::checkHover(s32 X, s32 Y) } } +#ifndef HAVE_TOUCHSCREENGUI if (m_drawer.m_hovertag) RenderingEngine::get_raw_device()->getCursorControl()->setActiveIcon( gui::ECI_HAND); else RenderingEngine::get_raw_device()->getCursorControl()->setActiveIcon( gui::ECI_NORMAL); +#endif } bool GUIHyperText::OnEvent(const SEvent &event) @@ -1075,8 +1076,12 @@ bool GUIHyperText::OnEvent(const SEvent &event) if (event.EventType == EET_GUI_EVENT && event.GUIEvent.EventType == EGET_ELEMENT_LEFT) { m_drawer.m_hovertag = nullptr; - RenderingEngine::get_raw_device()->getCursorControl()->setActiveIcon( - gui::ECI_NORMAL); +#ifndef HAVE_TOUCHSCREENGUI + gui::ICursorControl *cursor_control = + RenderingEngine::get_raw_device()->getCursorControl(); + if (cursor_control->isVisible()) + cursor_control->setActiveIcon(gui::ECI_NORMAL); +#endif } if (event.EventType == EET_MOUSE_INPUT_EVENT) { @@ -1089,6 +1094,7 @@ bool GUIHyperText::OnEvent(const SEvent &event) m_text_scrollpos.Y = -m_vscrollbar->getPos(); m_drawer.draw(m_display_text_rect, m_text_scrollpos); checkHover(event.MouseInput.X, event.MouseInput.Y); + return true; } else if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) { ParsedText::Element *element = getElementAt( @@ -1146,7 +1152,8 @@ void GUIHyperText::draw() m_vscrollbar->setPos(0); m_vscrollbar->setVisible(false); } - m_drawer.draw(m_display_text_rect, m_text_scrollpos); + m_drawer.draw(AbsoluteClippingRect, + m_display_text_rect.UpperLeftCorner + m_text_scrollpos); // draw children IGUIElement::draw(); |