Skip to content

Commit 0afa3b5

Browse files
author
N3xoX1
committed
UI: handle the resize of the window to better show the output
1 parent af08db3 commit 0afa3b5

9 files changed

Lines changed: 67 additions & 18 deletions

File tree

lang/english/html/main_window.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<html window-frame="solid-with-shadow" window-icon="window-icon.png" >
1+
<html window-frame="solid-with-shadow" window-icon="window-icon.png" window-resizable window-min-width="640" window-min-height="480">
22
<head>
33
<link href="main_window.css" rel="stylesheet" type="text/css">
44
<title>NxEmu</title>
@@ -7,9 +7,10 @@
77
<window-caption role=window-caption><img src="window-icon-32.png" /><span>NxEmu</span></window-caption>
88
<window-buttons>
99
<window-button role="window-minimize"></window-button>
10+
<window-button role="window-maximize"></window-button>
1011
<window-button role="window-close"></window-button>
1112
</window-buttons>
1213
</header>
1314
<mainmenu id="MainMenu" />
1415
<div id="MainContents" />
15-
</html>
16+
</html>

src/nxemu-module-spec/base.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
enum
1818
{
19-
MODULE_LOADER_SPECS_VERSION = 0x0104,
20-
MODULE_VIDEO_SPECS_VERSION = 0x0101,
21-
MODULE_CPU_SPECS_VERSION = 0x0101,
22-
MODULE_OPERATING_SYSTEM_SPECS_VERSION = 0x0103,
19+
MODULE_LOADER_SPECS_VERSION = 0x0105,
20+
MODULE_VIDEO_SPECS_VERSION = 0x0102,
21+
MODULE_CPU_SPECS_VERSION = 0x0102,
22+
MODULE_OPERATING_SYSTEM_SPECS_VERSION = 0x0104,
2323
};
2424

2525
enum MODULE_TYPE : uint16_t
@@ -60,6 +60,7 @@ typedef struct
6060
__interface IRenderWindow
6161
{
6262
void * RenderSurface(void) const;
63+
float PixelRatio(void) const;
6364
};
6465

6566
__interface IOperatingSystem;

src/nxemu-module-spec/video.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ __interface IVideo
3434
void MemoryMap(uint64_t address, uint64_t virtualAddress, uint64_t size, uint64_t asid, bool track) = 0;
3535
void RequestComposite(VideoFramebufferConfig * layers, uint32_t layerCount, VideoNvFence * fences, uint32_t fenceCount) = 0;
3636
uint64_t RegisterProcess(IMemory * memory) = 0;
37+
void UpdateFramebufferLayout(uint32_t width, uint32_t height) = 0;
3738
};
3839

3940
EXPORT IVideo * CALL CreateVideo(IRenderWindow & RenderWindow, ISwitchSystem & System);

src/nxemu-video/video_manager.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ uint64_t VideoManager::RegisterProcess(IMemory * memory)
8383
return asid.id;
8484
}
8585

86+
void VideoManager::UpdateFramebufferLayout(uint32_t width, uint32_t height)
87+
{
88+
impl->m_emuWindow->UpdateCurrentFramebufferLayout(width, height);
89+
}
90+
8691
uint64_t VideoManager::MemoryAllocate(uint64_t size)
8792
{
8893
return impl->m_host1x->MemoryManager().Allocate(size);

src/nxemu-video/video_manager.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ class VideoManager :
1313
void EmulationStarting();
1414

1515
//IVideo
16-
bool Initialize(void);
17-
uint64_t MemoryAllocate(uint64_t size);
18-
void MemoryTrackContinuity(uint64_t address, uint64_t virtualAddress, uint64_t size, uint64_t asid);
19-
void MemoryMap(uint64_t address, uint64_t virtualAddress, uint64_t size, uint64_t asid, bool track);
20-
void RequestComposite(VideoFramebufferConfig * layers, uint32_t layerCount, VideoNvFence * fences, uint32_t fenceCount);
21-
uint64_t RegisterProcess(IMemory* memory);
16+
bool Initialize(void) override;
17+
uint64_t MemoryAllocate(uint64_t size) override;
18+
void MemoryTrackContinuity(uint64_t address, uint64_t virtualAddress, uint64_t size, uint64_t asid) override;
19+
void MemoryMap(uint64_t address, uint64_t virtualAddress, uint64_t size, uint64_t asid, bool track) override;
20+
void RequestComposite(VideoFramebufferConfig * layers, uint32_t layerCount, VideoNvFence * fences, uint32_t fenceCount) override;
21+
uint64_t RegisterProcess(IMemory* memory) override;
22+
void UpdateFramebufferLayout(uint32_t width, uint32_t height) override;
2223

2324
private:
2425
VideoManager() = delete;

src/nxemu/user_interface/sciter_main_window.cpp

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ bool SciterMainWindow::Show(void)
8181
m_window->OnDestroySinkAdd(this);
8282
m_window->CenterWindow();
8383
SetCaption(m_windowTitle);
84+
8485
SciterElement menuElement(rootElement.GetElementByID("MainMenu"));
8586
void * interfacePtr = nullptr;
8687
if (menuElement.IsValid() && m_sciterUI.GetElementInterface(menuElement, IID_IMENUBAR, &interfacePtr))
@@ -93,13 +94,23 @@ bool SciterMainWindow::Show(void)
9394
SciterElement mainContents(rootElement.GetElementByID("MainContents"));
9495
if (mainContents.IsValid())
9596
{
97+
m_sciterUI.AttachHandler(mainContents, IID_IRESIZESINK, (IResizeSink*)this);
9698
rect = mainContents.GetLocation();
9799
}
98100

101+
uint32_t width = rect.right - rect.left;
102+
uint32_t height = rect.bottom - rect.top;
99103
m_renderWindow = CreateWindowExW(0, L"Static", L"", WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS,
100-
rect.left, rect.top, rect.right, rect.bottom, (HWND)m_window->GetHandle(), nullptr, GetModuleHandle(nullptr), nullptr);
104+
rect.left, rect.top, width, height, (HWND)m_window->GetHandle(), nullptr, GetModuleHandle(nullptr), nullptr);
101105
ShowWindow((HWND)m_renderWindow, SW_HIDE);
102106
SwitchSystem::Create(*this);
107+
108+
SwitchSystem* system = SwitchSystem::GetInstance();
109+
if (system != nullptr)
110+
{
111+
IVideo & video = system->Video();
112+
video.UpdateFramebufferLayout(rect.right - rect.left, rect.bottom - rect.top);
113+
}
103114
return true;
104115
}
105116

