• R/O
  • SSH
  • HTTPS

tortoisesvn: Commit


Commit MetaInfo

Revision28245 (tree)
Time2018-06-02 23:20:42
Authorstefankueng

Log Message

Adjust the revision graph for high-dpi displays.

Change Summary

Incremental Difference

--- trunk/src/TortoiseProc/RevisionGraph/RevisionGraphWnd.cpp (revision 28244)
+++ trunk/src/TortoiseProc/RevisionGraph/RevisionGraphWnd.cpp (revision 28245)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2003-2017 - TortoiseSVN
3+// Copyright (C) 2003-2018 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -38,6 +38,7 @@
3838 #include "RevisionGraph/StandardLayout.h"
3939 #include "RevisionGraph/UpsideDownLayout.h"
4040 #include "FormatMessageWrapper.h"
41+#include "DPIAware.h"
4142 #include <strsafe.h>
4243
4344 #ifdef _DEBUG
@@ -253,9 +254,10 @@
253254 // get node at point or node that is close enough
254255 // so that point may hit a glyph area
255256
257+ auto glyphsize = CDPIAware::Instance().ScaleX(GLYPH_SIZE);
256258 index_t nodeIndex = GetHitNode(point);
257259 if (nodeIndex == NO_INDEX)
258- nodeIndex = GetHitNode(point, CSize (GLYPH_SIZE, GLYPH_SIZE / 2));
260+ nodeIndex = GetHitNode(point, CSize (glyphsize, glyphsize / 2));
259261
260262 if (nodeIndex >= nodeList->GetCount())
261263 return 0;
@@ -270,12 +272,12 @@
270272 CRect r = node.rect;
271273 CPoint center = r.CenterPoint();
272274
273- CRect rightGlyphArea ( r.right - GLYPH_SIZE, center.y - GLYPH_SIZE / 2
274- , r.right + GLYPH_SIZE, center.y + GLYPH_SIZE / 2);
275- CRect topGlyphArea ( center.x - GLYPH_SIZE, r.top - GLYPH_SIZE / 2
276- , center.x + GLYPH_SIZE, r.top + GLYPH_SIZE / 2);
277- CRect bottomGlyphArea ( center.x - GLYPH_SIZE, r.bottom - GLYPH_SIZE / 2
278- , center.x + GLYPH_SIZE, r.bottom + GLYPH_SIZE / 2);
275+ CRect rightGlyphArea ( r.right - glyphsize, center.y - glyphsize / 2
276+ , r.right + glyphsize, center.y + glyphsize / 2);
277+ CRect topGlyphArea ( center.x - glyphsize, r.top - glyphsize / 2
278+ , center.x + glyphsize, r.top + glyphsize / 2);
279+ CRect bottomGlyphArea ( center.x - glyphsize, r.bottom - glyphsize / 2
280+ , center.x + glyphsize, r.bottom + glyphsize / 2);
279281
280282 bool upsideDown
281283 = m_state.GetOptions()->GetOption<CUpsideDownLayout>()->IsActive();
@@ -313,7 +315,7 @@
313315
314316 const CRevisionGraphState::SVisibleGlyph* CRevisionGraphWnd::GetHitGlyph (CPoint point) const
315317 {
316- float glyphSize = GLYPH_SIZE * m_fZoomFactor;
318+ float glyphSize = CDPIAware::Instance().ScaleX(GLYPH_SIZE) * m_fZoomFactor;
317319
318320 CSyncPointer<const CRevisionGraphState::TVisibleGlyphs>
319321 visibleGlyphs (m_state.GetVisibleGlyphs());
--- trunk/src/TortoiseProc/RevisionGraph/RevisionGraphDlgDraw.cpp (revision 28244)
+++ trunk/src/TortoiseProc/RevisionGraph/RevisionGraphDlgDraw.cpp (revision 28245)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2003-2011, 2013-2016 - TortoiseSVN
3+// Copyright (C) 2003-2011, 2013-2016, 2018 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -30,6 +30,7 @@
3030 #include "IRevisionGraphLayout.h"
3131 #include "UpsideDownLayout.h"
3232 #include "ShowTreeStripes.h"
33+#include "DPIAware.h"
3334
3435 #ifdef _DEBUG
3536 #define new DEBUG_NEW
@@ -102,7 +103,7 @@
102103
103104 void CRevisionGraphWnd::ClearVisibleGlyphs (const CRect& rect)
104105 {
105- float glyphSize = GLYPH_SIZE * m_fZoomFactor;
106+ float glyphSize = CDPIAware::Instance().ScaleX(GLYPH_SIZE) * m_fZoomFactor;
106107
107108 CSyncPointer<CRevisionGraphState::TVisibleGlyphs>
108109 visibleGlyphs (m_state.GetVisibleGlyphs());
@@ -139,7 +140,7 @@
139140 {
140141 enum {POINT_COUNT = 8};
141142
142- float radius = CORNER_SIZE * m_fZoomFactor;
143+ float radius = CDPIAware::Instance().ScaleX(CORNER_SIZE) * m_fZoomFactor;
143144 PointF points[POINT_COUNT];
144145 CutawayPoints (rect, radius, points);
145146
@@ -173,7 +174,7 @@
173174
174175 // show left & right edges of low boxes as "<===>"
175176
176- float minCutAway = min (CORNER_SIZE * m_fZoomFactor, rect.Height / 2);
177+ float minCutAway = min (CDPIAware::Instance().ScaleX(CORNER_SIZE) * m_fZoomFactor, rect.Height / 2);
177178
178179 // larger boxes: remove 25% of the shorter side
179180
@@ -425,7 +426,7 @@
425426
426427 // expand it just a little to make it look nicer
427428
428- cover.InflateRect (10, 2, 10, 2);
429+ cover.InflateRect (CDPIAware::Instance().ScaleX(10), CDPIAware::Instance().ScaleY(2), CDPIAware::Instance().ScaleX(10), CDPIAware::Instance().ScaleY(2));
429430
430431 // and now, transfrom it
431432
@@ -483,7 +484,7 @@
483484 , const Color& darkColor
484485 , const Color& penColor)
485486 {
486- float squareSize = MARKER_SIZE * m_fZoomFactor;
487+ float squareSize = CDPIAware::Instance().ScaleX(MARKER_SIZE) * m_fZoomFactor;
487488
488489 PointF leftBottom (leftTop.X, leftTop.Y + squareSize);
489490 RectF square (leftTop, SizeF (squareSize, squareSize));
@@ -519,11 +520,11 @@
519520
520521 // bitmap source area
521522
522- REAL x = ((REAL)position + (REAL)glyph) * GLYPH_BITMAP_SIZE;
523+ REAL x = ((REAL)position + (REAL)glyph) * CDPIAware::Instance().ScaleX(GLYPH_BITMAP_SIZE);
523524
524525 // screen target area
525526
526- float glyphSize = GLYPH_SIZE * m_fZoomFactor;
527+ float glyphSize = CDPIAware::Instance().ScaleX(GLYPH_SIZE) * m_fZoomFactor;
527528 RectF target (leftTop, SizeF (glyphSize, glyphSize));
528529
529530 // scaled copy
@@ -532,7 +533,7 @@
532533 {
533534 graphics.graphics->DrawImage ( glyphs
534535 , target
535- , x, 0.0f, GLYPH_BITMAP_SIZE, GLYPH_BITMAP_SIZE
536+ , x, 0.0f, (REAL)CDPIAware::Instance().ScaleX(GLYPH_BITMAP_SIZE), (REAL)CDPIAware::Instance().ScaleY(GLYPH_BITMAP_SIZE)
536537 , UnitPixel, NULL, NULL, NULL);
537538 }
538539 else if (graphics.pSVG)
@@ -588,7 +589,7 @@
588589 CSyncPointer<CRevisionGraphState::TVisibleGlyphs>
589590 visibleGlyphs (m_state.GetVisibleGlyphs());
590591
591- float squareSize = GLYPH_SIZE * m_fZoomFactor;
592+ float squareSize = CDPIAware::Instance().ScaleX(GLYPH_SIZE) * m_fZoomFactor;
592593 if (glyph2 == NoGlyph)
593594 {
594595 PointF leftTop (center.X - 0.5f * squareSize, center.Y - 0.5f * squareSize);
@@ -754,7 +755,7 @@
754755 , int colorIndex )
755756 {
756757 // marker size
757- float squareSize = MARKER_SIZE * m_fZoomFactor;
758+ float squareSize = CDPIAware::Instance().ScaleX(MARKER_SIZE) * m_fZoomFactor;
758759 float squareDist = min ( (noderect.Height - squareSize) / 2
759760 , squareSize / 2);
760761
@@ -1016,7 +1017,7 @@
10161017 if ((m_hoverIndex != NO_INDEX) || (m_hoverGlyphs != 0))
10171018 {
10181019 index_t nodeIndex = m_hoverIndex == NO_INDEX
1019- ? GetHitNode (point, CSize (GLYPH_SIZE, GLYPH_SIZE / 2))
1020+ ? GetHitNode (point, CSize (CDPIAware::Instance().ScaleX(GLYPH_SIZE), CDPIAware::Instance().ScaleY(GLYPH_SIZE) / 2))
10201021 : m_hoverIndex;
10211022
10221023 if (nodeIndex >= nodeList->GetCount())
--- trunk/src/TortoiseProc/RevisionGraph/StandardNodeSizeAssignment.cpp (revision 28244)
+++ trunk/src/TortoiseProc/RevisionGraph/StandardNodeSizeAssignment.cpp (revision 28245)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2003-2010 - TortoiseSVN
3+// Copyright (C) 2003-2010, 2018 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -22,6 +22,7 @@
2222 #include "StandardLayout.h"
2323 #include "VisibleGraphNode.h"
2424 #include "GraphNodeState.h"
25+#include "DPIAware.h"
2526
2627 // construction
2728
@@ -57,13 +58,13 @@
5758 || ( node->previousInBranch->node->GetPath()
5859 != node->node->GetPath());
5960
60- int height = 21;
61+ int height = CDPIAware::Instance().ScaleY(21);
6162 if (node->requiresPath)
6263 {
6364 size_t visibleElementCount = node->node->GetPath().GetDepth()
6465 - node->skipStartPathElements
6566 - node->skipTailPathElements;
66- height += (int)(3 + visibleElementCount * 16);
67+ height += (int)(CDPIAware::Instance().ScaleY(3) + visibleElementCount * 16);
6768 }
6869
6970 // shift (root) nodes down, if their source has been folded
@@ -73,16 +74,16 @@
7374 int shift = (state & ( CGraphNodeStates::COLLAPSED_ABOVE
7475 | CGraphNodeStates::SPLIT_ABOVE)) == 0
7576 ? 0
76- : 6;
77+ : CDPIAware::Instance().ScaleY(6);
7778
7879 int extension = (state & ( CGraphNodeStates::COLLAPSED_BELOW
7980 | CGraphNodeStates::SPLIT_BELOW)) == 0
8081 ? 0
81- : 6;
82+ : CDPIAware::Instance().ScaleY(6);
8283
8384 // set result
8485
85- node->requiredSize = CSize (150, height + extension + shift);
86- node->rect = CRect (0, shift, 150, height + shift);
86+ node->requiredSize = CSize (CDPIAware::Instance().ScaleX(150), height + extension + shift);
87+ node->rect = CRect (0, shift, CDPIAware::Instance().ScaleX(150), height + shift);
8788 }
8889 }
--- trunk/src/TortoiseProc/RevisionGraph/RevisionGraphDlgFunc.cpp (revision 28244)
+++ trunk/src/TortoiseProc/RevisionGraph/RevisionGraphDlgFunc.cpp (revision 28245)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2003-2011, 2013-2015 - TortoiseSVN
3+// Copyright (C) 2003-2011, 2013-2015, 2018 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -33,6 +33,7 @@
3333 #include "RevisionGraph/StandardLayout.h"
3434 #include "RevisionGraph/ShowWC.h"
3535 #include "RevisionGraph/ShowWCModification.h"
36+#include "DPIAware.h"
3637
3738 #pragma warning(push)
3839 #pragma warning(disable: 4458) // declaration of 'xxx' hides class member
@@ -69,8 +70,8 @@
6970 float origZoom = m_fZoomFactor;
7071
7172 CRect clientRect = GetClientRect();
72- CSize preViewSize (max (REVGRAPH_PREVIEW_WIDTH, clientRect.Width() / 4)
73- ,max (REVGRAPH_PREVIEW_HEIGHT, clientRect.Height() / 4));
73+ CSize preViewSize (max (CDPIAware::Instance().ScaleX(REVGRAPH_PREVIEW_WIDTH), clientRect.Width() / 4)
74+ ,max (CDPIAware::Instance().ScaleY(REVGRAPH_PREVIEW_HEIGHT), clientRect.Height() / 4));
7475
7576 // zoom the graph so that it is completely visible in the window
7677 CRect graphRect = GetGraphRect();
--- trunk/src/TortoiseProc/RevisionGraph/RevisionGraphDlg.cpp (revision 28244)
+++ trunk/src/TortoiseProc/RevisionGraph/RevisionGraphDlg.cpp (revision 28245)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2003-2017 - TortoiseSVN
3+// Copyright (C) 2003-2018 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -32,6 +32,7 @@
3232 #include "RepositoryInfo.h"
3333 #include "RevisionInRange.h"
3434 #include "RemovePathsBySubString.h"
35+#include "DPIAware.h"
3536 #include <strsafe.h>
3637
3738 #ifdef _DEBUG
@@ -136,25 +137,43 @@
136137 CBitmap cBitmap;
137138 BITMAP bmBitmap;
138139
140+ // load the toolbar with the dimensions of the bitmap itself
139141 cBitmap.Attach(LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_REVGRAPHBAR),
140142 IMAGE_BITMAP, 0, 0,
141143 LR_DEFAULTSIZE|LR_CREATEDIBSECTION));
142144 cBitmap.GetBitmap(&bmBitmap);
145+ cBitmap.DeleteObject();
146+ // now load the toolbar again, but this time with the dpi-scaled dimensions
147+ // note: we could just load it once and then resize the bitmap, but
148+ // that's not faster. So loading it again is what we do.
149+ cBitmap.Attach(LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_REVGRAPHBAR),
150+ IMAGE_BITMAP,
151+ CDPIAware::Instance().ScaleX(bmBitmap.bmWidth),
152+ CDPIAware::Instance().ScaleY(bmBitmap.bmHeight),
153+ LR_CREATEDIBSECTION));
154+ cBitmap.GetBitmap(&bmBitmap);
143155
156+
144157 CSize cSize(bmBitmap.bmWidth, bmBitmap.bmHeight);
145- int nNbBtn = cSize.cx/20;
158+ int nNbBtn = cSize.cx/ CDPIAware::Instance().ScaleX(20);
146159 RGBTRIPLE * rgb = (RGBTRIPLE*)(bmBitmap.bmBits);
147160 COLORREF rgbMask = RGB(rgb[0].rgbtRed, rgb[0].rgbtGreen, rgb[0].rgbtBlue);
148161
149- cImageList.Create(20, cSize.cy, ILC_COLOR32|ILC_MASK, nNbBtn, 0);
162+ cImageList.Create(CDPIAware::Instance().ScaleX(20), cSize.cy, ILC_COLOR32|ILC_MASK, nNbBtn, 0);
150163 cImageList.Add(&cBitmap, rgbMask);
164+ // set the sizes of the button and images:
165+ // note: buttonX must be 7 pixels more than imageX, and buttonY must be 6 pixels more than imageY.
166+ // See the source of SetSizes().
167+ m_ToolBar.SetSizes(CSize(CDPIAware::Instance().ScaleX(27), CDPIAware::Instance().ScaleY(26)),
168+ CSize(CDPIAware::Instance().ScaleX(20), CDPIAware::Instance().ScaleY(20)));
151169 m_ToolBar.SendMessage(TB_SETIMAGELIST, 0, (LPARAM)cImageList.m_hImageList);
152170 cImageList.Detach();
153171 cBitmap.Detach();
154172 }
173+
155174 RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
156175
157-#define SNAP_WIDTH 60 //the width of the combo box
176+#define SNAP_WIDTH CDPIAware::Instance().ScaleX(60) //the width of the combo box
158177 // set up the ComboBox control as a snap mode select box
159178 // First get the index of the placeholders position in the toolbar
160179 int zoomComboIndex = 0;
@@ -167,8 +186,8 @@
167186 m_ToolBar.GetItemRect(zoomComboIndex, &rect);
168187
169188 // expand the rectangle to allow the combo box room to drop down
170- rect.top+=3;
171- rect.bottom += 200;
189+ rect.top+= CDPIAware::Instance().ScaleY(3);
190+ rect.bottom += CDPIAware::Instance().ScaleY(200);
172191
173192 // then create the combo box and show it
174193 if (!m_ToolBar.m_ZoomCombo.CreateEx(WS_EX_RIGHT, WS_CHILD|WS_VISIBLE|CBS_AUTOHSCROLL|CBS_DROPDOWN,
@@ -422,7 +441,7 @@
422441 float horzfact = (windowRect.Width() - 4.0f)/(4.0f + graphRect.Width());
423442 float vertfact = (windowRect.Height() - 4.0f)/(4.0f + graphRect.Height());
424443 if ((horzfact < vertfact) && (horzfact < MAX_ZOOM))
425- vertfact = (windowRect.Height() - 20.0f)/(4.0f + graphRect.Height());
444+ vertfact = (windowRect.Height() - CDPIAware::Instance().ScaleY(20))/(4.0f + graphRect.Height());
426445
427446 DoZoom (min (MAX_ZOOM, vertfact));
428447 }
@@ -436,7 +455,7 @@
436455 float horzfact = (windowRect.Width() - 4.0f)/(4.0f + graphRect.Width());
437456 float vertfact = (windowRect.Height() - 4.0f)/(4.0f + graphRect.Height());
438457 if ((vertfact < horzfact) && (vertfact < MAX_ZOOM))
439- horzfact = (windowRect.Width() - 20.0f)/(4.0f + graphRect.Width());
458+ horzfact = (windowRect.Width() - CDPIAware::Instance().ScaleX(20))/(4.0f + graphRect.Width());
440459
441460 DoZoom (min (MAX_ZOOM, horzfact));
442461 }
Show on old repository browser