Exemplo n.º 1
0
void CRevisionGraphWnd::UnifiedDiffRevs(bool bHead)
{
    ASSERT(m_SelectedEntry1 != NULL);
    ASSERT(m_SelectedEntry2 != NULL);

    CSyncPointer<SVN> svn (m_state.GetSVN());

    CTSVNPath url1;
    CTSVNPath url2;
    SVNRev rev1;
    SVNRev rev2;
    SVNRev peg;

    GetSelected (m_SelectedEntry1, bHead, url1, rev1, peg);
    GetSelected (m_SelectedEntry2, bHead, url2, rev2, peg);

    bool alternativeTool = !!(GetAsyncKeyState(VK_SHIFT) & 0x8000);
    if (m_state.PromptShown())
    {
        SVNDiff diff (svn.get(), this->m_hWnd);
        diff.SetAlternativeTool (alternativeTool);
        diff.ShowUnifiedDiff (url1, rev1, url2, rev2, peg, L"");
    }
    else
    {
        CAppUtils::StartShowUnifiedDiff(m_hWnd, url1, rev1,
            url2, rev2, peg,
            SVNRev(), L"", alternativeTool);
    }
}
void CRevisionGraphWnd::DrawGlyphs
	( GraphicsDevice& graphics
	, Image* glyphs
	, const CVisibleGraphNode* node
	, const PointF& center
	, GlyphType glyph1
	, GlyphType glyph2
	, GlyphPosition position
	, DWORD state1
	, DWORD state2
	, bool showAll)
{
	// don't show collapse and cut glyths by default

	if (!showAll && ((glyph1 == CollapseGlyph) || (glyph1 == SplitGlyph)))
		glyph1 = NoGlyph;
	if (!showAll && ((glyph2 == CollapseGlyph) || (glyph2 == SplitGlyph)))
		glyph2 = NoGlyph;

	// glyth2 shall be set only if 2 glyphs are in use

	if (glyph1 == NoGlyph)
	{
		std::swap (glyph1, glyph2);
		std::swap (state1, state2);
	}

	// anything to do?

	if (glyph1 == NoGlyph)
		return;

	// 1 or 2 glyphs?

	CSyncPointer<CRevisionGraphState::TVisibleGlyphs>
		visibleGlyphs (m_state.GetVisibleGlyphs());

	float squareSize = GLYPH_SIZE * m_fZoomFactor;
	if (glyph2 == NoGlyph)
	{
		PointF leftTop (center.X - 0.5f * squareSize, center.Y - 0.5f * squareSize);
		DrawGlyph (graphics, glyphs, leftTop, glyph1, position);
		visibleGlyphs->push_back
			(CRevisionGraphState::SVisibleGlyph (state1, leftTop, node));
	}
	else
	{
		PointF leftTop1 (center.X - squareSize, center.Y - 0.5f * squareSize);
		DrawGlyph (graphics, glyphs, leftTop1, glyph1, position);
		visibleGlyphs->push_back
			(CRevisionGraphState::SVisibleGlyph (state1, leftTop1, node));

		PointF leftTop2 (center.X, center.Y - 0.5f * squareSize);
		DrawGlyph (graphics, glyphs, leftTop2, glyph2, position);
		visibleGlyphs->push_back
			(CRevisionGraphState::SVisibleGlyph (state2, leftTop2, node));
	}

}
Exemplo n.º 3
0
BOOL CRevisionGraphDlg::OnInitDialog()
{
    CResizableStandAloneDialog::OnInitDialog();
    CAppUtils::MarkWindowAsUnpinnable(m_hWnd);

    EnableToolTips();

    // begin background operation

    StartWorkerThread();

    // set up the status bar
    m_StatusBar.Create(WS_CHILD|WS_VISIBLE|SBT_OWNERDRAW,
        CRect(0,0,0,0), this, 1);
    int strPartDim[2]= {120, -1};
    m_StatusBar.SetParts(2, strPartDim);

    if (InitializeToolbar() != TRUE)
        return FALSE;

    m_pTaskbarList.Release();
    m_pTaskbarList.CoCreateInstance(CLSID_TaskbarList);

    CSyncPointer<CAllRevisionGraphOptions>
        options (m_Graph.m_state.GetOptions());

    for (size_t i = 0; i < options->count(); ++i)
        if ((*options)[i]->CommandID() != 0)
            SetOption ((*options)[i]->CommandID());

    CMenu * pMenu = GetMenu();
    if (pMenu)
    {
        CRegDWORD reg = CRegDWORD(L"Software\\TortoiseSVN\\ShowRevGraphOverview", FALSE);
        m_Graph.SetShowOverview ((DWORD)reg != FALSE);
        pMenu->CheckMenuItem(ID_VIEW_SHOWOVERVIEW, MF_BYCOMMAND | (DWORD(reg) ? MF_CHECKED : 0));
        int tbstate = m_ToolBar.GetToolBarCtrl().GetState(ID_VIEW_SHOWOVERVIEW);
        m_ToolBar.GetToolBarCtrl().SetState(ID_VIEW_SHOWOVERVIEW, tbstate | (DWORD(reg) ? TBSTATE_CHECKED : 0));
    }

    m_hAccel = LoadAccelerators(AfxGetResourceHandle(),MAKEINTRESOURCE(IDR_ACC_REVISIONGRAPH));

    CRect graphrect = GetGraphRect();
    m_Graph.Init(this, &graphrect);
    m_Graph.SetOwner(this);
    m_Graph.UpdateWindow();
    DoZoom (DEFAULT_ZOOM);

    EnableSaveRestore(L"RevisionGraphDlg");
    if (GetExplorerHWND())
        CenterWindow(CWnd::FromHandle(GetExplorerHWND()));

    return TRUE;  // return TRUE unless you set the focus to a control
}
size_t CRevisionGraphState::GetTreeCount() const
{
    CSingleLock lock (&mutex);

    if (layout.get() == NULL)
        return 0;

    CSyncPointer<const ILayoutRectList> trees
        ( &mutex
        , layout->GetTrees()
        , true);
    return trees->GetCount();
}
void CRevisionGraphWnd::DrawStripes (GraphicsDevice& graphics, const CSize& offset)
{
	// we need to fill this visible area of the the screen
	// (even if there is graph in that part)

	RectF clipRect;
	if (graphics.graphics)
		graphics.graphics->GetVisibleClipBounds (&clipRect);

	// don't show stripes if we don't have multiple roots

	CSyncPointer<const ILayoutRectList> trees (m_state.GetTrees());
	if (trees->GetCount() < 2)
		return;

	// iterate over all trees

	for ( index_t i = 0, count = trees->GetCount(); i < count; ++i)
	{
		// screen coordinates covered by the tree

		CRect tree = trees->GetRect(i);
		REAL left = tree.left * m_fZoomFactor;
		REAL right = tree.right * m_fZoomFactor;
		RectF rect ( left - offset.cx
					, clipRect.Y
					, i+1 == count ? clipRect.Width : right - left
					, clipRect.Height);

		// relevant?

		if (rect.IntersectsWith (clipRect))
		{
			// draw the background stripe

			Color color (  (i & 1) == 0
						? m_Colors.GetColor (CColors::gdpStripeColor1)
						: m_Colors.GetColor (CColors::gdpStripeColor2));
			if (graphics.graphics)
			{
				SolidBrush brush (color);
				graphics.graphics->FillRectangle (&brush, rect);
			}
			else if (graphics.pSVG)
				graphics.pSVG->RoundedRectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height,
												color, 1, color);
		}
	}
}
void CRevisionGraphWnd::DrawShadows (GraphicsDevice& graphics, const CRect& logRect, const CSize& offset)
{
  // shadow color to use

	Color background;
	background.SetFromCOLORREF (GetSysColor(COLOR_WINDOW));
	Color textColor;
	textColor.SetFromCOLORREF (GetSysColor(COLOR_WINDOWTEXT));

	Color shadowColor = LimitedScaleColor (background, ARGB (Color::Black), 0.5f);

	// iterate over all visible nodes

	CSyncPointer<const ILayoutNodeList> nodes (m_state.GetNodes());
	for ( index_t index = nodes->GetFirstVisible (logRect)
		; index != NO_INDEX
		; index = nodes->GetNextVisible (index, logRect))
	{
		// get node and position

		ILayoutNodeList::SNode node = nodes->GetNode (index);
		RectF noderect (GetNodeRect (node, offset));

		// actual drawing

		switch (node.style)
		{
		case ILayoutNodeList::SNode::STYLE_DELETED:
		case ILayoutNodeList::SNode::STYLE_RENAMED:
			DrawShadow (graphics, noderect, shadowColor, TSVNOctangle);
			break;
		case ILayoutNodeList::SNode::STYLE_ADDED:
			DrawShadow(graphics, noderect, shadowColor, TSVNRoundRect);
			break;
		case ILayoutNodeList::SNode::STYLE_LAST:
			DrawShadow(graphics, noderect, shadowColor, TSVNEllipse);
			break;
		default:
			DrawShadow(graphics, noderect, shadowColor, TSVNRectangle);
			break;
		}
	}

}
Exemplo n.º 7
0
BOOL CRevisionGraphDlg::ToggleOption (UINT controlID)
{
    // check request for validity

    if (m_Graph.IsUpdateJobRunning())
    {
        // restore previous state

        int state = m_ToolBar.GetToolBarCtrl().GetState(controlID);
        if (state & TBSTATE_CHECKED)
            state &= ~TBSTATE_CHECKED;
        else
            state |= TBSTATE_CHECKED;
        m_ToolBar.GetToolBarCtrl().SetState (controlID, state);

        return FALSE;
    }

    CMenu * pMenu = GetMenu();
    if (pMenu == NULL)
        return FALSE;

    // actually toggle the option

    int tbstate = m_ToolBar.GetToolBarCtrl().GetState(controlID);
    UINT state = pMenu->GetMenuState(controlID, MF_BYCOMMAND);
    if (state & MF_CHECKED)
    {
        pMenu->CheckMenuItem(controlID, MF_BYCOMMAND | MF_UNCHECKED);
        m_ToolBar.GetToolBarCtrl().SetState(controlID, tbstate & (~TBSTATE_CHECKED));
    }
    else
    {
        pMenu->CheckMenuItem(controlID, MF_BYCOMMAND | MF_CHECKED);
        m_ToolBar.GetToolBarCtrl().SetState(controlID, tbstate | TBSTATE_CHECKED);
    }

    CSyncPointer<CAllRevisionGraphOptions>
        options (m_Graph.m_state.GetOptions());
    if (((state & MF_CHECKED) != 0) == options->IsSelected (controlID))
        options->ToggleSelection (controlID);

    return TRUE;
}
void CRevisionGraphWnd::ClearVisibleGlyphs (const CRect& /*rect*/)
{
#if 0
	float glyphSize = GLYPH_SIZE * m_fZoomFactor;

	CSyncPointer<CRevisionGraphState::TVisibleGlyphs>
		visibleGlyphs (m_state.GetVisibleGlyphs());

	for (size_t i = visibleGlyphs->size(), count = i; i > 0; --i)
	{
		const PointF& leftTop = (*visibleGlyphs)[i-1].leftTop;
		CRect glyphRect ( static_cast<int>(leftTop.X)
						, static_cast<int>(leftTop.Y)
						, static_cast<int>(leftTop.X + glyphSize)
						, static_cast<int>(leftTop.Y + glyphSize));

		if (CRect().IntersectRect (glyphRect, rect))
		{
			(*visibleGlyphs)[i-1] = (*visibleGlyphs)[--count];
			visibleGlyphs->pop_back();
		}
	}
#endif
}
Exemplo n.º 9
0
bool CRevisionGraphWnd::AnalyzeRevisionData()
{
    CSyncPointer<const CFullGraph> fullGraph (m_state.GetFullGraph());
    if ((fullGraph.get() != NULL) && (fullGraph->GetNodeCount() > 0))
    {
        // filter graph

        CSyncPointer<CAllRevisionGraphOptions> options (m_state.GetOptions());
        options->Prepare();

        std::unique_ptr<CVisibleGraph> visibleGraph (new CVisibleGraph());
        CVisibleGraphBuilder builder ( *fullGraph
                                     , *visibleGraph
                                     , options->GetCopyFilterOptions());
        builder.Run();
        options->GetModificationOptions().Apply (visibleGraph.get());

        index_t index = 0;
        for (size_t i = 0, count = visibleGraph->GetRootCount(); i < count; ++i)
            index = visibleGraph->GetRoot (i)->InitIndex (index);

        // layout nodes

        std::unique_ptr<CStandardLayout> newLayout
            ( new CStandardLayout ( m_state.GetFullHistory()->GetCache()
                                  , visibleGraph.get()
                                  , m_state.GetFullHistory()->GetWCInfo()));
        options->GetLayoutOptions().Apply (newLayout.get());
        newLayout->Finalize();

        // switch state

        m_state.SetAnalysisResult (visibleGraph, newLayout);
    }

    return m_state.GetNodes().get() != NULL;
}