compatibility with high-DPI displays

metadata
Wenzel Jakob 2017-07-29 02:17:36 +02:00
parent 5aac89e1ef
commit 6d7d66175c
4 changed files with 27 additions and 19 deletions

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>570</width>
<height>319</height>
<height>340</height>
</rect>
</property>
<property name="windowTitle">
@ -77,12 +77,12 @@
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;About Mitsuba&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Version MTS_VERSION&lt;br /&gt;Configuration flags: &lt;span style=&quot; font-family:'Courier New,courier';&quot;&gt;CONFIG_FLAGS&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Mitsuba is an extensible rendering framework written in portable C++. It implements unbiased as well as biased techniques and contains heavy optimizations targeted towards current CPU architectures.&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Copyright © MTS_YEAR Wenzel Jakob &amp;lt;&lt;a href=&quot;mailto:wenzel@cs.cornell.edu&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;wenzel@cs.cornell.edu&lt;/span&gt;&lt;/a&gt;&amp;gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Licensed under the &lt;a href=&quot;http://www.gnu.org/licenses/gpl-3.0.html&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;GNU GPL, Version 3&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'.SF NS Text'; font-size:13pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt; font-weight:600;&quot;&gt;About Mitsuba&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;Version MTS_VERSION&lt;br /&gt;Configuration flags: &lt;/span&gt;&lt;span style=&quot; font-family:'Courier New,courier'; font-size:10pt;&quot;&gt;CONFIG_FLAGS&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;Mitsuba is an extensible rendering framework written in portable C++. It implements unbiased as well as biased techniques and contains heavy optimizations targeted towards current CPU architectures.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;Copyright © MTS_YEAR Wenzel Jakob &amp;lt;&lt;/span&gt;&lt;a href=&quot;mailto:wenzel.jakob@epfl.ch&quot;&gt;&lt;span style=&quot; font-size:10pt; text-decoration: underline; color:#0000ff;&quot;&gt;wenzel.jakob@epfl.ch&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;Licensed under the &lt;/span&gt;&lt;a href=&quot;http://www.gnu.org/licenses/gpl-3.0.html&quot;&gt;&lt;span style=&quot; font-size:10pt; text-decoration: underline; color:#0000ff;&quot;&gt;GNU GPL, Version 3&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>

View File

@ -374,10 +374,11 @@ void GLWidget::downloadFramebuffer() {
}
QSize GLWidget::sizeHint() const {
float ratio = windowHandle()->devicePixelRatio();
QSize minimumSize(440, 170);
if (m_context) {
return QSize(std::max(minimumSize.width(), m_context->framebuffer->getWidth()),
std::max(minimumSize.height(), m_context->framebuffer->getHeight()));
return QSize(std::max(minimumSize.width(), int(m_context->framebuffer->getWidth()/ratio)),
std::max(minimumSize.height(), int(m_context->framebuffer->getHeight()/ratio)));
} else {
return minimumSize;
}
@ -609,13 +610,12 @@ void GLWidget::keyReleaseEvent(QKeyEvent *event) {
}
void GLWidget::mouseMoveEvent(QMouseEvent *event) {
QPoint rel = event->pos() - m_mousePos;
float ratio = windowHandle()->devicePixelRatio();
QPoint rel = event->pos() - m_mousePos / ratio;
if (!m_context || !m_context->scene
|| !m_mouseDrag || rel == QPoint(0,0) || m_animation)
return;
m_mousePos = event->pos();
// if (m_ignoreMouseEvent == rel) {
if (m_ignoreMouseEvent != QPoint(0, 0)) {
m_ignoreMouseEvent = QPoint(0, 0);
@ -766,8 +766,10 @@ void GLWidget::mousePressEvent(QMouseEvent *event) {
if (m_context == NULL || m_context->scene == NULL)
return;
m_mousePos = event->pos();
m_initialMousePos = mapToGlobal(m_mousePos);
float ratio = windowHandle()->devicePixelRatio();
m_mousePos = event->pos()*ratio;
m_initialMousePos = mapToGlobal(event->pos());
m_mouseDrag = true;
if (m_cropping) {
@ -977,7 +979,8 @@ void GLWidget::paintGL() {
Point2i lowerRight = upperLeft +
m_context->framebuffer->getSize();
if (width() > size.x || height() > size.y) {
float ratio = windowHandle()->devicePixelRatio();
if (width() * ratio > size.x || height() * ratio > size.y) {
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
/* Draw a border to highlight the region occupied by the image */
glColor4f(0.4f, 0.4f, 0.4f, 1.0f);
@ -1369,10 +1372,11 @@ void GLWidget::updateScrollBars() {
return;
}
float ratio = windowHandle()->devicePixelRatio();
int reqWidth = m_context->framebuffer->getWidth(),
reqHeight = m_context->framebuffer->getHeight(),
width = size().width(),
height = size().height();
width = size().width()*ratio,
height = size().height()*ratio;
if (m_hScroll->isVisible())
height += m_hScroll->size().height();

View File

@ -23,7 +23,9 @@ LogWidget::LogWidget(QWidget *parent)
: QMainWindow(parent) {
m_contents = new QTextEdit(this);
QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
#if defined(__OSX__)
font.setPointSize(14);
#endif
m_contents->setFont(font);
m_contents->setReadOnly(true);
QPalette palette;

View File

@ -134,8 +134,10 @@ ServerWidget::ServerWidget(QWidget *parent,
const QString &nodeName, int listenPort)
: QMainWindow(parent) {
m_contents = new QTextEdit(this);
QFont font("Monospace");
font.setStyleHint(QFont::TypeWriter);
QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
#if defined(__OSX__)
font.setPointSize(14);
#endif
m_contents->setFont(font);
m_contents->setReadOnly(true);
QPalette palette;