mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-26 05:58:48 -05:00
Render GUI correctly on retina screens (#834)
This commit is contained in:
committed by
Alexander Bock
parent
1d50a88fc0
commit
6a6db9aa78
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user