mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-08-07 00:28:45 +00:00
Qt: Move screen-related stuff to own folder
This commit is contained in:
parent
ab812e0e75
commit
2cc94daae4
5 changed files with 75 additions and 7 deletions
|
@ -730,21 +730,22 @@ if(NOT BUILD_HYDRA_CORE AND NOT BUILD_LIBRETRO_CORE)
|
|||
option(GENERATE_QT_TRANSLATION "Generate Qt translation file" OFF)
|
||||
set(QT_LANGUAGES docs/translations)
|
||||
|
||||
set(FRONTEND_SOURCE_FILES src/panda_qt/main.cpp src/panda_qt/screen.cpp src/panda_qt/main_window.cpp src/panda_qt/about_window.cpp
|
||||
set(FRONTEND_SOURCE_FILES src/panda_qt/main.cpp src/panda_qt/main_window.cpp src/panda_qt/about_window.cpp
|
||||
src/panda_qt/config_window.cpp src/panda_qt/zep.cpp src/panda_qt/text_editor.cpp src/panda_qt/cheats_window.cpp src/panda_qt/mappings.cpp
|
||||
src/panda_qt/patch_window.cpp src/panda_qt/elided_label.cpp src/panda_qt/shader_editor.cpp src/panda_qt/translations.cpp
|
||||
src/panda_qt/thread_debugger.cpp src/panda_qt/cpu_debugger.cpp src/panda_qt/dsp_debugger.cpp src/panda_qt/input_window.cpp
|
||||
src/panda_qt/screen/screen.cpp
|
||||
)
|
||||
|
||||
set(FRONTEND_HEADER_FILES include/panda_qt/screen.hpp include/panda_qt/main_window.hpp include/panda_qt/about_window.hpp
|
||||
set(FRONTEND_HEADER_FILES include/panda_qt/main_window.hpp include/panda_qt/about_window.hpp
|
||||
include/panda_qt/config_window.hpp include/panda_qt/text_editor.hpp include/panda_qt/cheats_window.hpp
|
||||
include/panda_qt/patch_window.hpp include/panda_qt/elided_label.hpp include/panda_qt/shader_editor.hpp
|
||||
include/panda_qt/thread_debugger.hpp include/panda_qt/cpu_debugger.hpp include/panda_qt/dsp_debugger.hpp
|
||||
include/panda_qt/disabled_widget_overlay.hpp include/panda_qt/input_window.hpp
|
||||
include/panda_qt/disabled_widget_overlay.hpp include/panda_qt/input_window.hpp include/panda_qt/screen/screen.hpp
|
||||
)
|
||||
|
||||
if (APPLE AND ENABLE_METAL)
|
||||
set(FRONTEND_SOURCE_FILES ${FRONTEND_SOURCE_FILES} src/panda_qt/metal_context.mm)
|
||||
set(FRONTEND_SOURCE_FILES ${FRONTEND_SOURCE_FILES} src/panda_qt/screen/metal_context.mm)
|
||||
endif()
|
||||
|
||||
source_group("Source Files\\Qt" FILES ${FRONTEND_SOURCE_FILES})
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "panda_qt/cpu_debugger.hpp"
|
||||
#include "panda_qt/dsp_debugger.hpp"
|
||||
#include "panda_qt/patch_window.hpp"
|
||||
#include "panda_qt/screen.hpp"
|
||||
#include "panda_qt/screen/screen.hpp"
|
||||
#include "panda_qt/shader_editor.hpp"
|
||||
#include "panda_qt/text_editor.hpp"
|
||||
#include "panda_qt/thread_debugger.hpp"
|
||||
|
|
67
include/panda_qt/screen/screen.hpp
Normal file
67
include/panda_qt/screen/screen.hpp
Normal file
|
@ -0,0 +1,67 @@
|
|||
#pragma once
|
||||
#include <QWidget>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
#include "gl/context.h"
|
||||
#include "screen_layout.hpp"
|
||||
#include "window_info.h"
|
||||
|
||||
// OpenGL widget for drawing the 3DS screen
|
||||
class ScreenWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using ResizeCallback = std::function<void(u32, u32)>;
|
||||
|
||||
enum class API { OpenGL, Metal, Vulkan };
|
||||
|
||||
ScreenWidget(API api, ResizeCallback resizeCallback, QWidget* parent = nullptr);
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
// Called by the emulator thread for resizing the actual GL surface, since the emulator thread owns the GL context
|
||||
void resizeSurface(u32 width, u32 height);
|
||||
|
||||
GL::Context* getGLContext() { return glContext.get(); }
|
||||
void* getMTKLayer() { return mtkLayer; }
|
||||
|
||||
// Dimensions of our output surface
|
||||
u32 surfaceWidth = 0;
|
||||
u32 surfaceHeight = 0;
|
||||
WindowInfo windowInfo;
|
||||
|
||||
// Cached "previous" dimensions, used when resizing our window
|
||||
u32 previousWidth = 0;
|
||||
u32 previousHeight = 0;
|
||||
|
||||
API api = API::OpenGL;
|
||||
|
||||
// Coordinates (x/y/width/height) for the two screens in window space, used for properly handling touchscreen regardless
|
||||
// of layout or resizing
|
||||
ScreenLayout::WindowCoordinates screenCoordinates;
|
||||
// Screen layouts and sizes
|
||||
ScreenLayout::Layout screenLayout = ScreenLayout::Layout::Default;
|
||||
float topScreenSize = 0.5f;
|
||||
|
||||
void reloadScreenLayout(ScreenLayout::Layout newLayout, float newTopScreenSize);
|
||||
|
||||
private:
|
||||
// GL context for GL-based renderers
|
||||
std::unique_ptr<GL::Context> glContext = nullptr;
|
||||
|
||||
// CA::MetalLayer for the Metal renderer
|
||||
void* mtkLayer = nullptr;
|
||||
|
||||
ResizeCallback resizeCallback;
|
||||
|
||||
bool createGLContext();
|
||||
bool createMetalContext();
|
||||
|
||||
void resizeMetalView();
|
||||
|
||||
qreal devicePixelRatioFromScreen() const;
|
||||
int scaledWindowWidth() const;
|
||||
int scaledWindowHeight() const;
|
||||
std::optional<WindowInfo> getWindowInfo();
|
||||
|
||||
void reloadScreenCoordinates();
|
||||
};
|
|
@ -5,7 +5,7 @@
|
|||
#import <QWindow>
|
||||
#import <QuartzCore/QuartzCore.hpp>
|
||||
|
||||
#import "panda_qt/screen.hpp"
|
||||
#import "panda_qt/screen/screen.hpp"
|
||||
|
||||
bool ScreenWidget::createMetalContext() {
|
||||
NSView* nativeView = (NSView*)this->winId();
|
|
@ -12,7 +12,7 @@
|
|||
#include <qpa/qplatformnativeinterface.h>
|
||||
#endif
|
||||
|
||||
#include "panda_qt/screen.hpp"
|
||||
#include "panda_qt/screen/screen.hpp"
|
||||
|
||||
// OpenGL screen widget, based on https://github.com/stenzek/duckstation/blob/master/src/duckstation-qt/displaywidget.cpp
|
||||
// and https://github.com/melonDS-emu/melonDS/blob/master/src/frontend/qt_sdl/main.cpp
|
Loading…
Add table
Add a link
Reference in a new issue