Render GUI correctly on retina screens (#834)

This commit is contained in:
Emil Axelsson
2019-04-27 15:45:36 +02:00
committed by Alexander Bock
parent 1d50a88fc0
commit 6a6db9aa78
3 changed files with 18 additions and 7 deletions
+4 -1
View File
@@ -194,7 +194,10 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration)
if (isGuiWindow && isMaster && _instance) {
if (global::windowDelegate.windowHasResized()) {
_instance->reshape(global::windowDelegate.currentWindowSize());
_instance->reshape(static_cast<glm::ivec2>(
static_cast<glm::vec2>(global::windowDelegate.currentWindowSize()) *
global::windowDelegate.dpiScaling()
));
}
if (_visible) {
_instance->draw();
+9 -4
View File
@@ -73,7 +73,10 @@ BrowserInstance::~BrowserInstance() {
}
void BrowserInstance::initialize() {
reshape(global::windowDelegate.currentWindowSize());
reshape(static_cast<glm::ivec2>(
static_cast<glm::vec2>(global::windowDelegate.currentWindowSize()) *
global::windowDelegate.dpiScaling()
));
_isInitialized = true;
}
@@ -162,9 +165,11 @@ bool BrowserInstance::sendMouseWheelEvent(const CefMouseEvent& event,
}
void BrowserInstance::setZoom(float ratio) {
//Zooming in CEF is non-linear according to this:
//https://www.magpcss.org/ceforum/viewtopic.php?f=6&t=11491
_zoomLevel = glm::log(static_cast<double>(ratio))/glm::log(1.2);
const float dpiScaling = global::windowDelegate.dpiScaling().x;
// Zooming in CEF is non-linear according to this:
// https://www.magpcss.org/ceforum/viewtopic.php?f=6&t=11491
_zoomLevel = glm::log(static_cast<double>(ratio * dpiScaling))/glm::log(1.2);
_browser->GetHost()->SetZoomLevel(_zoomLevel);
}
+5 -2
View File
@@ -26,6 +26,8 @@
#include <modules/webbrowser/include/browserinstance.h>
#include <openspace/engine/globalscallbacks.h>
#include <openspace/engine/globals.h>
#include <openspace/engine/windowdelegate.h>
#include <ghoul/logging/logmanager.h>
#include <fmt/format.h>
@@ -268,8 +270,9 @@ bool EventHandler::isDoubleClick(const MouseButtonState& button) const {
}
bool EventHandler::mousePositionCallback(double x, double y) {
_mousePosition.x = floor(static_cast<float>(x));
_mousePosition.y = floor(static_cast<float>(y));
const glm::vec2 dpiScaling = global::windowDelegate.dpiScaling();
_mousePosition.x = floor(static_cast<float>(x) * dpiScaling.x);
_mousePosition.y = floor(static_cast<float>(y) * dpiScaling.y);
_browserInstance->sendMouseMoveEvent(mouseEvent());
// Let the mouse event trickle on
return false;