Skip to content

Commit

Permalink
Refactor|UI: Relocate the "native UI" mode to libappfw BaseGuiApp
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jun 20, 2016
1 parent 40d10dc commit 07490d8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
15 changes: 0 additions & 15 deletions doomsday/apps/client/include/clientapp.h
Expand Up @@ -88,21 +88,6 @@ public slots:
void openHomepageInBrowser();
void openInBrowser(QUrl url);

/**
* Enters the "native UI" mode that temporarily switches the main window to a
* regular window and restores the desktop display mode. This allows the user to
* access native UI widgets normally.
*
* Call this before showing native UI widgets. You must call endNativeUIMode()
* afterwards.
*/
void beginNativeUIMode();

/**
* Ends the "native UI" mode, restoring the previous main window properties.
*/
void endNativeUIMode();

protected:
void unloadGame(GameProfile const &upcomingGame) override;
void makeGameCurrent(GameProfile const &newGame) override;
Expand Down
22 changes: 0 additions & 22 deletions doomsday/apps/client/src/clientapp.cpp
Expand Up @@ -775,28 +775,6 @@ void ClientApp::openInBrowser(QUrl url)
QDesktopServices::openUrl(url);
}

void ClientApp::beginNativeUIMode()
{
// Switch temporarily to windowed mode. Not needed on OS X because the display mode
// is never changed on that platform.
#ifndef MACOSX
auto &win = ClientWindow::main();
win.saveState();
int const windowedMode[] = {
ClientWindow::Fullscreen, false,
ClientWindow::End
};
win.changeAttributes(windowedMode);
#endif
}

void ClientApp::endNativeUIMode()
{
#ifndef MACOSX
ClientWindow::main().restoreState();
#endif
}

void ClientApp::unloadGame(GameProfile const &upcomingGame)
{
DoomsdayApp::unloadGame(upcomingGame);
Expand Down
15 changes: 15 additions & 0 deletions doomsday/sdk/libappfw/include/de/framework/baseguiapp.h
Expand Up @@ -50,6 +50,21 @@ class LIBAPPFW_PUBLIC BaseGuiApp : public GuiApp
void initSubsystems(SubsystemInitFlags flags = DefaultSubsystems);
double dpiFactor() const;

/**
* Enters the "native UI" mode that temporarily switches the main window to a
* regular window and restores the desktop display mode. This allows the user to
* access native UI widgets normally.
*
* Call this before showing native UI widgets. You must call endNativeUIMode()
* afterwards.
*/
void beginNativeUIMode();

/**
* Ends the "native UI" mode, restoring the previous main window properties.
*/
void endNativeUIMode();

public:
static BaseGuiApp &app();
static PersistentState &persistentUIState();
Expand Down
22 changes: 22 additions & 0 deletions doomsday/sdk/libappfw/src/baseguiapp.cpp
Expand Up @@ -25,6 +25,7 @@
#include <de/DictionaryValue>
#include <de/Function>
#include <de/NativeFont>
#include <de/BaseWindow>
#include <de/ScriptSystem>
#include <QFontDatabase>

Expand Down Expand Up @@ -184,4 +185,25 @@ VRConfig &BaseGuiApp::vr()
return app().d->vr;
}

void BaseGuiApp::beginNativeUIMode()
{
// Switch temporarily to windowed mode. Not needed on OS X because the display mode
// is never changed on that platform.
#ifndef MACOSX
auto &win = static_cast<BaseWindow &>(CanvasWindow::main());
win.saveState();
int const windowedMode[] = {
BaseWindow::Fullscreen, false,
BaseWindow::End
};
win.changeAttributes(windowedMode);
#endif
}

void BaseGuiApp::endNativeUIMode()
{
#ifndef MACOSX
static_cast<BaseWindow &>(CanvasWindow::main()).restoreState();
#endif
}
} // namespace de

0 comments on commit 07490d8

Please sign in to comment.