Integrate C++11 branch into 5_1-new

This commit is contained in:
teejusb
2019-06-22 12:35:38 -07:00
444 changed files with 19503 additions and 21007 deletions
+82 -82
View File
@@ -1,82 +1,82 @@
#include "global.h"
#include "LoadingWindow.h"
#include "PrefsManager.h"
#include "RageLog.h"
#include "arch/arch_default.h"
LoadingWindow *LoadingWindow::Create()
{
if( !PREFSMAN->m_bShowLoadingWindow )
return new LoadingWindow_Null;
#if defined(UNIX) && !defined(HAVE_GTK)
return new LoadingWindow_Null;
#endif
// Don't load NULL by default.
const RString drivers = "win32,macosx,gtk";
vector<RString> DriversToTry;
split( drivers, ",", DriversToTry, true );
ASSERT( DriversToTry.size() != 0 );
RString Driver;
LoadingWindow *ret = NULL;
for( unsigned i = 0; ret == NULL && i < DriversToTry.size(); ++i )
{
Driver = DriversToTry[i];
#ifdef USE_LOADING_WINDOW_MACOSX
if( !DriversToTry[i].CompareNoCase("MacOSX") ) ret = new LoadingWindow_MacOSX;
#endif
#ifdef USE_LOADING_WINDOW_GTK
if( !DriversToTry[i].CompareNoCase("Gtk") ) ret = new LoadingWindow_Gtk;
#endif
#ifdef USE_LOADING_WINDOW_WIN32
if( !DriversToTry[i].CompareNoCase("Win32") ) ret = new LoadingWindow_Win32;
#endif
if( !DriversToTry[i].CompareNoCase("Null") ) ret = new LoadingWindow_Null;
if( ret == NULL )
continue;
RString sError = ret->Init();
if( sError != "" )
{
LOG->Info( "Couldn't load driver %s: %s", DriversToTry[i].c_str(), sError.c_str() );
SAFE_DELETE( ret );
}
}
if( ret ) {
LOG->Info( "Loading window: %s", Driver.c_str() );
ret->SetIndeterminate(true);
}
return ret;
}
/*
* (c) 2002-2005 Glenn Maynard
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include "global.h"
#include "LoadingWindow.h"
#include "PrefsManager.h"
#include "RageLog.h"
#include "arch/arch_default.h"
LoadingWindow *LoadingWindow::Create()
{
if( !PREFSMAN->m_bShowLoadingWindow )
return new LoadingWindow_Null;
#if defined(UNIX) && !defined(HAVE_GTK)
return new LoadingWindow_Null;
#endif
// Don't load nullptr by default.
const RString drivers = "win32,macosx,gtk";
vector<RString> DriversToTry;
split( drivers, ",", DriversToTry, true );
ASSERT( DriversToTry.size() != 0 );
RString Driver;
LoadingWindow *ret = nullptr;
for( unsigned i = 0; ret == nullptr && i < DriversToTry.size(); ++i )
{
Driver = DriversToTry[i];
#ifdef USE_LOADING_WINDOW_MACOSX
if( !DriversToTry[i].CompareNoCase("MacOSX") ) ret = new LoadingWindow_MacOSX;
#endif
#ifdef USE_LOADING_WINDOW_GTK
if( !DriversToTry[i].CompareNoCase("Gtk") ) ret = new LoadingWindow_Gtk;
#endif
#ifdef USE_LOADING_WINDOW_WIN32
if( !DriversToTry[i].CompareNoCase("Win32") ) ret = new LoadingWindow_Win32;
#endif
if( !DriversToTry[i].CompareNoCase("Null") ) ret = new LoadingWindow_Null;
if( ret == nullptr )
continue;
RString sError = ret->Init();
if( sError != "" )
{
LOG->Info( "Couldn't load driver %s: %s", DriversToTry[i].c_str(), sError.c_str() );
SAFE_DELETE( ret );
}
}
if( ret ) {
LOG->Info( "Loading window: %s", Driver.c_str() );
ret->SetIndeterminate(true);
}
return ret;
}
/*
* (c) 2002-2005 Glenn Maynard
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
+137 -137
View File
@@ -1,137 +1,137 @@
#include "global.h"
#include "RageLog.h"
#include "RageFileManager.h"
#include "RageUtil.h"
#include "LoadingWindow_Gtk.h"
#include "LoadingWindow_GtkModule.h"
#include <dlfcn.h>
static void *Handle = NULL;
static INIT Module_Init;
static SHUTDOWN Module_Shutdown;
static SETTEXT Module_SetText;
static SETICON Module_SetIcon;
static SETSPLASH Module_SetSplash;
static SETPROGRESS Module_SetProgress;
static SETINDETERMINATE Module_SetIndeterminate;
LoadingWindow_Gtk::LoadingWindow_Gtk()
{
}
static RString ModuleError( const RString s )
{
return ssprintf( "Couldn't load symbol Module_%s", s.c_str() );
}
RString LoadingWindow_Gtk::Init()
{
ASSERT( Handle == NULL );
Handle = dlopen( RageFileManagerUtil::sDirOfExecutable + "/" + "GtkModule.so", RTLD_NOW );
if( Handle == NULL )
return ssprintf( "dlopen(): %s", dlerror() );
Module_Init = (INIT) dlsym(Handle, "Init");
if( !Module_Init )
return ModuleError("Init");
Module_Shutdown = (SHUTDOWN) dlsym(Handle, "Shutdown");
if( !Module_Shutdown )
return ModuleError("Shutdown");
Module_SetText = (SETTEXT) dlsym(Handle, "SetText");
if( !Module_SetText )
return ModuleError("SetText");
Module_SetIcon = (SETICON) dlsym(Handle, "SetIcon");
if( !Module_SetIcon )
return ModuleError("SetIcon");
Module_SetSplash = (SETSPLASH) dlsym(Handle, "SetSplash");
if( !Module_SetSplash )
return ModuleError("SetSplash");
Module_SetProgress = (SETPROGRESS) dlsym(Handle, "SetProgress");
if( !Module_SetProgress )
return ModuleError("SetProgress");
Module_SetIndeterminate = (SETINDETERMINATE) dlsym(Handle, "SetIndeterminate");
if( !Module_SetIndeterminate )
return ModuleError("SetIndeterminate");
const char *ret = Module_Init( &g_argc, &g_argv );
if( ret != NULL )
return ret;
return "";
}
LoadingWindow_Gtk::~LoadingWindow_Gtk()
{
if( Module_Shutdown != NULL )
Module_Shutdown();
Module_Shutdown = NULL;
if( Handle )
dlclose( Handle );
Handle = NULL;
}
void LoadingWindow_Gtk::SetText( RString s )
{
Module_SetText( s );
}
void LoadingWindow_Gtk::SetIcon( const RageSurface *pIcon )
{
Module_SetIcon( pIcon );
}
void LoadingWindow_Gtk::SetSplash( const RageSurface *pSplash )
{
Module_SetSplash( pSplash );
}
void LoadingWindow_Gtk::SetProgress( const int progress )
{
LoadingWindow::SetProgress( progress );
Module_SetProgress( m_progress, m_totalWork );
}
void LoadingWindow_Gtk::SetTotalWork( const int totalWork )
{
LoadingWindow::SetTotalWork( totalWork );
Module_SetProgress( m_progress, m_totalWork );
}
void LoadingWindow_Gtk::SetIndeterminate( bool indeterminate )
{
LoadingWindow::SetIndeterminate( indeterminate );
Module_SetIndeterminate( m_indeterminate );
}
/*
* (c) 2003-2004 Glenn Maynard, Sean Burke
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include "global.h"
#include "RageLog.h"
#include "RageFileManager.h"
#include "RageUtil.h"
#include "LoadingWindow_Gtk.h"
#include "LoadingWindow_GtkModule.h"
#include <dlfcn.h>
static void *Handle = nullptr;
static INIT Module_Init;
static SHUTDOWN Module_Shutdown;
static SETTEXT Module_SetText;
static SETICON Module_SetIcon;
static SETSPLASH Module_SetSplash;
static SETPROGRESS Module_SetProgress;
static SETINDETERMINATE Module_SetIndeterminate;
LoadingWindow_Gtk::LoadingWindow_Gtk()
{
}
static RString ModuleError( const RString s )
{
return ssprintf( "Couldn't load symbol Module_%s", s.c_str() );
}
RString LoadingWindow_Gtk::Init()
{
ASSERT( Handle == nullptr );
Handle = dlopen( RageFileManagerUtil::sDirOfExecutable + "/" + "GtkModule.so", RTLD_NOW );
if( Handle == nullptr )
return ssprintf( "dlopen(): %s", dlerror() );
Module_Init = (INIT) dlsym(Handle, "Init");
if( !Module_Init )
return ModuleError("Init");
Module_Shutdown = (SHUTDOWN) dlsym(Handle, "Shutdown");
if( !Module_Shutdown )
return ModuleError("Shutdown");
Module_SetText = (SETTEXT) dlsym(Handle, "SetText");
if( !Module_SetText )
return ModuleError("SetText");
Module_SetIcon = (SETICON) dlsym(Handle, "SetIcon");
if( !Module_SetIcon )
return ModuleError("SetIcon");
Module_SetSplash = (SETSPLASH) dlsym(Handle, "SetSplash");
if( !Module_SetSplash )
return ModuleError("SetSplash");
Module_SetProgress = (SETPROGRESS) dlsym(Handle, "SetProgress");
if( !Module_SetProgress )
return ModuleError("SetProgress");
Module_SetIndeterminate = (SETINDETERMINATE) dlsym(Handle, "SetIndeterminate");
if( !Module_SetIndeterminate )
return ModuleError("SetIndeterminate");
const char *ret = Module_Init( &g_argc, &g_argv );
if( ret != nullptr )
return ret;
return "";
}
LoadingWindow_Gtk::~LoadingWindow_Gtk()
{
if( Module_Shutdown != nullptr )
Module_Shutdown();
Module_Shutdown = nullptr;
if( Handle )
dlclose( Handle );
Handle = nullptr;
}
void LoadingWindow_Gtk::SetText( RString s )
{
Module_SetText( s );
}
void LoadingWindow_Gtk::SetIcon( const RageSurface *pIcon )
{
Module_SetIcon( pIcon );
}
void LoadingWindow_Gtk::SetSplash( const RageSurface *pSplash )
{
Module_SetSplash( pSplash );
}
void LoadingWindow_Gtk::SetProgress( const int progress )
{
LoadingWindow::SetProgress( progress );
Module_SetProgress( m_progress, m_totalWork );
}
void LoadingWindow_Gtk::SetTotalWork( const int totalWork )
{
LoadingWindow::SetTotalWork( totalWork );
Module_SetProgress( m_progress, m_totalWork );
}
void LoadingWindow_Gtk::SetIndeterminate( bool indeterminate )
{
LoadingWindow::SetIndeterminate( indeterminate );
Module_SetIndeterminate( m_indeterminate );
}
/*
* (c) 2003-2004 Glenn Maynard, Sean Burke
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
+151 -151
View File
@@ -1,151 +1,151 @@
#include "global.h"
#include "LoadingWindow_GtkModule.h"
#include "RageUtil.h"
#include "RageSurface.h"
#include "RageSurfaceUtils.h"
#include "RageSurface_Load.h"
#include <gtk/gtk.h>
static GtkWidget *label;
static GtkWidget *window;
static GtkWidget *splash;
static GtkWidget *progressBar;
extern "C" const char *Init( int *argc, char ***argv )
{
// Need to use external library to load this image. Native loader seems broken :/
const gchar *splash_image_path = "Data/splash.png";
GtkWidget *vbox;
gtk_disable_setlocale();
if( !gtk_init_check(argc,argv) )
return "Couldn't initialize gtk (cannot open display)";
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position( GTK_WINDOW(window), GTK_WIN_POS_CENTER );
gtk_widget_set_size_request(window,468,-1);
gtk_window_set_deletable( GTK_WINDOW(window), FALSE );
gtk_window_set_resizable(GTK_WINDOW(window),FALSE);
gtk_window_set_role( GTK_WINDOW(window), "sm-startup" );
//gtk_window_set_icon( GTK_WINDOW(window), );
gtk_widget_realize(window);
splash = gtk_image_new_from_file(splash_image_path);
label = gtk_label_new(NULL);
gtk_label_set_justify(GTK_LABEL(label),GTK_JUSTIFY_CENTER);
gtk_label_set_ellipsize(GTK_LABEL(label),PANGO_ELLIPSIZE_END);
gtk_label_set_line_wrap(GTK_LABEL(label),FALSE);
progressBar = gtk_progress_bar_new();
gtk_progress_bar_set_fraction( GTK_PROGRESS_BAR(progressBar), 0.0 );
vbox = gtk_vbox_new(FALSE,0);
gtk_container_add(GTK_CONTAINER(window),vbox);
gtk_box_pack_start(GTK_BOX(vbox),splash,FALSE,FALSE,0);
gtk_box_pack_end(GTK_BOX(vbox),progressBar,FALSE,FALSE,0);
gtk_box_pack_end(GTK_BOX(vbox),label,TRUE,TRUE,0);
gtk_widget_show_all(window);
gtk_main_iteration_do(FALSE);
return NULL;
}
extern "C" void Shutdown()
{
gtk_widget_hide(window);
g_signal_emit_by_name (G_OBJECT (window), "destroy");
while( gtk_events_pending() )
gtk_main_iteration_do(FALSE);
}
extern "C" void SetText( const char *s )
{
gtk_label_set_text(GTK_LABEL(label), s);
gtk_widget_show(label);
gtk_main_iteration_do(FALSE);
}
void DeletePixels( guchar *pixels, gpointer data )
{
delete[] (uint8_t *)pixels;
}
GdkPixbuf *MakePixbuf( const RageSurface *pSrc )
{
RageSurface *pSurface = CreateSurface( pSrc->w, pSrc->h, 32,
0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 );
RageSurfaceUtils::Blit( pSrc, pSurface , -1, -1 );
GdkPixbuf *pBuf = gdk_pixbuf_new_from_data( pSurface->pixels, GDK_COLORSPACE_RGB,
true, 8, pSurface->w, pSurface->h , pSurface->pitch, DeletePixels, NULL);
if( pBuf != NULL )
pSurface->pixels_owned = false;
delete pSurface;
return pBuf;
}
extern "C" void SetIcon( const RageSurface *pSrcImg )
{
GdkPixbuf *pBuf = MakePixbuf( pSrcImg );
if( pBuf != NULL )
{
gtk_window_set_icon( GTK_WINDOW(window), pBuf );
g_object_unref(pBuf);
}
gtk_main_iteration_do(FALSE);
}
extern "C" void SetSplash( const RageSurface *pSplash )
{
GdkPixbuf *pBuf = MakePixbuf( pSplash );
if( pBuf != NULL )
{
gtk_image_set_from_pixbuf(GTK_IMAGE(splash), pBuf);
g_object_unref(pBuf);
}
gtk_main_iteration_do(FALSE);
}
extern "C" void SetProgress( int progress, int totalWork )
{
gdouble fraction = ( totalWork > 0 ? progress / (gdouble)totalWork : 0 );
if( fraction > 1.0 ) fraction = 1.0;
if( fraction < 0.0 ) fraction = 0.0;
gtk_progress_bar_set_fraction( GTK_PROGRESS_BAR(progressBar), fraction );
gtk_main_iteration_do(FALSE);
}
extern "C" void SetIndeterminate( bool indeterminate )
{
gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progressBar));
gtk_main_iteration_do(FALSE);
}
/*
* (c) 2003-2004 Glenn Maynard, Sean Burke
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include "global.h"
#include "LoadingWindow_GtkModule.h"
#include "RageUtil.h"
#include "RageSurface.h"
#include "RageSurfaceUtils.h"
#include "RageSurface_Load.h"
#include <gtk/gtk.h>
static GtkWidget *label;
static GtkWidget *window;
static GtkWidget *splash;
static GtkWidget *progressBar;
extern "C" const char *Init( int *argc, char ***argv )
{
// Need to use external library to load this image. Native loader seems broken :/
const gchar *splash_image_path = "Data/splash.png";
GtkWidget *vbox;
gtk_disable_setlocale();
if( !gtk_init_check(argc,argv) )
return "Couldn't initialize gtk (cannot open display)";
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position( GTK_WINDOW(window), GTK_WIN_POS_CENTER );
gtk_widget_set_size_request(window,468,-1);
gtk_window_set_deletable( GTK_WINDOW(window), FALSE );
gtk_window_set_resizable(GTK_WINDOW(window),FALSE);
gtk_window_set_role( GTK_WINDOW(window), "sm-startup" );
//gtk_window_set_icon( GTK_WINDOW(window), );
gtk_widget_realize(window);
splash = gtk_image_new_from_file(splash_image_path);
label = gtk_label_new(nullptr);
gtk_label_set_justify(GTK_LABEL(label),GTK_JUSTIFY_CENTER);
gtk_label_set_ellipsize(GTK_LABEL(label),PANGO_ELLIPSIZE_END);
gtk_label_set_line_wrap(GTK_LABEL(label),FALSE);
progressBar = gtk_progress_bar_new();
gtk_progress_bar_set_fraction( GTK_PROGRESS_BAR(progressBar), 0.0 );
vbox = gtk_vbox_new(FALSE,0);
gtk_container_add(GTK_CONTAINER(window),vbox);
gtk_box_pack_start(GTK_BOX(vbox),splash,FALSE,FALSE,0);
gtk_box_pack_end(GTK_BOX(vbox),progressBar,FALSE,FALSE,0);
gtk_box_pack_end(GTK_BOX(vbox),label,TRUE,TRUE,0);
gtk_widget_show_all(window);
gtk_main_iteration_do(FALSE);
return nullptr;
}
extern "C" void Shutdown()
{
gtk_widget_hide(window);
g_signal_emit_by_name (G_OBJECT (window), "destroy");
while( gtk_events_pending() )
gtk_main_iteration_do(FALSE);
}
extern "C" void SetText( const char *s )
{
gtk_label_set_text(GTK_LABEL(label), s);
gtk_widget_show(label);
gtk_main_iteration_do(FALSE);
}
void DeletePixels( guchar *pixels, gpointer data )
{
delete[] (uint8_t *)pixels;
}
GdkPixbuf *MakePixbuf( const RageSurface *pSrc )
{
RageSurface *pSurface = CreateSurface( pSrc->w, pSrc->h, 32,
0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 );
RageSurfaceUtils::Blit( pSrc, pSurface , -1, -1 );
GdkPixbuf *pBuf = gdk_pixbuf_new_from_data( pSurface->pixels, GDK_COLORSPACE_RGB,
true, 8, pSurface->w, pSurface->h , pSurface->pitch, DeletePixels, nullptr);
if( pBuf != nullptr )
pSurface->pixels_owned = false;
delete pSurface;
return pBuf;
}
extern "C" void SetIcon( const RageSurface *pSrcImg )
{
GdkPixbuf *pBuf = MakePixbuf( pSrcImg );
if( pBuf != nullptr )
{
gtk_window_set_icon( GTK_WINDOW(window), pBuf );
g_object_unref(pBuf);
}
gtk_main_iteration_do(FALSE);
}
extern "C" void SetSplash( const RageSurface *pSplash )
{
GdkPixbuf *pBuf = MakePixbuf( pSplash );
if( pBuf != nullptr )
{
gtk_image_set_from_pixbuf(GTK_IMAGE(splash), pBuf);
g_object_unref(pBuf);
}
gtk_main_iteration_do(FALSE);
}
extern "C" void SetProgress( int progress, int totalWork )
{
gdouble fraction = ( totalWork > 0 ? progress / (gdouble)totalWork : 0 );
if( fraction > 1.0 ) fraction = 1.0;
if( fraction < 0.0 ) fraction = 0.0;
gtk_progress_bar_set_fraction( GTK_PROGRESS_BAR(progressBar), fraction );
gtk_main_iteration_do(FALSE);
}
extern "C" void SetIndeterminate( bool indeterminate )
{
gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progressBar));
gtk_main_iteration_do(FALSE);
}
/*
* (c) 2003-2004 Glenn Maynard, Sean Burke
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
+19 -19
View File
@@ -17,7 +17,7 @@
#include "LocalizedString.h"
#include "RageSurfaceUtils_Zoom.h"
static HBITMAP g_hBitmap = NULL;
static HBITMAP g_hBitmap = nullptr;
/* Load a RageSurface into a GDI surface. */
static HBITMAP LoadWin32Surface( const RageSurface *pSplash, HWND hWnd )
@@ -39,11 +39,11 @@ static HBITMAP LoadWin32Surface( const RageSurface *pSplash, HWND hWnd )
RageSurfaceUtils::Zoom( s, iWidth, iHeight );
}
HDC hScreen = GetDC(NULL);
ASSERT_M( hScreen != NULL, werr_ssprintf(GetLastError(), "hScreen") );
HDC hScreen = GetDC(nullptr);
ASSERT_M( hScreen != nullptr, werr_ssprintf(GetLastError(), "hScreen") );
HBITMAP bitmap = CreateCompatibleBitmap( hScreen, s->w, s->h );
ASSERT_M( bitmap != NULL, werr_ssprintf(GetLastError(), "CreateCompatibleBitmap") );
ASSERT_M( bitmap != nullptr, werr_ssprintf(GetLastError(), "CreateCompatibleBitmap") );
HDC BitmapDC = CreateCompatibleDC( hScreen );
SelectObject( BitmapDC, bitmap );
@@ -60,10 +60,10 @@ static HBITMAP LoadWin32Surface( const RageSurface *pSplash, HWND hWnd )
}
}
SelectObject( BitmapDC, NULL );
SelectObject( BitmapDC, nullptr );
DeleteObject( BitmapDC );
ReleaseDC( NULL, hScreen );
ReleaseDC( nullptr, hScreen );
delete s;
return bitmap;
@@ -73,8 +73,8 @@ static HBITMAP LoadWin32Surface( RString sFile, HWND hWnd )
{
RString error;
RageSurface *pSurface = RageSurfaceUtils::LoadFile( sFile, error );
if( pSurface == NULL )
return NULL;
if( pSurface == nullptr )
return nullptr;
HBITMAP ret = LoadWin32Surface( pSurface, hWnd );
delete pSurface;
@@ -92,7 +92,7 @@ BOOL CALLBACK LoadingWindow_Win32::WndProc( HWND hWnd, UINT msg, WPARAM wParam,
if( !vs.empty() )
g_hBitmap = LoadWin32Surface( vs[0], hWnd );
}
if( g_hBitmap == NULL )
if( g_hBitmap == nullptr )
g_hBitmap = LoadWin32Surface( "Data/splash.bmp", hWnd );
SendMessage(
GetDlgItem(hWnd,IDC_SPLASH),
@@ -104,7 +104,7 @@ BOOL CALLBACK LoadingWindow_Win32::WndProc( HWND hWnd, UINT msg, WPARAM wParam,
case WM_DESTROY:
DeleteObject( g_hBitmap );
g_hBitmap = NULL;
g_hBitmap = nullptr;
break;
}
@@ -113,25 +113,25 @@ BOOL CALLBACK LoadingWindow_Win32::WndProc( HWND hWnd, UINT msg, WPARAM wParam,
void LoadingWindow_Win32::SetIcon( const RageSurface *pIcon )
{
if( m_hIcon != NULL )
if( m_hIcon != nullptr )
DestroyIcon( m_hIcon );
m_hIcon = IconFromSurface( pIcon );
if( m_hIcon != NULL )
if( m_hIcon != nullptr )
// XXX: GCL_HICON isn't available on x86-64 Windows
SetClassLong( hwnd, GCL_HICON, (LONG) m_hIcon );
}
void LoadingWindow_Win32::SetSplash( const RageSurface *pSplash )
{
if( g_hBitmap != NULL )
if( g_hBitmap != nullptr )
{
DeleteObject( g_hBitmap );
g_hBitmap = NULL;
g_hBitmap = nullptr;
}
g_hBitmap = LoadWin32Surface( pSplash, hwnd );
if( g_hBitmap != NULL )
if( g_hBitmap != nullptr )
{
SendDlgItemMessage(
hwnd, IDC_SPLASH,
@@ -144,9 +144,9 @@ void LoadingWindow_Win32::SetSplash( const RageSurface *pSplash )
LoadingWindow_Win32::LoadingWindow_Win32()
{
m_hIcon = NULL;
hwnd = CreateDialog( handle.Get(), MAKEINTRESOURCE(IDD_LOADING_DIALOG), NULL, WndProc );
ASSERT( hwnd != NULL );
m_hIcon = nullptr;
hwnd = CreateDialog( handle.Get(), MAKEINTRESOURCE(IDD_LOADING_DIALOG), nullptr, WndProc );
ASSERT( hwnd != nullptr );
for( unsigned i = 0; i < 3; ++i )
text[i] = "ABC"; /* always set on first call */
SetText( "" );
@@ -157,7 +157,7 @@ LoadingWindow_Win32::~LoadingWindow_Win32()
{
if( hwnd )
DestroyWindow( hwnd );
if( m_hIcon != NULL )
if( m_hIcon != nullptr )
DestroyIcon( m_hIcon );
}