@@ -401,6 +412,11 @@ void * SciterMainWindow::RenderSurface(void) const
401412
return m_renderWindow;
402413
}
403414

415+
float SciterMainWindow::PixelRatio(void) const
416+
{
417+
return 1.0;
418+
}
419+
404420
bool SciterMainWindow::OnKeyDown(SCITER_ELEMENT element, SCITER_ELEMENT item, SciterKeys keyCode, uint32_t keyboardState)
405421
{
406422
SwitchSystem* system = SwitchSystem::GetInstance();
@@ -434,4 +450,23 @@ bool SciterMainWindow::OnKeyUp(SCITER_ELEMENT element, SCITER_ELEMENT item, Scit
434450
bool SciterMainWindow::OnKeyChar(SCITER_ELEMENT element, SCITER_ELEMENT item, SciterKeys keyCode, uint32_t keyboardState)
435451
{
436452
return false;
437-
}
453+
}
454+
455+
bool SciterMainWindow::OnSizeChanged(SCITER_ELEMENT elem)
456+
{
457+
SciterElement rootElement(m_window->GetRootElement());
458+
if (elem == rootElement.GetElementByID("MainContents"))
459+
{
460+
SciterElement::RECT rect = SciterElement(elem).GetLocation();
461+
uint32_t width = rect.right - rect.left;
462+
uint32_t height = rect.bottom - rect.top;
463+
MoveWindow((HWND)m_renderWindow, rect.left, rect.top, width, height, false);
464+
SwitchSystem * system = SwitchSystem::GetInstance();
465+
if (system != nullptr)
466+
{
467+
IVideo & video = system->Video();
468+
video.UpdateFramebufferLayout(width, height);
469+
}
470+
}
471+
return false;
472+
}

src/nxemu/user_interface/sciter_main_window.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ class SciterMainWindow :
88
public IWindowDestroySink,
99
public IMenuBarSink,
1010
public IRenderWindow,
11-
public IKeySink
11+
public IKeySink,
12+
public IResizeSink
1213
{
1314
enum MainMenuID
1415
{
@@ -59,12 +60,16 @@ class SciterMainWindow :
5960

6061
// IRenderWindow
6162
void * RenderSurface(void) const override;
63+
float PixelRatio(void) const override;
6264

6365
// IKeySink
6466
bool OnKeyDown(SCITER_ELEMENT element, SCITER_ELEMENT item, SciterKeys keyCode, uint32_t keyboardState) override;
6567
bool OnKeyUp(SCITER_ELEMENT element, SCITER_ELEMENT item, SciterKeys keyCode, uint32_t keyboardState) override;
6668
bool OnKeyChar(SCITER_ELEMENT element, SCITER_ELEMENT item, SciterKeys keyCode, uint32_t keyboardState) override;
6769

70+
// IResizeSink
71+
bool OnSizeChanged(SCITER_ELEMENT elem);
72+
6873
ISciterUI & m_sciterUI;
6974
ISciterWindow * m_window;
7075
std::shared_ptr<IMenuBar> m_menuBar;

src/yuzu_common/intrusive_list.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,13 @@ class IntrusiveListImpl {
259259
splice_impl(pos, o.begin(), o.end());
260260
}
261261

262-
constexpr void splice(const_iterator pos, IntrusiveListImpl& o, const_iterator first) {
262+
constexpr void splice(const_iterator pos, IntrusiveListImpl & /*o*/, const_iterator first) {
263263
const_iterator last(first);
264264
std::advance(last, 1);
265265
splice_impl(pos, first, last);
266266
}
267267

268-
constexpr void splice(const_iterator pos, IntrusiveListImpl& o, const_iterator first,
268+
constexpr void splice(const_iterator pos, IntrusiveListImpl & /*o*/, const_iterator first,
269269
const_iterator last) {
270270
splice_impl(pos, first, last);
271271
}

0 commit comments

Comments
 (0)