mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 16:40:05 +00:00
Add right click to edit location marker
This commit is contained in:
parent
cfed61c6ff
commit
fc8d65d4d1
3 changed files with 65 additions and 6 deletions
|
|
@ -38,7 +38,7 @@ static constexpr std::size_t kIntegersPerVertex_ = 4;
|
|||
static constexpr std::size_t kIntegerBufferLength_ =
|
||||
kNumTriangles * kVerticesPerTriangle * kIntegersPerVertex_;
|
||||
|
||||
struct GeoIconDrawItem
|
||||
struct GeoIconDrawItem : types::EventHandler
|
||||
{
|
||||
units::length::nautical_miles<double> threshold_ {};
|
||||
std::chrono::sys_time<std::chrono::seconds> startTime_ {};
|
||||
|
|
@ -691,7 +691,7 @@ void GeoIcons::Impl::UpdateSingleBuffer(
|
|||
hoverIcons.end(),
|
||||
[&di](auto& entry) { return entry.di_ == di; });
|
||||
|
||||
if (di->visible_ && !di->hoverText_.empty())
|
||||
if (di->visible_ && (!di->hoverText_.empty() || di->event_ != nullptr))
|
||||
{
|
||||
const units::angle::radians<double> radians = angle;
|
||||
|
||||
|
|
@ -903,7 +903,7 @@ bool GeoIcons::RunMousePicking(
|
|||
const QPointF& mouseGlobalPos,
|
||||
const glm::vec2& mouseCoords,
|
||||
const common::Coordinate& /* mouseGeoCoords */,
|
||||
std::shared_ptr<types::EventHandler>& /* eventHandler */)
|
||||
std::shared_ptr<types::EventHandler>& eventHandler )
|
||||
{
|
||||
std::unique_lock lock {p->iconMutex_};
|
||||
|
||||
|
|
@ -993,12 +993,27 @@ bool GeoIcons::RunMousePicking(
|
|||
if (it != p->currentHoverIcons_.crend())
|
||||
{
|
||||
itemPicked = true;
|
||||
util::tooltip::Show(it->di_->hoverText_, mouseGlobalPos);
|
||||
if (!it->di_->hoverText_.empty())
|
||||
{
|
||||
// Show tooltip
|
||||
util::tooltip::Show(it->di_->hoverText_, mouseGlobalPos);
|
||||
}
|
||||
if (it->di_->event_ != nullptr)
|
||||
{
|
||||
eventHandler = it->di_;
|
||||
}
|
||||
}
|
||||
|
||||
return itemPicked;
|
||||
}
|
||||
|
||||
void GeoIcons::RegisterEventHandler(
|
||||
const std::shared_ptr<GeoIconDrawItem>& di,
|
||||
const std::function<void(QEvent*)>& eventHandler)
|
||||
{
|
||||
di->event_ = eventHandler;
|
||||
}
|
||||
|
||||
} // namespace draw
|
||||
} // namespace gl
|
||||
} // namespace qt
|
||||
|
|
|
|||
|
|
@ -183,6 +183,16 @@ public:
|
|||
*/
|
||||
void FinishIcons();
|
||||
|
||||
/**
|
||||
* Registers an event handler for an icon.
|
||||
*
|
||||
* @param [in] di Icon draw item
|
||||
* @param [in] eventHandler Event handler function
|
||||
*/
|
||||
static void
|
||||
RegisterEventHandler(const std::shared_ptr<GeoIconDrawItem>& di,
|
||||
const std::function<void(QEvent*)>& eventHandler);
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue