comparison view/View.cpp @ 1402:b0eeec95ab5b

Handle integer pixel scaling as well
author Chris Cannam
date Thu, 15 Nov 2018 14:18:26 +0000
parents 28075cc658c9
children c8a6fd3f9dff d794630429a7
comparison
equal deleted inserted replaced
1401:28075cc658c9 1402:b0eeec95ab5b
236 if ((*i)->needsTextLabelHeight()) { 236 if ((*i)->needsTextLabelHeight()) {
237 sortedLayers[getObjectExportId(*i)] = *i; 237 sortedLayers[getObjectExportId(*i)] = *i;
238 } 238 }
239 } 239 }
240 240
241 int y = scaleSize(15) + paint.fontMetrics().ascent(); 241 int y = scalePixelSize(15) + paint.fontMetrics().ascent();
242 242
243 for (std::map<int, Layer *>::const_iterator i = sortedLayers.begin(); 243 for (std::map<int, Layer *>::const_iterator i = sortedLayers.begin();
244 i != sortedLayers.end(); ++i) { 244 i != sortedLayers.end(); ++i) {
245 if (i->second == layer) break; 245 if (i->second == layer) break;
246 y += paint.fontMetrics().height(); 246 y += paint.fontMetrics().height();
672 pb->setTextVisible(false); 672 pb->setTextVisible(false);
673 673
674 QPushButton *cancel = new QPushButton(this); 674 QPushButton *cancel = new QPushButton(this);
675 cancel->setIcon(IconLoader().load("cancel")); 675 cancel->setIcon(IconLoader().load("cancel"));
676 cancel->setFlat(true); 676 cancel->setFlat(true);
677 int scaled20 = scaleSize(20); 677 int scaled20 = scalePixelSize(20);
678 cancel->setFixedSize(QSize(scaled20, scaled20)); 678 cancel->setFixedSize(QSize(scaled20, scaled20));
679 connect(cancel, SIGNAL(clicked()), this, SLOT(cancelClicked())); 679 connect(cancel, SIGNAL(clicked()), this, SLOT(cancelClicked()));
680 680
681 ProgressBarRec pbr; 681 ProgressBarRec pbr;
682 pbr.cancel = cancel; 682 pbr.cancel = cancel;
1618 } 1618 }
1619 1619
1620 return size * ratio; 1620 return size * ratio;
1621 } 1621 }
1622 1622
1623 int
1624 View::scalePixelSize(int size) const
1625 {
1626 double d = scaleSize(size);
1627 int i = int(d + 0.5);
1628 if (size != 0 && i == 0) i = 1;
1629 return i;
1630 }
1631
1623 double 1632 double
1624 View::scalePenWidth(double width) const 1633 View::scalePenWidth(double width) const
1625 { 1634 {
1626 if (width <= 0) { // zero-width pen, produce a scaled one-pixel pen 1635 if (width <= 0) { // zero-width pen, produce a scaled one-pixel pen
1627 width = 1; 1636 width = 1;
1790 i->second.lastCheck = 0; 1799 i->second.lastCheck = 0;
1791 timer->setInterval(2000); 1800 timer->setInterval(2000);
1792 timer->start(); 1801 timer->start();
1793 } 1802 }
1794 1803
1795 int scaled20 = scaleSize(20); 1804 int scaled20 = scalePixelSize(20);
1796 1805
1797 cancel->move(0, ph - pb->height()/2 - scaled20/2); 1806 cancel->move(0, ph - pb->height()/2 - scaled20/2);
1798 cancel->show(); 1807 cancel->show();
1799 1808
1800 pb->setValue(completion); 1809 pb->setValue(completion);