Create HIDPI_GL_CANVAS wrapper for transparent wxGLCanvas HiDPI/Retina support. Enable HiDPI/Retina for 3d-viewer.
This commit is contained in:
parent
9da1dc4c51
commit
909d95b5be
|
@ -90,7 +90,7 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow *aParent,
|
|||
BOARD *aBoard,
|
||||
CINFO3D_VISU &aSettings , S3D_CACHE *a3DCachePointer ) :
|
||||
|
||||
wxGLCanvas( aParent,
|
||||
HIDPI_GL_CANVAS( aParent,
|
||||
wxID_ANY,
|
||||
aAttribList,
|
||||
wxDefaultPosition,
|
||||
|
@ -516,8 +516,7 @@ void EDA_3D_CANVAS::OnMagnify( wxMouseEvent& event )
|
|||
DisplayStatus();
|
||||
Request_refresh();
|
||||
|
||||
// Please someone test if this is need
|
||||
//m_settings.CameraGet().SetCurMousePosition( event.GetPosition() );
|
||||
m_settings.CameraGet().SetCurMousePosition( event.GetPosition() );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -36,9 +36,9 @@
|
|||
#include "3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.h"
|
||||
#include "3d_rendering/3d_render_raytracing/c3d_render_raytracing.h"
|
||||
#include "3d_cache/3d_cache.h"
|
||||
#include <gal/hidpi_gl_canvas.h>
|
||||
#include <wx/clipbrd.h>
|
||||
#include <wx/dataobj.h>
|
||||
#include <wx/glcanvas.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/wupdlock.h>
|
||||
#include <wx/timer.h>
|
||||
|
@ -50,7 +50,7 @@
|
|||
* Class EDA_3D_CANVAS
|
||||
* Implement a canvas based on a wxGLCanvas
|
||||
*/
|
||||
class EDA_3D_CANVAS : public wxGLCanvas
|
||||
class EDA_3D_CANVAS : public HIDPI_GL_CANVAS
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -83,7 +83,7 @@ END_EVENT_TABLE()
|
|||
C3D_MODEL_VIEWER::C3D_MODEL_VIEWER(wxWindow *aParent,
|
||||
const int *aAttribList , S3D_CACHE *aCacheManager) :
|
||||
|
||||
wxGLCanvas( aParent,
|
||||
HIDPI_GL_CANVAS( aParent,
|
||||
wxID_ANY,
|
||||
aAttribList,
|
||||
wxDefaultPosition,
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#define _C3D_MODEL_VIEWER_H_
|
||||
|
||||
#include "3d_rendering/ctrack_ball.h"
|
||||
#include <wx/glcanvas.h>
|
||||
#include <gal/hidpi_gl_canvas.h>
|
||||
|
||||
class S3D_CACHE;
|
||||
class C_OGL_3DMODEL;
|
||||
|
@ -42,7 +42,7 @@ class C_OGL_3DMODEL;
|
|||
* Class C3D_MODEL_VIEWER
|
||||
* Implement a canvas based on a wxGLCanvas
|
||||
*/
|
||||
class C3D_MODEL_VIEWER : public wxGLCanvas
|
||||
class C3D_MODEL_VIEWER : public HIDPI_GL_CANVAS
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -41,6 +41,7 @@ set( GAL_SRCS
|
|||
view/view_controls.cpp
|
||||
view/wx_view_controls.cpp
|
||||
geometry/hetriang.cpp
|
||||
gal/hidpi_gl_canvas.cpp
|
||||
|
||||
# OpenGL GAL
|
||||
gal/opengl/opengl_gal.cpp
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017 Bernhard Stegmaier <stegmaier@sw-systems.de>
|
||||
* Copyright (C) 2016-2017 Kicad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* Base class for HiDPI aware wxGLCanvas implementations.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <gal/hidpi_gl_canvas.h>
|
||||
|
||||
|
||||
HIDPI_GL_CANVAS::HIDPI_GL_CANVAS( wxWindow *parent,
|
||||
const wxGLAttributes& dispAttrs,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name,
|
||||
const wxPalette& palette ) :
|
||||
wxGLCanvas( parent, dispAttrs, id, pos, size, style, name, palette )
|
||||
{
|
||||
#ifdef RETINA_OPENGL_PATCH
|
||||
SetViewWantsBestResolution( true );
|
||||
scaleFactor = GetBackingScaleFactor();
|
||||
#endif
|
||||
}
|
||||
|
||||
HIDPI_GL_CANVAS::HIDPI_GL_CANVAS( wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const int *attribList,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name,
|
||||
const wxPalette& palette ) :
|
||||
wxGLCanvas( parent, id, attribList, pos, size, style, name, palette )
|
||||
{
|
||||
#ifdef RETINA_OPENGL_PATCH
|
||||
SetViewWantsBestResolution( true );
|
||||
scaleFactor = GetBackingScaleFactor();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
wxSize HIDPI_GL_CANVAS::GetClientSize() const
|
||||
{
|
||||
wxSize size = wxGLCanvas::GetClientSize();
|
||||
|
||||
#ifdef RETINA_OPENGL_PATCH
|
||||
size.x *= scaleFactor;
|
||||
size.y *= scaleFactor;
|
||||
#endif
|
||||
|
||||
return size;
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017 Bernhard Stegmaier <stegmaier@sw-systems.de>
|
||||
* Copyright (C) 2016-2017 Kicad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* Base class for HiDPI aware wxGLCanvas implementations.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef HIDPI_GL_CANVAS_H
|
||||
#define HIDPI_GL_CANVAS_H
|
||||
|
||||
#include <wx/glcanvas.h>
|
||||
|
||||
|
||||
/**
|
||||
* @brief wxGLCanvas wrapper for HiDPI/Retina support.
|
||||
*
|
||||
* This is a small wrapper class to enable HiDPI/Retina support for wxGLCanvas.
|
||||
* HiDPI currently only works with a patched wxWidgets version, see:
|
||||
* http://trac.wxwidgets.org/ticket/15700
|
||||
*/
|
||||
class HIDPI_GL_CANVAS : public wxGLCanvas
|
||||
{
|
||||
public:
|
||||
HIDPI_GL_CANVAS( wxWindow *parent,
|
||||
const wxGLAttributes& dispAttrs,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString& name = wxGLCanvasName,
|
||||
const wxPalette& palette = wxNullPalette );
|
||||
|
||||
HIDPI_GL_CANVAS( wxWindow *parent,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const int *attribList = NULL,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString& name = wxGLCanvasName,
|
||||
const wxPalette& palette = wxNullPalette );
|
||||
|
||||
wxSize GetClientSize() const;
|
||||
|
||||
|
||||
#ifdef RETINA_OPENGL_PATCH
|
||||
private:
|
||||
float scaleFactor;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // HIDPI_GL_CANVAS_H
|
Loading…
Reference in New Issue