Changeset 294 for trunk/Utilities/DirectionControl/MainDialog.h
 Timestamp:
 Jun 13, 2014, 11:21:15 PM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Utilities/DirectionControl/MainDialog.h
r293 r294 82 82 _A((GetStyle() & SS_TYPEMASK) == SS_LEFT); //_A((UINT) ((GetStyle() & SS_TYPEMASK)  SS_LEFT) < (SS_RIGHT  SS_LEFT + 1)); 83 83 //ModifyStyle(0, SS_NOTIFY); 84 _A(GetExStyle() & WS_EX_TRANSPARENT); 84 85 CWindow Parent = GetParent(); 85 86 pT>UpdateLayout(); … … 137 138 return; 138 139 m_nToleranceArrowSize = m_nArrowSize * 3 / 4; 139 m_ArrowHandlePosition = Transform(0, m_nArrowSize  5, m_fAngle);140 m_ToleranceArrowHandlePositionA = Transform(0, m_nToleranceArrowSize  4, m_fAngle  m_fToleranceAngle / 2);141 m_ToleranceArrowHandlePositionB = Transform(0, m_nToleranceArrowSize  4, m_fAngle + m_fToleranceAngle / 2);140 m_ArrowHandlePosition = Transform(0, m_nArrowSize  6, m_fAngle); 141 m_ToleranceArrowHandlePositionA = Transform(0, m_nToleranceArrowSize  6, m_fAngle  m_fToleranceAngle / 2); 142 m_ToleranceArrowHandlePositionB = Transform(0, m_nToleranceArrowSize  6, m_fAngle + m_fToleranceAngle / 2); 142 143 } 143 144 VOID EraseBackground(CDCHandle Dc) … … 223 224 Dc.Ellipse(m_CenterPosition.x  D, m_CenterPosition.y  D, m_CenterPosition.x + D + F, m_CenterPosition.y + D + F); 224 225 } 225 static BOOL Close(POINT PositionA, POINT PositionB, LONG nDistanceThreshold = 6) 226 { 226 static BOOL Close(CPoint PositionA, CPoint PositionB, LONG nDistanceThreshold, CPoint* pRelativePosition = NULL) 227 { 228 if(pRelativePosition) 229 *pRelativePosition = PositionA  PositionB; 227 230 return (PositionA.x  PositionB.x) * (PositionA.x  PositionB.x) + (PositionA.y  PositionB.y) * (PositionA.y  PositionB.y) < (nDistanceThreshold * nDistanceThreshold); 228 231 } 232 UINT DragModeFromPosition(CPoint Position, CPoint* pRelativePosition = NULL) const 233 { 234 if(Close(m_ToleranceArrowHandlePositionA, Position, 6, pRelativePosition)) 235 return 2; 236 if(Close(m_ToleranceArrowHandlePositionB, Position, 6, pRelativePosition)) 237 return 3; 238 if(Close(m_ArrowHandlePosition, Position, 6, pRelativePosition)) 239 return 1; 240 if(Close(m_ToleranceArrowHandlePositionA, Position, 10, pRelativePosition)) 241 return 2; 242 if(Close(m_ToleranceArrowHandlePositionB, Position, 10, pRelativePosition)) 243 return 3; 244 if(Close(m_ArrowHandlePosition, Position, 10, pRelativePosition)) 245 return 1; 246 return 0; 247 } 229 248 DOUBLE GetAngle() const 230 249 { … … 234 253 { 235 254 return m_fToleranceAngle; 255 } 256 VOID SetAngle(DOUBLE fAngle) 257 { 258 T* pT = static_cast<T*>(this); 259 if(m_fAngle == fAngle) 260 return; 261 m_fAngle = fAngle; 262 m_nVersion++; 263 if(!pT>IsWindow()) 264 return; 265 pT>UpdateLayout(); 266 pT>Invalidate(); 267 } 268 VOID SetToleranceAngle(DOUBLE fToleranceAngle) 269 { 270 T* pT = static_cast<T*>(this); 271 if(m_fToleranceAngle == fToleranceAngle) 272 return; 273 m_fToleranceAngle = fToleranceAngle; 274 m_nVersion++; 275 if(!pT>IsWindow()) 276 return; 277 pT>UpdateLayout(); 278 pT>Invalidate(); 236 279 } 237 280 … … 326 369 { 327 370 _W(ScreenToClient(&Position)); 328 if(Close(m_ArrowHandlePosition, Position)  Close(m_ToleranceArrowHandlePositionA, Position)  Close(m_ToleranceArrowHandlePositionB, Position)) 371 const UINT nDragMode = DragModeFromPosition(Position); 372 if(nDragMode) 329 373 { 330 374 ::SetCursor(AtlLoadSysCursor(IDC_SIZEALL)); … … 352 396 CPoint AlignPosition = Position  m_DragRelativeButtonDownPosition; 353 397 const DOUBLE fAngle = atan2((DOUBLE) (Position.y  m_CenterPosition.y), (DOUBLE) (Position.x  m_CenterPosition.x)) + M_PI / 2; 354 m_fToleranceAngle = 2 * abs(fAngle  m_fAngle); 398 DOUBLE fToleranceAngle = abs(fAngle  m_fAngle); 399 if(fToleranceAngle > M_PI) 400 fToleranceAngle = 2 * M_PI  fToleranceAngle; 401 _A(fToleranceAngle >= 0 && fToleranceAngle <= M_PI); 402 m_fToleranceAngle = 2 * fToleranceAngle; 355 403 m_nVersion++; 356 404 } … … 360 408 CPoint AlignPosition = Position  m_DragRelativeButtonDownPosition; 361 409 const DOUBLE fAngle = atan2((DOUBLE) (Position.y  m_CenterPosition.y), (DOUBLE) (Position.x  m_CenterPosition.x)) + M_PI / 2; 362 m_fToleranceAngle = 2 * abs(fAngle  m_fAngle); 410 DOUBLE fToleranceAngle = abs(fAngle  m_fAngle); 411 if(fToleranceAngle > M_PI) 412 fToleranceAngle = 2 * M_PI  fToleranceAngle; 413 _A(fToleranceAngle >= 0 && fToleranceAngle <= M_PI); 414 m_fToleranceAngle = 2 * fToleranceAngle; 363 415 m_nVersion++; 364 416 } … … 384 436 if(!(nButton & MK_LBUTTON)) 385 437 return 0; 386 m_nDragMode = 0; 387 if(Close(m_ToleranceArrowHandlePositionA, Position)) 388 { 389 m_nDragMode = 2; 390 m_DragRelativeButtonDownPosition = Position  m_ToleranceArrowHandlePositionA; 391 } else if(Close(m_ToleranceArrowHandlePositionB, Position)) 392 { 393 m_nDragMode = 3; 394 m_DragRelativeButtonDownPosition = Position  m_ToleranceArrowHandlePositionB; 395 } else if(Close(m_ArrowHandlePosition, Position)) 396 { 397 m_nDragMode = 1; 398 m_DragRelativeButtonDownPosition = Position  m_ArrowHandlePosition; 399 } else 438 CPoint RelativePosition; 439 m_nDragMode = DragModeFromPosition(Position, &RelativePosition); 440 if(!m_nDragMode) 400 441 return 0; 442 m_DragButtonDownPosition = Position; 443 m_DragRelativeButtonDownPosition = RelativePosition; 401 444 m_nDragVersion = m_nVersion; 402 m_DragButtonDownPosition = Position;403 445 SetCapture(); 404 446 ::SetCursor(AtlLoadSysCursor(IDC_SIZEALL));
Note: See TracChangeset
for help on using the changeset viewer.