float ATOM_CurveEditor::coordToKeyValue (int coord) const { int coordInCanvas = coord + getScrollValue().y; unsigned canvasSize = (getClientRect().size.h > getCanvasSize().h) ? getClientRect().size.h : getCanvasSize().h; float origin = canvasSize * _originValueAxis; return (origin - coordInCanvas) / _valueAxisUnitResolution; }
float ATOM_CurveEditor::coordToTimeInSecond (int coord) const { int coordInCanvas = coord + getScrollValue().x; unsigned canvasSize = (getClientRect().size.w > getCanvasSize().w) ? getClientRect().size.w : getCanvasSize().w; float origin = canvasSize * _originTimeAxis; return (coordInCanvas - origin) / _timeAxisUnitResolution; }
//----------------------------------------------------------------------------- void CScrollContainer::onDragMove (IDataPackage* drag, const CPoint& where) { if (autoDragScroll) { float x, y; if (getScrollValue (where, x, y)) { CScrollView* scrollView = static_cast<CScrollView*> (getParentView ()); if (scrollView) { CRect r (getViewSize ()); r.offset (x, y); scrollView->makeRectVisible (r); } } } return CViewContainer::onDragMove (drag, where); }
int ATOM_CurveEditor::timeValueToCoord (float timeInSecond) const { unsigned canvasSize = (getClientRect().size.w > getCanvasSize().w) ? getClientRect().size.w : getCanvasSize().w; return timeInSecond * _timeAxisUnitResolution + canvasSize * _originTimeAxis - getScrollValue().x; }
int ATOM_CurveEditor::keyValueToCoord (float value) const { unsigned canvasSize = (getClientRect().size.h > getCanvasSize().h) ? getClientRect().size.h : getCanvasSize().h; return canvasSize * _originValueAxis - value * _valueAxisUnitResolution - getScrollValue().y; }