Skip to content

Commit

Permalink
Remove a few #ifdefs from the Splash header, just skip the call to Sp…
Browse files Browse the repository at this point in the history
…lash::OnAppStartup in Linux.
  • Loading branch information
codereader committed Dec 18, 2017
1 parent b3ab7b1 commit 0695b70
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 23 deletions.
10 changes: 6 additions & 4 deletions radiant/RadiantApp.cpp
Expand Up @@ -8,10 +8,13 @@
#include "modulesystem/ModuleRegistry.h"

#include <wx/wxprec.h>
#include <wx/event.h>
#include <wx/cmdline.h>
#include <sigc++/functors/mem_fun.h>

#ifndef __linux__
#include "ui/splash/Splash.h"
#include <sigc++/functors/mem_fun.h>
#endif

#ifndef POSIX
#include "settings/LanguageManager.h"
Expand Down Expand Up @@ -74,7 +77,7 @@ bool RadiantApp::OnInit()
wxInitAllImageHandlers();

// Register to the start up signal
Connect(EV_RadiantStartup, wxCommandEventHandler(RadiantApp::onStartupEvent), NULL, this);
Bind(EV_RadiantStartup, sigc::mem_fun(*this, &RadiantApp::onStartupEvent));

// Activate the Popup Error Handler
_context.initErrorHandler();
Expand Down Expand Up @@ -135,8 +138,7 @@ void RadiantApp::onStartupEvent(wxCommandEvent& ev)
#ifndef __linux__
// We skip the splash screen in Linux, but the other platforms will show a progress bar
// Connect the progress callback to the Splash instance.
module::ModuleRegistry::Instance().signal_moduleInitialisationProgress().connect(
sigc::mem_fun(ui::Splash::Instance(), &ui::Splash::setProgressAndText));
ui::Splash::OnAppStartup();
#endif

module::ModuleRegistry::Instance().loadAndInitialiseModules();
Expand Down
21 changes: 10 additions & 11 deletions radiant/ui/splash/Splash.cpp
Expand Up @@ -6,13 +6,13 @@
#include <wx/sizer.h>
#include <wx/app.h>
#include <sigc++/retype_return.h>
#include <sigc++/functors/mem_fun.h>

#include "modulesystem/ModuleRegistry.h"

namespace ui
{

#if !defined(__linux__)
namespace
{
const char* const SPLASH_FILENAME = "darksplash.png";
Expand Down Expand Up @@ -67,8 +67,8 @@ void wxImagePanel::render(wxDC& dc)
}

Splash::Splash() :
wxFrame(NULL, wxID_ANY, wxT("DarkRadiant"), wxDefaultPosition, wxDefaultSize, wxCENTRE),
_progressBar(NULL)
wxFrame(nullptr, wxID_ANY, wxT("DarkRadiant"), wxDefaultPosition, wxDefaultSize, wxCENTRE),
_progressBar(nullptr)
{
const ApplicationContext& ctx = module::ModuleRegistry::Instance().getApplicationContext();
std::string fullFileName(ctx.getBitmapsPath() + SPLASH_FILENAME);
Expand Down Expand Up @@ -101,30 +101,22 @@ void Splash::queueDraw()
wxTheApp->Yield(true);
}

#endif

void Splash::setText(const std::string& text)
{
#if !defined(__linux__)
_imagePanel->setText(text);
queueDraw();
#endif
}

void Splash::setProgress(float fraction)
{
#if !defined(__linux__)
_progressBar->SetValue(static_cast<int>(fraction*100));
queueDraw();
#endif
}

void Splash::setProgressAndText(const std::string& text, float fraction)
{
#if !defined(__linux__)
setText(text);
setProgress(fraction);
#endif
}

Splash& Splash::Instance()
Expand All @@ -133,4 +125,11 @@ Splash& Splash::Instance()
return *instance;
}

void Splash::OnAppStartup()
{
// Connect the module progress callback
module::ModuleRegistry::Instance().signal_moduleInitialisationProgress().connect(
sigc::mem_fun(Instance(), &Splash::setProgressAndText));
}

} // namespace ui
13 changes: 5 additions & 8 deletions radiant/ui/splash/Splash.h
Expand Up @@ -16,14 +16,12 @@ class Splash :
public wxFrame,
public sigc::trackable
{
#if !defined(__linux__)
private:
wxGauge* _progressBar;
wxImagePanel* _imagePanel;

// Private constructor, creates all the widgets
Splash();
#endif

public:
/** greebo: Sets the text and/or progress of the progress bar.
Expand All @@ -34,14 +32,13 @@ class Splash :

static Splash& Instance();

#if !defined(__linux__)
private:
void createProgressBar();
// Shows and connects the Splash screen window for progress display
// Note: does nothing for the Linux platform
static void OnAppStartup();

/** greebo: Triggers a redraw of the splash screen
*/
private:
// greebo: Triggers a redraw of the splash screen
void queueDraw();
#endif
};

} // namespace ui

0 comments on commit 0695b70

Please sign in to comment.