MCPcopy Create free account
hub / github.com/antvis/F2Native / OnPress

Method OnPress

core/graphics/tooltip/TooltipController.cpp:95–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95bool tooltip::ToolTipController::OnPress(event::Event &event) {
96 if (isTooltips()) {
97 if (this->toolTips_.size() == 0) {
98 return false;
99 }
100
101 util::Point point = event.points[0];
102 point.x = fmax(chart_->GetCoord().GetXAxis().x, fmin(chart_->GetCoord().GetXAxis().y, point.x));
103 point.y = fmax(chart_->GetCoord().GetYAxis().y, fmin(chart_->GetCoord().GetYAxis().x, point.y));
104
105 auto currentTime = xg::CurrentTimestampAtMM();
106 auto deltaTime = currentTime - lastShowTimeStamp_;
107 if (deltaTime > 32) {
108 chart_->GetLogTracer()->trace("%s delta: %lu", "#ToolTipController onPress startShowTooltips", deltaTime);
109 bool ret = this->ShowToolTips(point);
110 this->lastShowTimeStamp_ = currentTime;
111 return ret;
112 }
113 } else {
114 // chart_->GetLogTracer()->trace("%s", "#ToolTipController onPress");
115 if(this->toolTip_.get() == nullptr)
116 return false;
117
118 util::Point point = event.points[0];
119 point.x = fmax(chart_->GetCoord().GetXAxis().x, fmin(chart_->GetCoord().GetXAxis().y, point.x));
120 point.y = fmax(chart_->GetCoord().GetYAxis().y, fmin(chart_->GetCoord().GetYAxis().x, point.y));
121 // bool alwaysShow = config_["alwaysShow"];
122 // if(!chart_->coord_->IsContains(point.x, point.y)) {
123 // chart_->GetLogTracer()->trace("%s", "#ToolTipController onPress interrupted.");
124 // if(!alwaysShow) {
125 // return this->HideToolTip();
126 // }
127 // return false;
128 // }
129
130 auto currentTime = xg::CurrentTimestampAtMM();
131 auto deltaTime = currentTime - lastShowTimeStamp_;
132 if(deltaTime > 32) {
133 chart_->GetLogTracer()->trace("%s delta: %lu", "#ToolTipController onPress startShowTooltip", deltaTime);
134 bool ret = this->ShowToolTip(point);
135 this->lastShowTimeStamp_ = currentTime;
136 return ret;
137 }
138 }
139 return false;
140}
141
142bool tooltip::ToolTipController::OnPressEnd(event::Event &event) {
143 chart_->GetLogTracer()->trace("%s", "#ToolTipController onPressend");

Callers

nothing calls this directly

Calls 9

ShowToolTipsMethod · 0.95
ShowToolTipMethod · 0.95
CurrentTimestampAtMMFunction · 0.85
traceMethod · 0.80
GetLogTracerMethod · 0.80
sizeMethod · 0.45
GetXAxisMethod · 0.45
GetYAxisMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected