Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for high DPI on Windows and Mac #43

Merged
merged 8 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ FILE(GLOB_RECURSE SOURCES src/*.cpp)
if (WIN32)
ENABLE_LANGUAGE(RC)
set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/win_stuff/resource.rc ${SOURCES})
set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/win_stuff/DeltaPatcher.exe.manifest ${SOURCES})
endif()

add_executable(DeltaPatcher WIN32 ${SOURCES})

target_link_libraries(DeltaPatcher wx::core wx::base xdelta3)

if (APPLE)
Expand Down
15 changes: 4 additions & 11 deletions app/include/gui/dpgui.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 12 2015)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////

#ifndef __DPGUI_H__
#define __DPGUI_H__

Expand Down Expand Up @@ -77,7 +70,7 @@ class MainDialog : public wxDialog

public:

MainDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Delta Patcher"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 504,-1 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER );
MainDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Delta Patcher"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER );
~MainDialog();

};
Expand Down Expand Up @@ -123,7 +116,7 @@ class DecodePanel : public wxPanel
public:
wxBoxSizer* decodeMainSizer;

DecodePanel( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 260,184 ), long style = wxTAB_TRAVERSAL );
DecodePanel( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL );
~DecodePanel();

};
Expand Down Expand Up @@ -174,7 +167,7 @@ class EncodePanel : public wxPanel

public:

EncodePanel( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 320,407 ), long style = wxTAB_TRAVERSAL );
EncodePanel( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL );
~EncodePanel();

};
Expand Down Expand Up @@ -212,7 +205,7 @@ class AboutDialog : public wxDialog

public:

AboutDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("About Delta Patcher"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 354,308 ), long style = wxDEFAULT_DIALOG_STYLE );
AboutDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("About Delta Patcher"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE );
~AboutDialog();

};
Expand Down
2 changes: 2 additions & 0 deletions app/mac_stuff/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<string>2010+ Phoenix (SadNES cITy Translations)</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSHighResolutionCapable</key>
<string>True</string>
<key>CFBundleIconFile</key>
<string>icon</string>
</dict>
Expand Down
6 changes: 6 additions & 0 deletions app/src/gui/DeltaPatcherDecodePanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <wx/generic/msgdlgg.h>
#include <wx/richtooltip.h>

#define DECODE_TEXTCTRL_WIDTH 17

DeltaPatcherDecodePanel::DeltaPatcherDecodePanel( wxWindow* parent,Logger* l )
:
DecodePanel( parent ), logger( l )
Expand All @@ -33,6 +35,10 @@ DecodePanel( parent ), logger( l )
checksumCheck = new wxMenuItem( applyOptionsMenu, wxID_ANY, wxString( _("Checksum validation") ) , wxEmptyString, wxITEM_CHECK );
applyOptionsMenu->Append( checksumCheck );
checksumCheck->Check( true );

wxSize sizeM = GetTextExtent("M");
originalField->SetSizeHints(DECODE_TEXTCTRL_WIDTH*sizeM.x,-1);
patchField->SetSizeHints(DECODE_TEXTCTRL_WIDTH*sizeM.x,-1);
}

void DeltaPatcherDecodePanel::OnDecodeOptionsClicked(wxCommandEvent& event)
Expand Down
9 changes: 9 additions & 0 deletions app/src/gui/DeltaPatcherEncodePanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#include <gui/icons/save.xpm>
#include <gui/icons/config.xpm>

#define ENCODE_TEXTCTRL_WIDTH 25
#define ENCODE_DESCRIPTION_TEXTCTRL_HEIGHT 10

class EncodePanelDropHandler : public DeltaPatcherDropHandler
{
private:
Expand Down Expand Up @@ -94,6 +97,12 @@ EncodePanel( parent ), logger( l )
checksumCheck = new wxMenuItem( createOptionsMenu, wxID_ANY, wxString( _("Add Checksum to patch") ) , wxEmptyString, wxITEM_CHECK );
createOptionsMenu->Append( checksumCheck );
checksumCheck->Check( true );

wxSize sizeM = GetTextExtent("M");
originalField->SetSizeHints(ENCODE_TEXTCTRL_WIDTH*sizeM.x,-1);
modifiedField->SetSizeHints(ENCODE_TEXTCTRL_WIDTH*sizeM.x,-1);
descriptionField->SetSizeHints(ENCODE_TEXTCTRL_WIDTH*sizeM.x,ENCODE_DESCRIPTION_TEXTCTRL_HEIGHT*sizeM.y);
patchField->SetSizeHints(ENCODE_TEXTCTRL_WIDTH*sizeM.x,-1);
}

void DeltaPatcherEncodePanel::OnEncodeOptionsClicked(wxCommandEvent& event)
Expand Down
11 changes: 9 additions & 2 deletions app/src/gui/DeltaPatcherMainDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <gui/icons/switch.xpm>
#include <gui/icons/log.xpm>

#define LOG_CTRL_WIDTH 30

DeltaPatcherMainDialog::DeltaPatcherMainDialog( wxWindow* parent, const wxString& patchName )
:
MainDialog( parent ), decodeMode(true), pendingPatchPath(patchName)
Expand Down Expand Up @@ -38,20 +40,25 @@ MainDialog( parent ), decodeMode(true), pendingPatchPath(patchName)

nullPanel->Show(false);

wxSize sizeM = GetTextExtent("M");
wxSize minLogCtrlSize(LOG_CTRL_WIDTH*sizeM.x,-1);

//preparing default panel
decodePanel=new DeltaPatcherDecodePanel(this,this);

panelSizer->Add( decodePanel, 1, wxEXPAND | wxALL, 5 );
decodePanel->GetSizer()->Fit(decodePanel);

//preparing encode panel
encodePanel=new DeltaPatcherEncodePanel(this,this);

encodePanel->Show(false);
panelSizer->Add( encodePanel, 1, wxEXPAND | wxALL, 5 );

//preparing log area
logCtrl->SetEditable(false);

logCtrl->SetSizeHints(minLogCtrlSize);

//checking release type
#ifdef __DP_DECODE_ONLY__
operationButton->Show(false);
Expand Down
13 changes: 2 additions & 11 deletions app/src/gui/dpgui.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 12 2015)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////

#include <gui/dpgui.h>

///////////////////////////////////////////////////////////////////////////

BEGIN_EVENT_TABLE( MainDialog, wxDialog )
EVT_ACTIVATE( MainDialog::_wxFB_OnActivate )
EVT_CLOSE( MainDialog::_wxFB_OnMainDialogClose )
Expand All @@ -28,7 +19,7 @@ MainDialog::MainDialog( wxWindow* parent, wxWindowID id, const wxString& title,

panelSizer = new wxBoxSizer( wxVERTICAL );

nullPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxSize( 260,184 ), wxTAB_TRAVERSAL );
nullPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
panelSizer->Add( nullPanel, 1, wxEXPAND | wxALL, 5 );


Expand Down Expand Up @@ -72,7 +63,7 @@ MainDialog::MainDialog( wxWindow* parent, wxWindowID id, const wxString& title,

logBox = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Log:") ), wxVERTICAL );

logCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 350,-1 ), wxHSCROLL|wxTE_MULTILINE|wxTE_WORDWRAP );
logCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxTE_MULTILINE|wxTE_WORDWRAP );
logBox->Add( logCtrl, 1, wxALL|wxEXPAND, 5 );


Expand Down
9 changes: 9 additions & 0 deletions app/win_stuff/DeltaPatcher.exe.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:application>
<asmv3:windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>