CRhinoObject* CRhinoRectangleGrips::NewObject() { UpdateRectangle(); CRhinoRectangleObject* pNewObject = 0; if (m_bGripsMoved && m_bDrawRectangle) { CRhinoRectangleObject* pOldObject = RectangleObject(); if (pOldObject) pNewObject = new CRhinoRectangleObject(*pOldObject); else pNewObject = new CRhinoRectangleObject(); ON_PolylineCurve rectangle_curve(m_rectangle); // Copy any user data from the original curve to the new curve if (pOldObject && pOldObject->Curve() && pOldObject->Curve()->FirstUserData()) rectangle_curve.CopyUserData(*pOldObject->Curve()); pNewObject->SetCurve(rectangle_curve); } return pNewObject; }
/* ================ rvGEWorkspace::Scroll Adjusts the given scrollbar by the given offset ================ */ void rvGEWorkspace::Scroll ( int scrollbar, int offset ) { SCROLLINFO si; if ( scrollbar == SB_HORZ && !mScrollHorz ) { return; } else if ( scrollbar == SB_VERT && !mScrollVert ) { return; } // Get all the vertial scroll bar information si.cbSize = sizeof (si); si.fMask = SIF_ALL; // Save the position for comparison later on GetScrollInfo ( mWnd, scrollbar, &si); si.nPos += (1000 * offset); if ( si.nPos < si.nMin ) si.nPos = si.nMin; if ( si.nPos > si.nMax ) si.nPos = si.nMax; si.fMask = SIF_POS; SetScrollInfo (mWnd, scrollbar, &si, TRUE); GetScrollInfo (mWnd, scrollbar, &si); UpdateRectangle ( ); }
void RectangleEditor::HandleLeftRelease(const vec2& pos) { if (m_pointControllerIndex != -1) { m_pointControllers[m_pointControllerIndex].SetActive(false); m_pointControllerIndex = -1; } m_isDragging = false; UpdateRectangle(); }
int rvGEWorkspace::HandleScroll ( int scrollbar, WPARAM wParam, LPARAM lParam ) { SCROLLINFO si; // Get all the vertial scroll bar information si.cbSize = sizeof (si); si.fMask = SIF_ALL; // Save the position for comparison later on GetScrollInfo ( mWnd, scrollbar, &si); switch (LOWORD (wParam)) { // user clicked left or up arrow case SB_LINELEFT: si.nPos -= 1000; break; // user clicked right or down arrow case SB_LINERIGHT: si.nPos += 1000; break; // user clicked shaft left of the scroll box case SB_PAGELEFT: si.nPos -= si.nPage; break; // user clicked shaft right of the scroll box case SB_PAGERIGHT: si.nPos += si.nPage; break; // user dragged the scroll box case SB_THUMBTRACK: si.nPos = si.nTrackPos; break; default : break; } // Set the position and then retrieve it. Due to adjustments // by Windows it may not be the same as the value set. si.fMask = SIF_POS; SetScrollInfo (mWnd, scrollbar, &si, TRUE); GetScrollInfo (mWnd, scrollbar, &si); UpdateRectangle ( ); return 0; }
void CRhinoRectangleGrips::Draw( CRhinoDrawGripsSettings& dgs ) { UpdateRectangle(); if ( m_bDrawRectangle && dgs.m_bDrawDynamicStuff ) { const int count = m_rectangle.Count(); const ON_3dPoint* P = m_rectangle.Array(); int i; for( i = 1; i < count; i++ ) dgs.m_vp.DrawLine( P[i-1],P[i] ); } CRhinoObjectGrips::Draw(dgs); }
bool RectangleEditor::HandlePositionChange(const vec2& pos, const vec2& delta) { for (size_t i = 0; i < m_pointControllers.size(); ++i) { m_pointControllers[i].SetFocused(m_pointControllers[i].InCursor(pos)); } bool changed = false; if (m_pointControllerIndex != -1) { m_pointControllers[m_pointControllerIndex].HandleMouseMove(pos, delta); changed = true; } else if (m_isDragging) { m_vertecies[0] += delta; m_vertecies[1] += delta; changed = true; } if (changed) { UpdateRectangle(); } return changed; }
void WidgetLayout::Update() { RectF parentWorldRect; Vec2F parentWorldPosition; if (mData->owner->mParentWidget) { parentWorldRect = mData->owner->mParentWidget->mChildrenWorldRect; RectF notWidgetWorldRect = mData->owner->mParentWidget->transform->mData->worldRectangle; parentWorldPosition = notWidgetWorldRect.LeftBottom() + mData->owner->mParentWidget->transform->mData->pivot*notWidgetWorldRect.Size(); } else if (mData->owner->mParent) { parentWorldRect = mData->owner->mParent->transform->mData->worldRectangle; parentWorldPosition = parentWorldRect.LeftBottom() + mData->owner->mParent->transform->mData->pivot*parentWorldRect.Size(); } RectF worldRectangle(parentWorldRect.LeftBottom() + mData->offsetMin + mData->anchorMin*parentWorldRect.Size(), parentWorldRect.LeftBottom() + mData->offsetMax + mData->anchorMax*parentWorldRect.Size()); mData->size = worldRectangle.Size(); mData->position = worldRectangle.LeftBottom() - parentWorldPosition + mData->size*mData->pivot; (this->*mCheckMinMaxFunc)(); FloorRectangle(); UpdateRectangle(); UpdateTransform(); UpdateWorldRectangleAndTransform(); mData->updateFrame = mData->dirtyFrame; if (mData->owner) { mData->owner->mChildrenWorldRect = mData->worldRectangle; mData->owner->OnTransformUpdated(); } }
/* ================ rvGESelectionMgr::HitTest Test to see if the given coordinate is within the selection rectangle and if it is see what its over. ================ */ rvGESelectionMgr::EHitTest rvGESelectionMgr::HitTest ( float x, float y ) { if ( !mSelections.Num ( ) ) { return HT_NONE; } UpdateRectangle ( ); // Inside the rectangle is moving if ( mRect.Contains ( x, y ) ) { return mExpression?HT_SELECT:HT_MOVE; } if ( mExpression ) { return HT_NONE; } // Check for top left sizing if ( idRectangle ( mRect.x - GUIED_GRABSIZE, mRect.y - GUIED_GRABSIZE, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) ) { return HT_SIZE_TOPLEFT; } // Check for left sizing if ( idRectangle ( mRect.x - GUIED_GRABSIZE, mRect.y + mRect.h / 2 - GUIED_GRABSIZE / 2, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) ) { return HT_SIZE_LEFT; } // Check for bottom left sizing if ( idRectangle ( mRect.x - GUIED_GRABSIZE, mRect.y + mRect.h, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) ) { return HT_SIZE_BOTTOMLEFT; } // Check for bottom sizing if ( idRectangle ( mRect.x + mRect.w / 2 - GUIED_GRABSIZE / 2, mRect.y + mRect.h, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) ) { return HT_SIZE_BOTTOM; } // Check for bottom right sizing if ( idRectangle ( mRect.x + mRect.w, mRect.y + mRect.h, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) ) { return HT_SIZE_BOTTOMRIGHT; } // Check for right sizing if ( idRectangle ( mRect.x + mRect.w, mRect.y + mRect.h / 2 - GUIED_GRABSIZE / 2, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) ) { return HT_SIZE_RIGHT; } // Check for top right sizing if ( idRectangle ( mRect.x + mRect.w, mRect.y - GUIED_GRABSIZE, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) ) { return HT_SIZE_TOPRIGHT; } // Check for top sizing if ( idRectangle ( mRect.x + mRect.w / 2 - GUIED_GRABSIZE / 2, mRect.y - GUIED_GRABSIZE, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) ) { return HT_SIZE_TOP; } return HT_NONE; }
/* ================ rvGESelectionMgr::Render Render the selections including the move/size bars ================ */ void rvGESelectionMgr::Render ( void ) { if ( !mSelections.Num ( ) ) { return; } qglEnable(GL_BLEND); qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); UpdateRectangle ( ); qglPolygonMode(GL_FRONT_AND_BACK, GL_LINE ); idVec4& color = gApp.GetOptions().GetSelectionColor ( ); qglColor4f ( color[0],color[1],color[2], 1.0f ); qglBegin(GL_LINE_LOOP ); qglVertex2f ( mRect.x, mRect.y ); qglVertex2f ( mRect.x + mRect.w, mRect.y ); qglVertex2f ( mRect.x + mRect.w, mRect.y + mRect.h); qglVertex2f ( mRect.x, mRect.y + mRect.h); qglEnd ( ); qglColor4f ( color[0],color[1],color[2], 0.75f ); int i; for ( i = 0; i < mSelections.Num(); i ++ ) { rvGEWindowWrapper* wrapper; idRectangle rect; wrapper = rvGEWindowWrapper::GetWrapper ( mSelections[i] ); assert ( wrapper ); rect = wrapper->GetScreenRect ( ); mWorkspace->WorkspaceToWindow ( rect ); if ( i == 0 ) { qglPolygonMode(GL_FRONT_AND_BACK, GL_FILL ); qglBegin ( GL_TRIANGLES ); qglVertex2f ( rect.x, rect.y ); qglVertex2f ( rect.x + GUIED_GRABSIZE, rect.y ); qglVertex2f ( rect.x, rect.y + GUIED_GRABSIZE ); qglEnd ( ); } qglPolygonMode(GL_FRONT_AND_BACK, GL_LINE ); qglBegin(GL_LINE_LOOP ); qglVertex2f ( rect.x, rect.y ); qglVertex2f ( rect.x + rect.w, rect.y ); qglVertex2f ( rect.x + rect.w, rect.y + rect.h); qglVertex2f ( rect.x, rect.y + rect.h); qglEnd ( ); qglPolygonMode(GL_FRONT_AND_BACK, GL_FILL ); qglBegin( GL_QUADS ); qglVertex2f ( rect.x + (rect.w - GUIED_CENTERSIZE) / 2, rect.y + (rect.h - GUIED_CENTERSIZE) / 2 ); qglVertex2f ( rect.x + (rect.w + GUIED_CENTERSIZE) / 2, rect.y + (rect.h - GUIED_CENTERSIZE) / 2 ); qglVertex2f ( rect.x + (rect.w + GUIED_CENTERSIZE) / 2, rect.y + (rect.h + GUIED_CENTERSIZE) / 2 ); qglVertex2f ( rect.x + (rect.w - GUIED_CENTERSIZE) / 2, rect.y + (rect.h + GUIED_CENTERSIZE) / 2 ); qglEnd ( ); } if ( mExpression ) { return; } qglPolygonMode(GL_FRONT_AND_BACK, GL_LINE ); qglColor4f ( color[0],color[1],color[2], 1.0f ); qglBegin(GL_QUADS); // Top Left qglVertex2f ( mRect.x - GUIED_GRABSIZE, mRect.y - GUIED_GRABSIZE ); qglVertex2f ( mRect.x - 1, mRect.y - GUIED_GRABSIZE ); qglVertex2f ( mRect.x - 1, mRect.y - 1 ); qglVertex2f ( mRect.x - GUIED_GRABSIZE, mRect.y - 1 ); // Left qglVertex2f ( mRect.x - GUIED_GRABSIZE, mRect.y + mRect.h / 2 - GUIED_GRABSIZE / 2); qglVertex2f ( mRect.x - 1, mRect.y + mRect.h / 2 - GUIED_GRABSIZE / 2 ); qglVertex2f ( mRect.x - 1, mRect.y + mRect.h / 2 + GUIED_GRABSIZE / 2 ); qglVertex2f ( mRect.x - GUIED_GRABSIZE, mRect.y + mRect.h / 2 + GUIED_GRABSIZE / 2 ); // Bototm Left qglVertex2f ( mRect.x - GUIED_GRABSIZE, mRect.y + mRect.h + 1 ); qglVertex2f ( mRect.x - 1, mRect.y + mRect.h + 1 ); qglVertex2f ( mRect.x - 1, mRect.y + mRect.h + GUIED_GRABSIZE ); qglVertex2f ( mRect.x - GUIED_GRABSIZE, mRect.y + mRect.h + GUIED_GRABSIZE ); // Bottom qglVertex2f ( mRect.x - GUIED_GRABSIZE / 2 + mRect.w / 2, mRect.y + mRect.h + 1 ); qglVertex2f ( mRect.x + GUIED_GRABSIZE / 2 + mRect.w / 2, mRect.y + mRect.h + 1 ); qglVertex2f ( mRect.x + GUIED_GRABSIZE / 2 + mRect.w / 2, mRect.y + mRect.h + GUIED_GRABSIZE ); qglVertex2f ( mRect.x - GUIED_GRABSIZE / 2 + mRect.w / 2, mRect.y + mRect.h + GUIED_GRABSIZE ); // Bottom Right qglVertex2f ( mRect.x + mRect.w + 1, mRect.y + mRect.h + 1 ); qglVertex2f ( mRect.x + mRect.w + GUIED_GRABSIZE, mRect.y + mRect.h + 1 ); qglVertex2f ( mRect.x + mRect.w + GUIED_GRABSIZE, mRect.y + mRect.h + GUIED_GRABSIZE ); qglVertex2f ( mRect.x + mRect.w + 1, mRect.y + mRect.h + GUIED_GRABSIZE ); // Right qglVertex2f ( mRect.x + mRect.w + 1, mRect.y + mRect.h / 2 - GUIED_GRABSIZE / 2); qglVertex2f ( mRect.x + mRect.w + GUIED_GRABSIZE, mRect.y + mRect.h / 2 - GUIED_GRABSIZE / 2 ); qglVertex2f ( mRect.x + mRect.w + GUIED_GRABSIZE, mRect.y + mRect.h / 2 + GUIED_GRABSIZE / 2 ); qglVertex2f ( mRect.x + mRect.w + 1, mRect.y + mRect.h / 2 + GUIED_GRABSIZE / 2 ); // Top Right qglVertex2f ( mRect.x + mRect.w + 1, mRect.y - GUIED_GRABSIZE ); qglVertex2f ( mRect.x + mRect.w + GUIED_GRABSIZE, mRect.y - GUIED_GRABSIZE ); qglVertex2f ( mRect.x + mRect.w + GUIED_GRABSIZE, mRect.y - 1 ); qglVertex2f ( mRect.x + mRect.w + 1, mRect.y - 1 ); // Top qglVertex2f ( mRect.x - GUIED_GRABSIZE / 2 + mRect.w / 2, mRect.y - GUIED_GRABSIZE ); qglVertex2f ( mRect.x + GUIED_GRABSIZE / 2 + mRect.w / 2, mRect.y - GUIED_GRABSIZE ); qglVertex2f ( mRect.x + GUIED_GRABSIZE / 2 + mRect.w / 2, mRect.y - 1 ); qglVertex2f ( mRect.x - GUIED_GRABSIZE / 2 + mRect.w / 2, mRect.y - 1 ); qglEnd ( ); qglPolygonMode(GL_FRONT_AND_BACK, GL_FILL ); }
void APU_INTERNAL::Write( WORD addr, BYTE data ) { switch( addr ) { // CH0,1 rectangle case 0x4000: case 0x4001: case 0x4002: case 0x4003: case 0x4004: case 0x4005: case 0x4006: case 0x4007: WriteRectangle( (addr<0x4004)?0:1, addr, data ); break; // CH2 triangle case 0x4008: case 0x4009: case 0x400A: case 0x400B: WriteTriangle( addr, data ); break; // CH3 noise case 0x400C: case 0x400D: case 0x400E: case 0x400F: WriteNoise( addr, data ); break; // CH4 DPCM case 0x4010: case 0x4011: case 0x4012: case 0x4013: WriteDPCM( addr, data ); break; case 0x4015: reg4015 = data; if( !(data&(1<<0)) ) { ch0.enable = 0; ch0.len_count = 0; } if( !(data&(1<<1)) ) { ch1.enable = 0; ch1.len_count = 0; } if( !(data&(1<<2)) ) { ch2.enable = 0; ch2.len_count = 0; ch2.lin_count = 0; ch2.counter_start = 0; } if( !(data&(1<<3)) ) { ch3.enable = 0; ch3.len_count = 0; } if( !(data&(1<<4)) ) { ch4.enable = 0; ch4.dmalength = 0; } else { ch4.enable = 0xFF; if( !ch4.dmalength ) { ch4.address = ch4.cache_addr; ch4.dmalength = ch4.cache_dmalength; ch4.phaseacc = 0; } } break; case 0x4017: break; // VirtuaNES固有ポート case 0x4018: UpdateRectangle( ch0, (INT)data ); UpdateRectangle( ch1, (INT)data ); UpdateTriangle ( (INT)data ); UpdateNoise ( (INT)data ); break; default: break; } }
/* ================ rvGEWorkspace::UpdateScrollbars Updates the states and the ranges of the scrollbars as well as the rectangle ================ */ void rvGEWorkspace::UpdateScrollbars ( void ) { SCROLLINFO info; // First update the rectangle without applying scroll positions so // we know the real sizes and coordinates UpdateRectangle ( false ); // Setup the veritcal scrollbar info.cbSize = sizeof(info); info.fMask = SIF_RANGE|SIF_PAGE; info.nMax = (mRect.h - mWindowHeight + 10) * 1000 / 2; info.nMin = -info.nMax; info.nPage = (int)((float)info.nMax * (float)((float)mWindowHeight / mRect.h)); info.nMax += info.nPage; // If there is something to scroll then turn on the vertical scroll bar // if its not on and update the scroll info. if ( info.nMax > 0 ) { if ( !mScrollVert ) { mScrollVert = true; ShowScrollBar ( mWnd, SB_VERT, mScrollVert ); } SetScrollInfo ( mWnd, SB_VERT, &info, TRUE ); } // Nothing to scroll, turn off the scrollbar if its on. else if ( mScrollVert ) { mScrollVert = false; SetScrollPos ( mWnd, SB_VERT, 0, FALSE ); ShowScrollBar ( mWnd, SB_VERT, mScrollVert ); } // Setup the horizontal scrollbar info.nMax = (mRect.w - mWindowWidth + 10) * 1000 / 2; info.nMin = -info.nMax; info.nPage = (int)((float)info.nMax * (float)((float)mWindowWidth / mRect.w)); info.nMax += info.nPage; // If there is something to scroll then turn on the vertical scroll bar // if its not on and update the scroll info. if ( info.nMax > 0 ) { if ( !mScrollHorz ) { mScrollHorz = true; ShowScrollBar ( mWnd, SB_HORZ, mScrollHorz ); } SetScrollInfo ( mWnd, SB_HORZ, &info, TRUE ); } // Nothing to scroll, turn off the scrollbar if its on. else if ( mScrollHorz ) { mScrollHorz = false; SetScrollPos ( mWnd, SB_HORZ, 0, FALSE ); ShowScrollBar ( mWnd, SB_HORZ, mScrollHorz ); } // Need to update the rectangle again to take the scrollbar changes into account UpdateRectangle ( true ); }