Skip to content

Commit

Permalink
WCartesianChart changes:
Browse files Browse the repository at this point in the history
 - Continue drag even when updated while dragging
 - Changed equality check to closeness check for WTransform
  • Loading branch information
RockinRoel committed Aug 20, 2018
1 parent 1bcd99b commit 91542c6
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 30 deletions.
2 changes: 2 additions & 0 deletions src/Wt/WJavaScriptExposableObject
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public:
*/
std::string jsRef() const;

bool closeTo(const WJavaScriptExposableObject& other) const { return false; }

protected:
bool sameBindingAs(const WJavaScriptExposableObject &rhs) const;
void assignBinding(const WJavaScriptExposableObject &rhs);
Expand Down
2 changes: 1 addition & 1 deletion src/Wt/WJavaScriptHandle
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public:
WJavaScriptExposableObject::JSInfo *binding = value_->clientBinding_;
value_->clientBinding_ = 0;

bool changed = *value_ != v;
bool changed = !value_->closeTo(v);
(*value_) = v;

value_->clientBinding_ = binding;
Expand Down
2 changes: 2 additions & 0 deletions src/Wt/WTransform
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ public:
*/
static const WTransform Identity;

bool closeTo(const WTransform& other) const;

virtual std::string jsValue() const WT_CXX11ONLY(override) ;

protected:
Expand Down
15 changes: 15 additions & 0 deletions src/Wt/WTransform.C
Original file line number Diff line number Diff line change
Expand Up @@ -586,4 +586,19 @@ void WTransform::assignFromJSON(const Json::Value &value)
}
}

bool WTransform::closeTo(const WTransform &other) const
{
if (isJavaScriptBound() || other.isJavaScriptBound())
return false;

static const double EPS = 1E-12;

return std::abs(m_[0] - other.m_[0]) <= EPS &&
std::abs(m_[1] - other.m_[1]) <= EPS &&
std::abs(m_[2] - other.m_[2]) <= EPS &&
std::abs(m_[3] - other.m_[3]) <= EPS &&
std::abs(m_[4] - other.m_[4]) <= EPS &&
std::abs(m_[5] - other.m_[5]) <= EPS;
}

}
4 changes: 3 additions & 1 deletion src/js/WCartesianChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,10 @@ WT_DECLARE_WT_MEMBER_BIG
this.mouseDrag = function(o, event) {
if (pointerActive)
return;
if (dragPreviousXY === null)
if (dragPreviousXY === null) {
self.mouseDown(o, event);
return;
}
var c = WT.widgetCoordinates(target.canvas, event);
if (WT.buttons === 1) {
if (dragCurrentYAxis === -1 && !dragXAxis &&
Expand Down
Loading

0 comments on commit 91542c6

Please sign in to comment.