comparison src/connectionitem.cpp @ 678:c0b46d0514a7 scale

Incomplete scaling updates. Should do this differently
author Chris Cannam
date Thu, 06 Dec 2018 14:55:45 +0000
parents ae67ea0af696
children
comparison
equal deleted inserted replaced
677:0329bbd4b57c 678:c0b46d0514a7
20 20
21 #include "changesetitem.h" 21 #include "changesetitem.h"
22 #include "changeset.h" 22 #include "changeset.h"
23 #include "colourset.h" 23 #include "colourset.h"
24 #include "textabbrev.h" 24 #include "textabbrev.h"
25 #include "common.h"
25 26
26 #include <QPainter> 27 #include <QPainter>
27 #include <QFont> 28 #include <QFont>
28 29
29 QRectF 30 QRectF
30 ConnectionItem::boundingRect() const 31 ConnectionItem::boundingRect() const
31 { 32 {
32 if (!(m_child || m_uncommitted)) return QRectF(); 33 if (!(m_child || m_uncommitted)) return QRectF();
33 float xscale = 100; 34 float xscale = scalePixelSize(100);
34 float yscale = 90; 35 float yscale = scalePixelSize(90);
35 float size = 50; 36 float size = scalePixelSize(50);
36 37
37 int c_col, c_row; 38 int c_col, c_row;
38 if (m_child) { 39 if (m_child) {
39 c_col = m_child->column(); c_row = m_child->row(); 40 c_col = m_child->column(); c_row = m_child->row();
40 } else { 41 } else {
46 p_col = m_parent->column(); p_row = m_parent->row(); 47 p_col = m_parent->column(); p_row = m_parent->row();
47 } else { 48 } else {
48 p_col = c_col - 1; p_row = c_row + 1; 49 p_col = c_col - 1; p_row = c_row + 1;
49 } 50 }
50 51
51 return QRectF(xscale * c_col + size/2 - 2, 52 return QRectF(xscale * c_col + size/2 - scalePixelSize(2),
52 yscale * c_row + size - 22, 53 yscale * c_row + size - scalePixelSize(22),
53 xscale * p_col - xscale * c_col + 6, 54 xscale * p_col - xscale * c_col + scalePixelSize(6),
54 yscale * p_row - yscale * c_row - size + 44) 55 yscale * p_row - yscale * c_row - size + scalePixelSize(44))
55 .normalized(); 56 .normalized();
56 } 57 }
57 58
58 void 59 void
59 ConnectionItem::paint(QPainter *paint, const QStyleOptionGraphicsItem *, QWidget *) 60 ConnectionItem::paint(QPainter *paint, const QStyleOptionGraphicsItem *, QWidget *)
83 paint->setPen(QPen(branchColour, 0, ls)); 84 paint->setPen(QPen(branchColour, 0, ls));
84 } else { 85 } else {
85 paint->setPen(QPen(branchColour, 2, ls)); 86 paint->setPen(QPen(branchColour, 2, ls));
86 } 87 }
87 88
88 float xscale = 100; 89 float xscale = scalePixelSize(100);
89 90 float yscale = scalePixelSize(90);
90 float yscale = 90; 91 float size = scalePixelSize(50);
91 float size = 50;
92 float ygap = yscale - size - 2; 92 float ygap = yscale - size - 2;
93 93
94 int c_col, c_row; 94 int c_col, c_row;
95 if (m_child) { 95 if (m_child) {
96 c_col = m_child->column(); c_row = m_child->row(); 96 c_col = m_child->column(); c_row = m_child->row();
109 float p_x = xscale * p_col + size/2; 109 float p_x = xscale * p_col + size/2;
110 110
111 // ensure line reaches the box, even if it's in a small height -- 111 // ensure line reaches the box, even if it's in a small height --
112 // doesn't matter if we overshoot as the box is opaque and has a 112 // doesn't matter if we overshoot as the box is opaque and has a
113 // greater Z value 113 // greater Z value
114 p.moveTo(c_x, yscale * c_row + size - 20); 114 p.moveTo(c_x, yscale * c_row + size - scalePixelSize(20));
115 115
116 p.lineTo(c_x, yscale * c_row + size); 116 p.lineTo(c_x, yscale * c_row + size);
117 117
118 if (p_col == c_col) { 118 if (p_col == c_col) {
119 119
146 146
147 if (m_parent) { 147 if (m_parent) {
148 148
149 // ensure line reaches the node -- again doesn't matter if we 149 // ensure line reaches the node -- again doesn't matter if we
150 // overshoot 150 // overshoot
151 p.lineTo(p_x, yscale * p_row + 20); 151 p.lineTo(p_x, yscale * p_row + scalePixelSize(20));
152 152
153 } else { 153 } else {
154 154
155 // no parent: merge from closed branch: draw only half the line 155 // no parent: merge from closed branch: draw only half the line
156 paint->setClipRect(QRectF((c_x + p_x)/2, yscale * c_row + size - 22, 156 paint->setClipRect(QRectF((c_x + p_x)/2,
157 yscale * c_row + size - scalePixelSize(22),
157 xscale, yscale)); 158 xscale, yscale));
158 } 159 }
159 160
160 paint->drawPath(p); 161 paint->drawPath(p);
161 162
164 // merge from closed branch: draw branch name 165 // merge from closed branch: draw branch name
165 166
166 paint->setClipping(false); 167 paint->setClipping(false);
167 168
168 QFont f; 169 QFont f;
169 f.setPixelSize(11); 170 f.setPixelSize(scalePixelSize(11));
170 f.setBold(true); 171 f.setBold(true);
171 f.setItalic(false); 172 f.setItalic(false);
172 paint->setFont(f); 173 paint->setFont(f);
173 174
174 QString branch = m_mergedBranch; 175 QString branch = m_mergedBranch;