mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 18:00:06 +00:00
Move placefile text hover to mouse picking pass
This commit is contained in:
parent
38b56be7c4
commit
37d751774d
2 changed files with 27 additions and 6 deletions
|
|
@ -55,6 +55,7 @@ public:
|
|||
float halfWidth_ {};
|
||||
float halfHeight_ {};
|
||||
ImFont* monospaceFont_ {};
|
||||
std::string hoverText_ {};
|
||||
|
||||
units::length::nautical_miles<double> mapDistance_ {};
|
||||
|
||||
|
|
@ -94,6 +95,7 @@ void PlacefileText::Render(
|
|||
{
|
||||
// Reset text ID per frame
|
||||
p->textId_ = 0;
|
||||
p->hoverText_.clear();
|
||||
|
||||
// Update map screen coordinate and scale information
|
||||
p->mapScreenCoordLocation_ = util::maplibre::LatLongToScreenCoordinate(
|
||||
|
|
@ -189,14 +191,10 @@ void PlacefileText::Impl::RenderText(
|
|||
ImGui::TextUnformatted(text.c_str());
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
// Create tooltip for hover text
|
||||
// Store hover text for mouse picking pass
|
||||
if (!hoverText.empty() && ImGui::IsItemHovered())
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushFont(monospaceFont_);
|
||||
ImGui::TextUnformatted(hoverText.c_str());
|
||||
ImGui::PopFont();
|
||||
ImGui::EndTooltip();
|
||||
hoverText_ = hoverText;
|
||||
}
|
||||
|
||||
// End window
|
||||
|
|
@ -211,6 +209,26 @@ void PlacefileText::Deinitialize()
|
|||
p->textList_.clear();
|
||||
}
|
||||
|
||||
bool PlacefileText::RunMousePicking(
|
||||
const QMapLibreGL::CustomLayerRenderParameters& /* params */)
|
||||
{
|
||||
bool itemPicked = false;
|
||||
|
||||
// Create tooltip for hover text
|
||||
if (!p->hoverText_.empty())
|
||||
{
|
||||
itemPicked = true;
|
||||
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushFont(p->monospaceFont_);
|
||||
ImGui::TextUnformatted(p->hoverText_.c_str());
|
||||
ImGui::PopFont();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
return itemPicked;
|
||||
}
|
||||
|
||||
void PlacefileText::StartText()
|
||||
{
|
||||
// Clear the new list
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ public:
|
|||
void Render(const QMapLibreGL::CustomLayerRenderParameters& params) override;
|
||||
void Deinitialize() override;
|
||||
|
||||
bool RunMousePicking(
|
||||
const QMapLibreGL::CustomLayerRenderParameters& params) override;
|
||||
|
||||
/**
|
||||
* Resets and prepares the draw item for adding a new set of text.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue