m_observer.onChanged();
}
typedef MemberCaller<StringPreference, void(const char*), &StringPreference::importString> ImportStringCaller;
-void exportString( StringImportCallback& importer ){
+void exportString( ImportExportCallback<const char *>::Import_t& importer ){
importer( m_string.c_str() );
}
-typedef MemberCaller<StringPreference, void(StringImportCallback&), &StringPreference::exportString> ExportStringCaller;
+typedef MemberCaller<StringPreference, void(ImportExportCallback<const char *>::Import_t&), &StringPreference::exportString> ExportStringCaller;
};
-inline void int_export( int i, StringImportCallback& importer ){
+inline void int_export( int i, ImportExportCallback<const char *>::Import_t& importer ){
char buffer[16];
sprintf( buffer, "%d", i );
importer( buffer );
m_observer.onChanged();
}
typedef MemberCaller<IntPreference, void(const char*), &IntPreference::importString> ImportStringCaller;
-void exportString( StringImportCallback& importer ){
+void exportString( ImportExportCallback<const char *>::Import_t& importer ){
int_export( m_int, importer );
}
-typedef MemberCaller<IntPreference, void(StringImportCallback&), &IntPreference::exportString> ExportStringCaller;
+typedef MemberCaller<IntPreference, void(ImportExportCallback<const char *>::Import_t&), &IntPreference::exportString> ExportStringCaller;
};
class IntPreferenceImporter
#include "generic/constant.h"
#include "generic/callback.h"
-typedef Callback<void(const char*)> StringImportCallback;
-typedef Callback<void(const StringImportCallback&)> StringExportCallback;
-
class PreferenceSystem
{
public:
INTEGER_CONSTANT( Version, 1 );
STRING_CONSTANT( Name, "preferences" );
-virtual void registerPreference( const char* name, const StringImportCallback& importer, const StringExportCallback& exporter ) = 0;
+virtual void registerPreference( const char* name, const ImportExportCallback<const char *>::Import_t& importer, const ImportExportCallback<const char *>::Export_t& exporter ) = 0;
};
#include "modulesystem.h"
Test test;
const Test& testconst = test;
{
- Callback<void()> a = makeCallbackF(&test0free)();
+ Callback<void()> a = makeCallbackF(&test0free);
Callback<void()> b = Test::Test0Caller( test );
b = makeCallback( Test::Test0(), test );
Callback<void()> c = Test::Test0ConstCaller( testconst );
}
{
typedef Callback<void(A1)> TestCallback1;
- TestCallback1 a = makeCallbackF(&test1free));
+ TestCallback1 a = makeCallbackF(&test1free);
TestCallback1 b = Test::Test1Caller( test );
b = makeCallback( Test::Test1(), test );
TestCallback1 c = Test::Test1ConstCaller( testconst );
return Callback<F>(reinterpret_cast<void *>(func), BindFirstOpaque<detail::freecallwrapper<F>>::thunk);
}
-// todo: remove
-
-using BoolImportCallback = Callback<void(bool)>;
-using BoolExportCallback = Callback<void(const BoolImportCallback&)>;
-
-using IntImportCallback = Callback<void(int)>;
-using IntExportCallback = Callback<void(const IntImportCallback&)>;
-
-using FloatImportCallback = Callback<void(float)>;
-using FloatExportCallback = Callback<void(const FloatImportCallback&)>;
-
-using StringImportCallback = Callback<void(const char*)>;
-using StringExportCallback = Callback<void(const StringImportCallback&)>;
-
-using SizeImportCallback = Callback<void(std::size_t)>;
-using SizeExportCallback = Callback<void(const SizeImportCallback&)>;
+template <class T>
+struct ImportExportCallback {
+ using Import_t = Callback<void(T)>;
+ Import_t Import;
+ using Export_t = Callback<void(const Callback<void(T)> &)>;
+ Export_t Export;
+};
#endif
{
public:
Command m_command;
-BoolExportCallback m_exportCallback;
-Toggle( const Callback<void()>& callback, const Accelerator& accelerator, const BoolExportCallback& exportCallback ) : m_command( callback, accelerator ), m_exportCallback( exportCallback ){
+ImportExportCallback<bool>::Export_t m_exportCallback;
+Toggle( const Callback<void()>& callback, const Accelerator& accelerator, const ImportExportCallback<bool>::Export_t& exportCallback ) : m_command( callback, accelerator ), m_exportCallback( exportCallback ){
}
};
}
}
-void ToggleShown::exportActive(const BoolImportCallback &importCallback)
+void ToggleShown::exportActive(const ImportExportCallback<bool>::Import_t &importCallback)
{
importCallback(active());
}
#include "debugging/debugging.h"
class ToggleItem {
- BoolExportCallback m_exportCallback;
- typedef std::list<BoolImportCallback> ImportCallbacks;
+ ImportExportCallback<bool>::Export_t m_exportCallback;
+ typedef std::list<ImportExportCallback<bool>::Import_t> ImportCallbacks;
ImportCallbacks m_importCallbacks;
public:
- ToggleItem(const BoolExportCallback &exportCallback) : m_exportCallback(exportCallback)
+ ToggleItem(const ImportExportCallback<bool>::Export_t &exportCallback) : m_exportCallback(exportCallback)
{
}
}
}
- void addCallback(const BoolImportCallback &callback)
+ void addCallback(const ImportExportCallback<bool>::Import_t &callback)
{
m_importCallbacks.push_back(callback);
m_exportCallback(callback);
}
- typedef MemberCaller<ToggleItem, void(const BoolImportCallback &), &ToggleItem::addCallback> AddCallbackCaller;
+ typedef MemberCaller<ToggleItem, void(const ImportExportCallback<bool>::Import_t &), &ToggleItem::addCallback> AddCallbackCaller;
};
class ToggleShown {
bool active() const;
- void exportActive(const BoolImportCallback &importCallback);
+ void exportActive(const ImportExportCallback<bool>::Import_t &importCallback);
- typedef MemberCaller<ToggleShown, void(const BoolImportCallback &), &ToggleShown::exportActive> ActiveCaller;
+ typedef MemberCaller<ToggleShown, void(const ImportExportCallback<bool>::Import_t &), &ToggleShown::exportActive> ActiveCaller;
void set(bool shown);
}
}
-void WindowPosition_Write(const WindowPosition &position, const StringImportCallback &importCallback)
+void WindowPosition_Write(const WindowPosition &position, const ImportExportCallback<const char *>::Import_t &importCallback)
{
char buffer[64];
sprintf( buffer, "%d %d %d %d", position.x, position.y, position.w, position.h );
self.setPosition( position );
}
-void WindowPositionTracker_exportString(const WindowPositionTracker &self, const StringImportCallback &importer)
+void WindowPositionTracker_exportString(const WindowPositionTracker &self, const ImportExportCallback<const char *>::Import_t &importer)
{
WindowPosition_Write( self.getPosition(), importer );
}
typedef ReferenceCaller<WindowPosition, void(const char *), WindowPosition_Parse> WindowPositionImportStringCaller;
-void WindowPosition_Write(const WindowPosition &position, const StringImportCallback &importCallback);
+void WindowPosition_Write(const WindowPosition &position, const ImportExportCallback<const char *>::Import_t &importCallback);
-typedef ConstReferenceCaller<WindowPosition, void(const StringImportCallback &), WindowPosition_Write> WindowPositionExportStringCaller;
+typedef ConstReferenceCaller<WindowPosition, void(const ImportExportCallback<const char *>::Import_t &), WindowPosition_Write> WindowPositionExportStringCaller;
class WindowPositionTracker {
typedef ReferenceCaller<WindowPositionTracker, void(const char *), WindowPositionTracker_importString> WindowPositionTrackerImportStringCaller;
-void WindowPositionTracker_exportString(const WindowPositionTracker &self, const StringImportCallback &importer);
+void WindowPositionTracker_exportString(const WindowPositionTracker &self, const ImportExportCallback<const char *>::Import_t &importer);
-typedef ConstReferenceCaller<WindowPositionTracker, void(const StringImportCallback &), WindowPositionTracker_exportString> WindowPositionTrackerExportStringCaller;
+typedef ConstReferenceCaller<WindowPositionTracker, void(const ImportExportCallback<const char *>::Import_t &), WindowPositionTracker_exportString> WindowPositionTrackerExportStringCaller;
#endif
self = string;
}
typedef ReferenceCaller<CopiedString, void(const char*), CopiedString_importString> CopiedStringImportStringCaller;
-inline void CopiedString_exportString( const CopiedString& self, const StringImportCallback& importer ){
+inline void CopiedString_exportString( const CopiedString& self, const ImportExportCallback<const char *>::Import_t& importer ){
importer( self.c_str() );
}
-typedef ConstReferenceCaller<CopiedString, void(const StringImportCallback&), CopiedString_exportString> CopiedStringExportStringCaller;
+typedef ConstReferenceCaller<CopiedString, void(const ImportExportCallback<const char *>::Import_t&), CopiedString_exportString> CopiedStringExportStringCaller;
inline void Bool_importString( bool& self, const char* string ){
self = string_equal( string, "true" );
}
typedef ReferenceCaller<bool, void(const char*), Bool_importString> BoolImportStringCaller;
-inline void Bool_exportString( const bool& self, const StringImportCallback& importer ){
+inline void Bool_exportString( const bool& self, const ImportExportCallback<const char *>::Import_t& importer ){
importer( self ? "true" : "false" );
}
-typedef ConstReferenceCaller<bool, void(const StringImportCallback&), Bool_exportString> BoolExportStringCaller;
+typedef ConstReferenceCaller<bool, void(const ImportExportCallback<const char *>::Import_t&), Bool_exportString> BoolExportStringCaller;
inline void Int_importString( int& self, const char* string ){
if ( !string_parse_int( string, self ) ) {
}
}
typedef ReferenceCaller<int, void(const char*), Int_importString> IntImportStringCaller;
-inline void Int_exportString( const int& self, const StringImportCallback& importer ){
+inline void Int_exportString( const int& self, const ImportExportCallback<const char *>::Import_t& importer ){
char buffer[16];
sprintf( buffer, "%d", self );
importer( buffer );
}
-typedef ConstReferenceCaller<int, void(const StringImportCallback&), Int_exportString> IntExportStringCaller;
+typedef ConstReferenceCaller<int, void(const ImportExportCallback<const char *>::Import_t&), Int_exportString> IntExportStringCaller;
inline void Size_importString( std::size_t& self, const char* string ){
int i;
}
}
typedef ReferenceCaller<std::size_t, void(const char*), Size_importString> SizeImportStringCaller;
-inline void Size_exportString( const std::size_t& self, const StringImportCallback& importer ){
+inline void Size_exportString( const std::size_t& self, const ImportExportCallback<const char *>::Import_t& importer ){
char buffer[16];
sprintf( buffer, "%u", Unsigned( self ) );
importer( buffer );
}
-typedef ConstReferenceCaller<std::size_t, void(const StringImportCallback&), Size_exportString> SizeExportStringCaller;
+typedef ConstReferenceCaller<std::size_t, void(const ImportExportCallback<const char *>::Import_t&), Size_exportString> SizeExportStringCaller;
inline void Float_importString( float& self, const char* string ){
if ( !string_parse_float( string, self ) ) {
}
}
typedef ReferenceCaller<float, void(const char*), Float_importString> FloatImportStringCaller;
-inline void Float_exportString( const float& self, const StringImportCallback& importer ){
+inline void Float_exportString( const float& self, const ImportExportCallback<const char *>::Import_t& importer ){
char buffer[16];
sprintf( buffer, "%g", self );
importer( buffer );
}
-typedef ConstReferenceCaller<float, void(const StringImportCallback&), Float_exportString> FloatExportStringCaller;
+typedef ConstReferenceCaller<float, void(const ImportExportCallback<const char *>::Import_t&), Float_exportString> FloatExportStringCaller;
inline void Vector3_importString( Vector3& self, const char* string ){
if ( !string_parse_vector3( string, self ) ) {
}
}
typedef ReferenceCaller<Vector3, void(const char*), Vector3_importString> Vector3ImportStringCaller;
-inline void Vector3_exportString( const Vector3& self, const StringImportCallback& importer ){
+inline void Vector3_exportString( const Vector3& self, const ImportExportCallback<const char *>::Import_t& importer ){
char buffer[64];
sprintf( buffer, "%g %g %g", self[0], self[1], self[2] );
importer( buffer );
}
-typedef ConstReferenceCaller<Vector3, void(const StringImportCallback&), Vector3_exportString> Vector3ExportStringCaller;
+typedef ConstReferenceCaller<Vector3, void(const ImportExportCallback<const char *>::Import_t&), Vector3_exportString> Vector3ExportStringCaller;
}
};
-inline void Bool_toString( const StringImportCallback& self, bool value ){
+inline void Bool_toString( const ImportExportCallback<const char *>::Import_t& self, bool value ){
Bool_exportString( value, self );
}
-typedef ConstReferenceCaller<StringImportCallback, void(bool), Bool_toString> BoolToString;
+typedef ConstReferenceCaller<ImportExportCallback<const char *>::Import_t, void(bool), Bool_toString> BoolToString;
template<typename Caller>
-inline StringImportCallback makeBoolStringImportCallback( const Caller& caller ){
- return StringImportCallback( caller.getEnvironment(), ImportConvert1<get_argument<StringImportCallback, 0>, Caller, BoolFromString>::thunk );
+inline ImportExportCallback<const char *>::Import_t makeBoolStringImportCallback( const Caller& caller ){
+ return ImportExportCallback<const char *>::Import_t( caller.getEnvironment(), ImportConvert1<get_argument<ImportExportCallback<const char *>::Import_t, 0>, Caller, BoolFromString>::thunk );
}
template<typename Caller>
-inline StringExportCallback makeBoolStringExportCallback( const Caller& caller ){
- return StringExportCallback( caller.getEnvironment(), ImportConvert1<get_argument<StringExportCallback, 0>, Caller, BoolToString>::thunk );
+inline ImportExportCallback<const char *>::Export_t makeBoolStringExportCallback( const Caller& caller ){
+ return ImportExportCallback<const char *>::Export_t( caller.getEnvironment(), ImportConvert1<get_argument<ImportExportCallback<const char *>::Export_t, 0>, Caller, BoolToString>::thunk );
}
}
};
-inline void Int_toString( const StringImportCallback& self, int value ){
+inline void Int_toString( const ImportExportCallback<const char *>::Import_t& self, int value ){
Int_exportString( value, self );
}
-typedef ConstReferenceCaller<StringImportCallback, void(int), Int_toString> IntToString;
+typedef ConstReferenceCaller<ImportExportCallback<const char *>::Import_t, void(int), Int_toString> IntToString;
template<typename Caller>
-inline StringImportCallback makeIntStringImportCallback( const Caller& caller ){
- return StringImportCallback( caller.getEnvironment(), ImportConvert1<get_argument<StringImportCallback, 0>, Caller, IntFromString>::thunk );
+inline ImportExportCallback<const char *>::Import_t makeIntStringImportCallback( const Caller& caller ){
+ return ImportExportCallback<const char *>::Import_t( caller.getEnvironment(), ImportConvert1<get_argument<ImportExportCallback<const char *>::Import_t, 0>, Caller, IntFromString>::thunk );
}
template<typename Caller>
-inline StringExportCallback makeIntStringExportCallback( const Caller& caller ){
- return StringExportCallback( caller.getEnvironment(), ImportConvert1<get_argument<StringExportCallback, 0>, Caller, IntToString>::thunk );
+inline ImportExportCallback<const char *>::Export_t makeIntStringExportCallback( const Caller& caller ){
+ return ImportExportCallback<const char *>::Export_t( caller.getEnvironment(), ImportConvert1<get_argument<ImportExportCallback<const char *>::Export_t, 0>, Caller, IntToString>::thunk );
}
}
};
-inline void Size_toString( const StringImportCallback& self, std::size_t value ){
+inline void Size_toString( const ImportExportCallback<const char *>::Import_t& self, std::size_t value ){
Size_exportString( value, self );
}
-typedef ConstReferenceCaller<StringImportCallback, void(std::size_t), Size_toString> SizeToString;
+typedef ConstReferenceCaller<ImportExportCallback<const char *>::Import_t, void(std::size_t), Size_toString> SizeToString;
template<typename Caller>
-inline StringImportCallback makeSizeStringImportCallback( const Caller& caller ){
- return StringImportCallback( caller.getEnvironment(), ImportConvert1<get_argument<StringImportCallback, 0>, Caller, SizeFromString>::thunk );
+inline ImportExportCallback<const char *>::Import_t makeSizeStringImportCallback( const Caller& caller ){
+ return ImportExportCallback<const char *>::Import_t( caller.getEnvironment(), ImportConvert1<get_argument<ImportExportCallback<const char *>::Import_t, 0>, Caller, SizeFromString>::thunk );
}
template<typename Caller>
-inline StringExportCallback makeSizeStringExportCallback( const Caller& caller ){
- return StringExportCallback( caller.getEnvironment(), ImportConvert1<get_argument<StringExportCallback, 0>, Caller, SizeToString>::thunk );
+inline ImportExportCallback<const char *>::Export_t makeSizeStringExportCallback( const Caller& caller ){
+ return ImportExportCallback<const char *>::Export_t( caller.getEnvironment(), ImportConvert1<get_argument<ImportExportCallback<const char *>::Export_t, 0>, Caller, SizeToString>::thunk );
}
#endif
#include "mainframe.h"
#include "preferences.h"
-LatchedBool g_useAlternativeTextureProjection( false, "Use alternative texture-projection (\"brush primitives\")" );
+LatchedValue<bool> g_useAlternativeTextureProjection( false, "Use alternative texture-projection (\"brush primitives\")" );
bool g_showAlternativeTextureProjectionOption = false;
bool g_brush_always_caulk;
Face::m_quantise = value ? quantiseInteger : quantiseFloating;
}
-void Face_exportSnapPlanes( const BoolImportCallback& importer ){
+void Face_exportSnapPlanes( const ImportExportCallback<bool>::Import_t& importer ){
importer( Face::m_quantise == quantiseInteger );
}
void Brush_constructPreferences( PreferencesPage& page ){
page.appendCheckBox(
"", "Snap planes to integer grid",
- makeCallbackF(Face_importSnapPlanes),
- makeCallbackF(Face_exportSnapPlanes)
+ {makeCallbackF(Face_importSnapPlanes),
+ makeCallbackF(Face_exportSnapPlanes)}
);
page.appendEntry(
"Default texture scale",
if ( g_showAlternativeTextureProjectionOption ) {
page.appendCheckBox(
"", "Use alternative texture-projection (\"brush primitives\")",
- LatchedBoolImportCaller( g_useAlternativeTextureProjection ),
- BoolExportCaller( g_useAlternativeTextureProjection.m_latched )
+ mkImportExportCallback(g_useAlternativeTextureProjection)
);
}
// d1223m
}
GlobalPreferenceSystem().registerPreference( "TextureLock", BoolImportStringCaller( g_brush_texturelock_enabled ), BoolExportStringCaller( g_brush_texturelock_enabled ) );
- GlobalPreferenceSystem().registerPreference( "BrushSnapPlanes", makeBoolStringImportCallback( FreeCaller<void(bool), Face_importSnapPlanes>() ), makeBoolStringExportCallback( FreeCaller<void(const BoolImportCallback&), Face_exportSnapPlanes>() ) );
+ GlobalPreferenceSystem().registerPreference( "BrushSnapPlanes", makeBoolStringImportCallback( FreeCaller<void(bool), Face_importSnapPlanes>() ), makeBoolStringExportCallback( FreeCaller<void(const ImportExportCallback<bool>::Import_t&), Face_exportSnapPlanes>() ) );
GlobalPreferenceSystem().registerPreference( "TexdefDefaultScale", FloatImportStringCaller( g_texdef_default_scale ), FloatExportStringCaller( g_texdef_default_scale ) );
GridStatus_getTextureLockEnabled = getTextureLockEnabled;
g_camwindow_globals_private.m_showStats ^= 1;
}
-void ShowStatsExport( const BoolImportCallback& importer ){
+void ShowStatsExport( const ImportExportCallback<bool>::Import_t& importer ){
importer( g_camwindow_globals_private.m_showStats );
}
-FreeCaller<void(const BoolImportCallback&), ShowStatsExport> g_show_stats_caller;
-BoolExportCallback g_show_stats_callback( g_show_stats_caller );
+FreeCaller<void(const ImportExportCallback<bool>::Import_t&), ShowStatsExport> g_show_stats_caller;
+ImportExportCallback<bool>::Export_t g_show_stats_callback( g_show_stats_caller );
ToggleItem g_show_stats( g_show_stats_callback );
void CamWnd::Cam_Draw(){
}
typedef FreeCaller<void(int), RenderModeImport> RenderModeImportCaller;
-void RenderModeExport( const IntImportCallback& importer ){
+void RenderModeExport( const ImportExportCallback<int>::Import_t& importer ){
switch ( CamWnd_GetMode() )
{
case cd_wire:
break;
}
}
-typedef FreeCaller<void(const IntImportCallback&), RenderModeExport> RenderModeExportCaller;
+typedef FreeCaller<void(const ImportExportCallback<int>::Import_t&), RenderModeExport> RenderModeExportCaller;
void Camera_constructPreferences( PreferencesPage& page ){
page.appendSlider( "Movement Speed", g_camwindow_globals_private.m_nMoveSpeed, TRUE, 0, 0, 100, MIN_CAM_SPEED, MAX_CAM_SPEED, 1, 10 );
page.appendCheckBox( "", "Invert mouse vertical axis", g_camwindow_globals_private.m_bCamInverseMouse );
page.appendCheckBox(
"", "Discrete movement",
- FreeCaller<void(bool), CamWnd_Move_Discrete_Import>(),
- BoolExportCaller( g_camwindow_globals_private.m_bCamDiscrete )
+ {FreeCaller<void(bool), CamWnd_Move_Discrete_Import>(),
+ BoolExportCaller( g_camwindow_globals_private.m_bCamDiscrete )}
);
page.appendCheckBox(
"", "Enable far-clip plane",
- FreeCaller<void(bool), Camera_SetFarClip>(),
- BoolExportCaller( g_camwindow_globals_private.m_bCubicClipping )
+ {FreeCaller<void(bool), Camera_SetFarClip>(),
+ BoolExportCaller( g_camwindow_globals_private.m_bCubicClipping )}
);
if ( g_pGameDescription->mGameType == "doom3" ) {
page.appendCombo(
"Render Mode",
STRING_ARRAY_RANGE( render_mode ),
- IntImportCallback( RenderModeImportCaller() ),
- IntExportCallback( RenderModeExportCaller() )
+ {ImportExportCallback<int>::Import_t( RenderModeImportCaller() ),
+ ImportExportCallback<int>::Export_t( RenderModeExportCaller() )}
);
}
else
page.appendCombo(
"Render Mode",
STRING_ARRAY_RANGE( render_mode ),
- IntImportCallback( RenderModeImportCaller() ),
- IntExportCallback( RenderModeExportCaller() )
+ {ImportExportCallback<int>::Import_t( RenderModeImportCaller() ),
+ ImportExportCallback<int>::Export_t( RenderModeExportCaller() )}
);
}
Toggles g_toggles;
-void GlobalToggles_insert( const char* name, const Callback<void()>& callback, const BoolExportCallback& exportCallback, const Accelerator& accelerator ){
+void GlobalToggles_insert( const char* name, const Callback<void()>& callback, const ImportExportCallback<bool>::Export_t& exportCallback, const Accelerator& accelerator ){
bool added = g_toggles.insert( Toggles::value_type( name, Toggle( callback, GlobalShortcuts_insert( name, accelerator ), exportCallback ) ) ).second;
ASSERT_MESSAGE( added, "toggle already registered: " << makeQuoted( name ) );
}
void GlobalCommands_insert( const char* name, const Callback<void()>& callback, const Accelerator& accelerator = accelerator_null() );
const Command& GlobalCommands_find( const char* name );
-void GlobalToggles_insert( const char* name, const Callback<void()>& callback, const BoolExportCallback& exportCallback, const Accelerator& accelerator = accelerator_null() );
+void GlobalToggles_insert( const char* name, const Callback<void()>& callback, const ImportExportCallback<bool>::Export_t& exportCallback, const Accelerator& accelerator = accelerator_null() );
const Toggle& GlobalToggles_find( const char* name );
void GlobalKeyEvents_insert( const char* name, const Accelerator& accelerator, const Callback<void()>& keyDown, const Callback<void()>& keyUp );
}
-
template<
- typename Type_,
- typename Other_,
- void( *Import ) ( Type_&, Other_ ),
- void( *Export ) ( Type_&, const Callback<void(Other_)>& )
- >
-class ImportExport
-{
+ typename Type_,
+ typename Other_ = Type_,
+ class T = impexp<Type_, Other_>
+>
+class ImportExport {
public:
-typedef Type_ Type;
-typedef Other_ Other;
+ using Type = Type_;
+ using Other = Other_;
-typedef ReferenceCaller<Type, void(Other), Import> ImportCaller;
-typedef ReferenceCaller<Type, void(const Callback<void(Other)>&), Export> ExportCaller;
+ using ImportCaller = ReferenceCaller<Type, void(Other), T::Import>;
+ using ExportCaller = ReferenceCaller<Type, void(const Callback<void(Other)> &), T::Export>;
};
-typedef ImportExport<bool, bool, BoolImport, BoolExport> BoolImportExport;
-typedef ImportExport<int, int, IntImport, IntExport> IntImportExport;
-typedef ImportExport<std::size_t, std::size_t, SizeImport, SizeExport> SizeImportExport;
-typedef ImportExport<float, float, FloatImport, FloatExport> FloatImportExport;
-typedef ImportExport<CopiedString, const char*, StringImport, StringExport> StringImportExport;
+using BoolImportExport = ImportExport<bool>;
+struct BoolToggle {
+ static void Import(GtkToggleButton &widget, bool value) {
+ gtk_toggle_button_set_active(&widget, value);
+ }
-void BoolToggleImport( GtkToggleButton& widget, bool value ){
- gtk_toggle_button_set_active( &widget, value );
-}
-void BoolToggleExport( GtkToggleButton& widget, const BoolImportCallback& importCallback ){
- importCallback( gtk_toggle_button_get_active( &widget ) != FALSE );
-}
-typedef ImportExport<GtkToggleButton, bool, BoolToggleImport, BoolToggleExport> BoolToggleImportExport;
+ static void Export(GtkToggleButton &widget, const ImportExportCallback<bool>::Import_t &importCallback) {
+ importCallback(gtk_toggle_button_get_active(&widget) != FALSE);
+ }
+};
+using BoolToggleImportExport = ImportExport<GtkToggleButton, bool, BoolToggle>;
-void IntRadioImport( GtkRadioButton& widget, int index ){
- radio_button_set_active( ui::RadioButton(&widget), index );
-}
-void IntRadioExport( GtkRadioButton& widget, const IntImportCallback& importCallback ){
- importCallback( radio_button_get_active( ui::RadioButton(&widget) ) );
-}
-typedef ImportExport<GtkRadioButton, int, IntRadioImport, IntRadioExport> IntRadioImportExport;
+using IntImportExport = ImportExport<int>;
-void TextEntryImport( GtkEntry& widget, const char* text ){
- ui::Entry(&widget).text(text);
-}
-void TextEntryExport( GtkEntry& widget, const StringImportCallback& importCallback ){
- importCallback( gtk_entry_get_text( &widget ) );
-}
-typedef ImportExport<GtkEntry, const char*, TextEntryImport, TextEntryExport> TextEntryImportExport;
+struct IntEntry {
+ static void Import(GtkEntry &widget, int value) {
+ entry_set_int(ui::Entry(&widget), value);
+ }
+ static void Export(GtkEntry &widget, const ImportExportCallback<int>::Import_t &importCallback) {
+ importCallback(atoi(gtk_entry_get_text(&widget)));
+ }
+};
-void IntEntryImport( GtkEntry& widget, int value ){
- entry_set_int( ui::Entry(&widget), value );
-}
-void IntEntryExport( GtkEntry& widget, const IntImportCallback& importCallback ){
- importCallback( atoi( gtk_entry_get_text( &widget ) ) );
-}
-typedef ImportExport<GtkEntry, int, IntEntryImport, IntEntryExport> IntEntryImportExport;
+using IntEntryImportExport = ImportExport<GtkEntry, int, IntEntry>;
+struct IntRadio {
+ static void Import(GtkRadioButton &widget, int index) {
+ radio_button_set_active(ui::RadioButton(&widget), index);
+ }
-void SizeEntryImport( GtkEntry& widget, std::size_t value ){
- entry_set_int( ui::Entry(&widget), int(value) );
-}
-void SizeEntryExport( GtkEntry& widget, const SizeImportCallback& importCallback ){
- int value = atoi( gtk_entry_get_text( &widget ) );
- if ( value < 0 ) {
- value = 0;
+ static void Export(GtkRadioButton &widget, const ImportExportCallback<int>::Import_t &importCallback) {
+ importCallback(radio_button_get_active(ui::RadioButton(&widget)));
}
- importCallback( value );
-}
-typedef ImportExport<GtkEntry, std::size_t, SizeEntryImport, SizeEntryExport> SizeEntryImportExport;
+};
+using IntRadioImportExport = ImportExport<GtkRadioButton, int, IntRadio>;
-void FloatEntryImport( GtkEntry& widget, float value ){
- entry_set_float( ui::Entry(&widget), value );
-}
-void FloatEntryExport( GtkEntry& widget, const FloatImportCallback& importCallback ){
- importCallback( (float)atof( gtk_entry_get_text( &widget ) ) );
-}
-typedef ImportExport<GtkEntry, float, FloatEntryImport, FloatEntryExport> FloatEntryImportExport;
+struct IntCombo {
+ static void Import(GtkComboBox &widget, int value) {
+ gtk_combo_box_set_active(&widget, value);
+ }
+ static void Export(GtkComboBox &widget, const ImportExportCallback<int>::Import_t &importCallback) {
+ importCallback(gtk_combo_box_get_active(&widget));
+ }
+};
-void FloatSpinnerImport( GtkSpinButton& widget, float value ){
- gtk_spin_button_set_value( &widget, value );
-}
-void FloatSpinnerExport( GtkSpinButton& widget, const FloatImportCallback& importCallback ){
- importCallback( float(gtk_spin_button_get_value( &widget ) ) );
-}
-typedef ImportExport<GtkSpinButton, float, FloatSpinnerImport, FloatSpinnerExport> FloatSpinnerImportExport;
+using IntComboImportExport = ImportExport<GtkComboBox, int, IntCombo>;
+struct IntAdjustment {
+ static void Import(GtkAdjustment &widget, int value) {
+ gtk_adjustment_set_value(&widget, value);
+ }
-void IntSpinnerImport( GtkSpinButton& widget, int value ){
- gtk_spin_button_set_value( &widget, value );
-}
-void IntSpinnerExport( GtkSpinButton& widget, const IntImportCallback& importCallback ){
- importCallback( gtk_spin_button_get_value_as_int( &widget ) );
-}
-typedef ImportExport<GtkSpinButton, int, IntSpinnerImport, IntSpinnerExport> IntSpinnerImportExport;
+ static void Export(GtkAdjustment &widget, const ImportExportCallback<int>::Import_t &importCallback) {
+ importCallback((int) gtk_adjustment_get_value(&widget));
+ }
+};
+using IntAdjustmentImportExport = ImportExport<GtkAdjustment, int, IntAdjustment>;
-void IntAdjustmentImport( GtkAdjustment& widget, int value ){
- gtk_adjustment_set_value( &widget, value );
-}
-void IntAdjustmentExport( GtkAdjustment& widget, const IntImportCallback& importCallback ){
- importCallback( (int)gtk_adjustment_get_value( &widget ) );
-}
-typedef ImportExport<GtkAdjustment, int, IntAdjustmentImport, IntAdjustmentExport> IntAdjustmentImportExport;
+struct IntSpinner {
+ static void Import(GtkSpinButton &widget, int value) {
+ gtk_spin_button_set_value(&widget, value);
+ }
+ static void Export(GtkSpinButton &widget, const ImportExportCallback<int>::Import_t &importCallback) {
+ importCallback(gtk_spin_button_get_value_as_int(&widget));
+ }
+};
-void IntComboImport( GtkComboBox& widget, int value ){
- gtk_combo_box_set_active( &widget, value );
-}
-void IntComboExport( GtkComboBox& widget, const IntImportCallback& importCallback ){
- importCallback( gtk_combo_box_get_active( &widget ) );
-}
-typedef ImportExport<GtkComboBox, int, IntComboImport, IntComboExport> IntComboImportExport;
+using IntSpinnerImportExport = ImportExport<GtkSpinButton, int, IntSpinner>;
+using StringImportExport = ImportExport<CopiedString, const char *>;
-template<typename FirstArgument>
-class CallbackDialogData : public DLG_DATA
-{
-public:
-typedef Callback<void(FirstArgument)> ImportCallback;
-typedef Callback<void(const ImportCallback&)> ExportCallback;
+struct TextEntry {
+ static void Import(GtkEntry &widget, const char *text) {
+ ui::Entry(&widget).text(text);
+ }
+
+ static void Export(GtkEntry &widget, const ImportExportCallback<const char *>::Import_t &importCallback) {
+ importCallback(gtk_entry_get_text(&widget));
+ }
+};
+
+using TextEntryImportExport = ImportExport<GtkEntry, const char *, TextEntry>;
+
+using SizeImportExport = ImportExport<std::size_t>;
+
+struct SizeEntry {
+ static void Import(GtkEntry &widget, std::size_t value) {
+ entry_set_int(ui::Entry(&widget), int(value));
+ }
+
+ static void Export(GtkEntry &widget, const ImportExportCallback<std::size_t>::Import_t &importCallback) {
+ int value = atoi(gtk_entry_get_text(&widget));
+ if (value < 0) {
+ value = 0;
+ }
+ importCallback(value);
+ }
+};
+
+using SizeEntryImportExport = ImportExport<GtkEntry, std::size_t, SizeEntry>;
-private:
-ImportCallback m_importWidget;
-ExportCallback m_exportWidget;
-ImportCallback m_importViewer;
-ExportCallback m_exportViewer;
+using FloatImportExport = ImportExport<float>;
+
+struct FloatEntry {
+ static void Import(GtkEntry &widget, float value) {
+ entry_set_float(ui::Entry(&widget), value);
+ }
+
+ static void Export(GtkEntry &widget, const ImportExportCallback<float>::Import_t &importCallback) {
+ importCallback((float) atof(gtk_entry_get_text(&widget)));
+ }
+};
+
+using FloatEntryImportExport = ImportExport<GtkEntry, float, FloatEntry>;
+
+struct FloatSpinner {
+ static void Import(GtkSpinButton &widget, float value) {
+ gtk_spin_button_set_value(&widget, value);
+ }
+
+ static void Export(GtkSpinButton &widget, const ImportExportCallback<float>::Import_t &importCallback) {
+ importCallback(float(gtk_spin_button_get_value(&widget)));
+ }
+};
+
+using FloatSpinnerImportExport = ImportExport<GtkSpinButton, float, FloatSpinner>;
+
+
+
+template<typename T>
+class CallbackDialogData : public DLG_DATA {
+ ImportExportCallback<T> m_cbWidget;
+ ImportExportCallback<T> m_cbViewer;
public:
-CallbackDialogData( const ImportCallback& importWidget, const ExportCallback& exportWidget, const ImportCallback& importViewer, const ExportCallback& exportViewer )
- : m_importWidget( importWidget ), m_exportWidget( exportWidget ), m_importViewer( importViewer ), m_exportViewer( exportViewer ){
-}
-void release(){
- delete this;
-}
-void importData() const {
- m_exportViewer( m_importWidget );
-}
-void exportData() const {
- m_exportWidget( m_importViewer );
-}
+ CallbackDialogData(const ImportExportCallback<T> &cbWidget, const ImportExportCallback<T> &cbViewer)
+ : m_cbWidget(cbWidget), m_cbViewer(cbViewer) {
+ }
+
+ void release() {
+ delete this;
+ }
+
+ void importData() const {
+ m_cbViewer.Export(m_cbWidget.Import);
+ }
+
+ void exportData() const {
+ m_cbWidget.Export(m_cbViewer.Import);
+ }
};
template<typename Widget, typename Viewer>
-class AddData
-{
-DialogDataList& m_data;
-public:
-AddData( DialogDataList& data ) : m_data( data ){
-}
-void apply( typename Widget::Type& widget, typename Viewer::Type& viewer ) const {
- m_data.push_back(
- new CallbackDialogData<typename Widget::Other>(
- typename Widget::ImportCaller( widget ),
- typename Widget::ExportCaller( widget ),
- typename Viewer::ImportCaller( viewer ),
- typename Viewer::ExportCaller( viewer )
+void AddData(DialogDataList &data, typename Widget::Type &widget, typename Viewer::Type &viewer) {
+ data.push_back(
+ new CallbackDialogData<typename Widget::Other>(
+ {typename Widget::ImportCaller(widget),
+ typename Widget::ExportCaller(widget)},
+ {typename Viewer::ImportCaller(viewer),
+ typename Viewer::ExportCaller(viewer)}
)
- );
+ );
}
-};
template<typename Widget>
-class AddCustomData
-{
-DialogDataList& m_data;
-public:
-AddCustomData( DialogDataList& data ) : m_data( data ){
-}
-void apply(
- typename Widget::Type& widget,
- const Callback<void(typename Widget::Other)>& importViewer,
- const Callback<void(const Callback<void(typename Widget::Other)>&)>& exportViewer
- ) const {
- m_data.push_back(
- new CallbackDialogData<typename Widget::Other>(
- typename Widget::ImportCaller( widget ),
- typename Widget::ExportCaller( widget ),
- importViewer,
- exportViewer
+void AddCustomData(
+ DialogDataList &data,
+ typename Widget::Type &widget,
+ ImportExportCallback<typename Widget::Other> const &cbViewer
+) {
+ data.push_back(
+ new CallbackDialogData<typename Widget::Other>(
+ {typename Widget::ImportCaller(widget),
+ typename Widget::ExportCaller(widget)},
+ cbViewer
)
- );
+ );
}
-};
// =============================================================================
// Dialog class
}
-void Dialog::AddBoolToggleData( GtkToggleButton& widget, const BoolImportCallback& importViewer, const BoolExportCallback& exportViewer ){
- AddCustomData<BoolToggleImportExport>( m_data ).apply( widget, importViewer, exportViewer );
+void Dialog::AddBoolToggleData( GtkToggleButton& widget, ImportExportCallback<bool> const &cb ){
+ AddCustomData<BoolToggleImportExport>( m_data, widget, cb );
}
-void Dialog::AddIntRadioData( GtkRadioButton& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
- AddCustomData<IntRadioImportExport>( m_data ).apply( widget, importViewer, exportViewer );
+void Dialog::AddIntRadioData( GtkRadioButton& widget, ImportExportCallback<int> const &cb ){
+ AddCustomData<IntRadioImportExport>( m_data, widget, cb );
}
-void Dialog::AddTextEntryData( GtkEntry& widget, const StringImportCallback& importViewer, const StringExportCallback& exportViewer ){
- AddCustomData<TextEntryImportExport>( m_data ).apply( widget, importViewer, exportViewer );
+void Dialog::AddTextEntryData( GtkEntry& widget, ImportExportCallback<const char *> const &cb ){
+ AddCustomData<TextEntryImportExport>( m_data, widget, cb );
}
-void Dialog::AddIntEntryData( GtkEntry& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
- AddCustomData<IntEntryImportExport>( m_data ).apply( widget, importViewer, exportViewer );
+void Dialog::AddIntEntryData( GtkEntry& widget, ImportExportCallback<int> const &cb ){
+ AddCustomData<IntEntryImportExport>( m_data, widget, cb );
}
-void Dialog::AddSizeEntryData( GtkEntry& widget, const SizeImportCallback& importViewer, const SizeExportCallback& exportViewer ){
- AddCustomData<SizeEntryImportExport>( m_data ).apply( widget, importViewer, exportViewer );
+void Dialog::AddSizeEntryData( GtkEntry& widget, ImportExportCallback<std::size_t> const &cb ){
+ AddCustomData<SizeEntryImportExport>( m_data, widget, cb );
}
-void Dialog::AddFloatEntryData( GtkEntry& widget, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){
- AddCustomData<FloatEntryImportExport>( m_data ).apply( widget, importViewer, exportViewer );
+void Dialog::AddFloatEntryData( GtkEntry& widget, ImportExportCallback<float> const &cb ){
+ AddCustomData<FloatEntryImportExport>( m_data, widget, cb );
}
-void Dialog::AddFloatSpinnerData( GtkSpinButton& widget, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){
- AddCustomData<FloatSpinnerImportExport>( m_data ).apply( widget, importViewer, exportViewer );
+void Dialog::AddFloatSpinnerData( GtkSpinButton& widget, ImportExportCallback<float> const &cb ){
+ AddCustomData<FloatSpinnerImportExport>( m_data, widget, cb );
}
-void Dialog::AddIntSpinnerData( GtkSpinButton& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
- AddCustomData<IntSpinnerImportExport>( m_data ).apply( widget, importViewer, exportViewer );
+void Dialog::AddIntSpinnerData( GtkSpinButton& widget, ImportExportCallback<int> const &cb ){
+ AddCustomData<IntSpinnerImportExport>( m_data, widget, cb );
}
-void Dialog::AddIntAdjustmentData( GtkAdjustment& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
- AddCustomData<IntAdjustmentImportExport>( m_data ).apply( widget, importViewer, exportViewer );
+void Dialog::AddIntAdjustmentData( GtkAdjustment& widget, ImportExportCallback<int> const &cb ){
+ AddCustomData<IntAdjustmentImportExport>( m_data, widget, cb );
}
-void Dialog::AddIntComboData( GtkComboBox& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
- AddCustomData<IntComboImportExport>( m_data ).apply( widget, importViewer, exportViewer );
+void Dialog::AddIntComboData( GtkComboBox& widget, ImportExportCallback<int> const &cb ){
+ AddCustomData<IntComboImportExport>( m_data, widget, cb );
}
void Dialog::AddDialogData( GtkToggleButton& widget, bool& data ){
- AddData<BoolToggleImportExport, BoolImportExport>( m_data ).apply( widget, data );
+ AddData<BoolToggleImportExport, BoolImportExport>( m_data, widget, data );
}
void Dialog::AddDialogData( GtkRadioButton& widget, int& data ){
- AddData<IntRadioImportExport, IntImportExport>( m_data ).apply( widget, data );
+ AddData<IntRadioImportExport, IntImportExport>( m_data, widget, data );
}
void Dialog::AddDialogData( GtkEntry& widget, CopiedString& data ){
- AddData<TextEntryImportExport, StringImportExport>( m_data ).apply( widget, data );
+ AddData<TextEntryImportExport, StringImportExport>( m_data, widget, data );
}
void Dialog::AddDialogData( GtkEntry& widget, int& data ){
- AddData<IntEntryImportExport, IntImportExport>( m_data ).apply( widget, data );
+ AddData<IntEntryImportExport, IntImportExport>( m_data, widget, data );
}
void Dialog::AddDialogData( GtkEntry& widget, std::size_t& data ){
- AddData<SizeEntryImportExport, SizeImportExport>( m_data ).apply( widget, data );
+ AddData<SizeEntryImportExport, SizeImportExport>( m_data, widget, data );
}
void Dialog::AddDialogData( GtkEntry& widget, float& data ){
- AddData<FloatEntryImportExport, FloatImportExport>( m_data ).apply( widget, data );
+ AddData<FloatEntryImportExport, FloatImportExport>( m_data, widget, data );
}
void Dialog::AddDialogData( GtkSpinButton& widget, float& data ){
- AddData<FloatSpinnerImportExport, FloatImportExport>( m_data ).apply( widget, data );
+ AddData<FloatSpinnerImportExport, FloatImportExport>( m_data, widget, data );
}
void Dialog::AddDialogData( GtkSpinButton& widget, int& data ){
- AddData<IntSpinnerImportExport, IntImportExport>( m_data ).apply( widget, data );
+ AddData<IntSpinnerImportExport, IntImportExport>( m_data, widget, data );
}
void Dialog::AddDialogData( GtkAdjustment& widget, int& data ){
- AddData<IntAdjustmentImportExport, IntImportExport>( m_data ).apply( widget, data );
+ AddData<IntAdjustmentImportExport, IntImportExport>( m_data, widget, data );
}
void Dialog::AddDialogData( GtkComboBox& widget, int& data ){
- AddData<IntComboImportExport, IntImportExport>( m_data ).apply( widget, data );
+ AddData<IntComboImportExport, IntImportExport>( m_data, widget, data );
}
void Dialog::exportData(){
}
-ui::CheckButton Dialog::addCheckBox( ui::VBox vbox, const char* name, const char* flag, const BoolImportCallback& importViewer, const BoolExportCallback& exportViewer ){
+ui::CheckButton Dialog::addCheckBox( ui::VBox vbox, const char* name, const char* flag, ImportExportCallback<bool> const &cb ){
auto check = ui::CheckButton( flag );
check.show();
- AddBoolToggleData( *GTK_TOGGLE_BUTTON( check ), importViewer, exportViewer );
+ AddBoolToggleData( *GTK_TOGGLE_BUTTON( check ), cb );
DialogVBox_packRow( vbox, ui::Widget(DialogRow_new( name, check ) ));
return check;
}
ui::CheckButton Dialog::addCheckBox( ui::VBox vbox, const char* name, const char* flag, bool& data ){
- return addCheckBox( vbox, name, flag, BoolImportCaller( data ), BoolExportCaller( data ) );
+ return addCheckBox(vbox, name, flag, mkImportExportCallback(data));
}
-void Dialog::addCombo( ui::VBox vbox, const char* name, StringArrayRange values, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
+void Dialog::addCombo( ui::VBox vbox, const char* name, StringArrayRange values, ImportExportCallback<int> const &cb ){
auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 );
alignment.show();
{
gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT( combo ), *i );
}
- AddIntComboData( *GTK_COMBO_BOX( combo ), importViewer, exportViewer );
+ AddIntComboData( *GTK_COMBO_BOX( combo ), cb );
combo.show();
alignment.add(combo);
}
void Dialog::addCombo( ui::VBox vbox, const char* name, int& data, StringArrayRange values ){
- addCombo( vbox, name, values, IntImportCaller( data ), IntExportCaller( data ) );
+ addCombo(vbox, name, values, mkImportExportCallback(data));
}
void Dialog::addSlider( ui::VBox vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ){
// adjustment
auto adj = ui::Adjustment( value, lower, upper, step_increment, page_increment, 0 );
- AddIntAdjustmentData( *GTK_ADJUSTMENT(adj), IntImportCaller( data ), IntExportCaller( data ) );
+ AddIntAdjustmentData(*GTK_ADJUSTMENT(adj), mkImportExportCallback(data));
// scale
auto alignment = ui::Alignment( 0.0, 0.5, 1.0, 0.0 );
DialogVBox_packRow( vbox, row );
}
-void Dialog::addRadio( ui::VBox vbox, const char* name, StringArrayRange names, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
+void Dialog::addRadio( ui::VBox vbox, const char* name, StringArrayRange names, ImportExportCallback<int> const &cb ){
auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 );
alignment.show();;
{
RadioHBox radioBox = RadioHBox_new( names );
alignment.add(radioBox.m_hbox);
- AddIntRadioData( *GTK_RADIO_BUTTON( radioBox.m_radio ), importViewer, exportViewer );
+ AddIntRadioData( *GTK_RADIO_BUTTON( radioBox.m_radio ), cb );
}
auto row = DialogRow_new( name, alignment );
}
void Dialog::addRadio( ui::VBox vbox, const char* name, int& data, StringArrayRange names ){
- addRadio( vbox, name, names, IntImportCaller( data ), IntExportCaller( data ) );
+ addRadio(vbox, name, names, mkImportExportCallback(data));
}
-void Dialog::addRadioIcons( ui::VBox vbox, const char* name, StringArrayRange icons, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
+void Dialog::addRadioIcons( ui::VBox vbox, const char* name, StringArrayRange icons, ImportExportCallback<int> const &cb ){
auto table = ui::Table(2, icons.last - icons.first, FALSE);
table.show();
group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radio ) );
}
- AddIntRadioData( *GTK_RADIO_BUTTON( radio ), importViewer, exportViewer );
+ AddIntRadioData( *GTK_RADIO_BUTTON( radio ), cb );
DialogVBox_packRow( vbox, DialogRow_new( name, table ) );
}
void Dialog::addRadioIcons( ui::VBox vbox, const char* name, int& data, StringArrayRange icons ){
- addRadioIcons( vbox, name, icons, IntImportCaller( data ), IntExportCaller( data ) );
+ addRadioIcons(vbox, name, icons, mkImportExportCallback(data));
}
-ui::Widget Dialog::addIntEntry( ui::VBox vbox, const char* name, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
+ui::Widget Dialog::addIntEntry( ui::VBox vbox, const char* name, ImportExportCallback<int> const &cb ){
DialogEntryRow row( DialogEntryRow_new( name ) );
- AddIntEntryData( *GTK_ENTRY(row.m_entry), importViewer, exportViewer );
+ AddIntEntryData( *GTK_ENTRY(row.m_entry), cb );
DialogVBox_packRow( vbox, row.m_row );
return row.m_row;
}
-ui::Widget Dialog::addSizeEntry( ui::VBox vbox, const char* name, const SizeImportCallback& importViewer, const SizeExportCallback& exportViewer ){
+ui::Widget Dialog::addSizeEntry( ui::VBox vbox, const char* name, ImportExportCallback<std::size_t> const &cb ){
DialogEntryRow row( DialogEntryRow_new( name ) );
- AddSizeEntryData( *GTK_ENTRY(row.m_entry), importViewer, exportViewer );
+ AddSizeEntryData( *GTK_ENTRY(row.m_entry), cb );
DialogVBox_packRow( vbox, row.m_row );
return row.m_row;
}
-ui::Widget Dialog::addFloatEntry( ui::VBox vbox, const char* name, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){
+ui::Widget Dialog::addFloatEntry( ui::VBox vbox, const char* name, ImportExportCallback<float> const &cb ){
DialogEntryRow row( DialogEntryRow_new( name ) );
- AddFloatEntryData( *GTK_ENTRY(row.m_entry), importViewer, exportViewer );
+ AddFloatEntryData( *GTK_ENTRY(row.m_entry), cb );
DialogVBox_packRow( vbox, row.m_row );
return row.m_row;
}
-ui::Widget Dialog::addPathEntry( ui::VBox vbox, const char* name, bool browse_directory, const StringImportCallback& importViewer, const StringExportCallback& exportViewer ){
+ui::Widget Dialog::addPathEntry( ui::VBox vbox, const char* name, bool browse_directory, ImportExportCallback<const char *> const &cb ){
PathEntry pathEntry = PathEntry_new();
pathEntry.m_button.connect( "clicked", G_CALLBACK( browse_directory ? button_clicked_entry_browse_directory : button_clicked_entry_browse_file ), pathEntry.m_entry );
- AddTextEntryData( *GTK_ENTRY(pathEntry.m_entry), importViewer, exportViewer );
+ AddTextEntryData( *GTK_ENTRY(pathEntry.m_entry), cb );
auto row = DialogRow_new( name, ui::Widget(pathEntry.m_frame ) );
DialogVBox_packRow( vbox, row );
- return ui::Widget(row );
+ return row;
}
ui::Widget Dialog::addPathEntry( ui::VBox vbox, const char* name, CopiedString& data, bool browse_directory ){
- return addPathEntry( vbox, name, browse_directory, StringImportCallback( StringImportCaller( data ) ), StringExportCallback( StringExportCaller( data ) ) );
+ return addPathEntry(vbox, name, browse_directory, mkImportExportCallback<CopiedString, const char *>(data));
}
-ui::SpinButton Dialog::addSpinner( ui::VBox vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
+ui::SpinButton Dialog::addSpinner( ui::VBox vbox, const char* name, double value, double lower, double upper, ImportExportCallback<int> const &cb ){
DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 1 ) );
- AddIntSpinnerData( *GTK_SPIN_BUTTON(row.m_spin), importViewer, exportViewer );
+ AddIntSpinnerData( *GTK_SPIN_BUTTON(row.m_spin), cb );
DialogVBox_packRow( vbox, row.m_row );
- return ui::SpinButton(row.m_spin);
+ return row.m_spin;
}
ui::SpinButton Dialog::addSpinner( ui::VBox vbox, const char* name, int& data, double value, double lower, double upper ){
- return addSpinner( vbox, name, value, lower, upper, IntImportCallback( IntImportCaller( data ) ), IntExportCallback( IntExportCaller( data ) ) );
+ return addSpinner(vbox, name, value, lower, upper, mkImportExportCallback(data));
}
-ui::SpinButton Dialog::addSpinner( ui::VBox vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){
+ui::SpinButton Dialog::addSpinner( ui::VBox vbox, const char* name, double value, double lower, double upper, ImportExportCallback<float> const &cb ){
DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 10 ) );
- AddFloatSpinnerData( *GTK_SPIN_BUTTON(row.m_spin), importViewer, exportViewer );
+ AddFloatSpinnerData( *GTK_SPIN_BUTTON(row.m_spin), cb );
DialogVBox_packRow( vbox, row.m_row );
- return ui::SpinButton(row.m_spin);
+ return row.m_spin;
}
#include "generic/callback.h"
#include "string/string.h"
-inline void BoolImport( bool& self, bool value ){
- self = value;
-}
-typedef ReferenceCaller<bool, void(bool), BoolImport> BoolImportCaller;
+template<class Self, class T = Self>
+struct impexp {
+ static void Import(Self &self, T value) {
+ self = value;
+ }
+
+ static void Export(Self &self, const Callback<void(T)> &importCallback) {
+ importCallback(self);
+ }
+};
-inline void BoolExport( bool& self, const BoolImportCallback& importCallback ){
- importCallback( self );
+template<class Self, class T = Self>
+ImportExportCallback<T> mkImportExportCallback(Self &self) {
+ return {
+ ReferenceCaller<Self, void(T), impexp<Self, T>::Import>(self),
+ ReferenceCaller<Self, void(const Callback<void(T)> &), impexp<Self, T>::Export>(self)
+ };
}
-typedef ReferenceCaller<bool, void(const BoolImportCallback&), BoolExport> BoolExportCaller;
+#define BoolImport impexp<bool>::Import
+#define BoolExport impexp<bool>::Export
-inline void IntImport( int& self, int value ){
- self = value;
-}
-typedef ReferenceCaller<int, void(int), IntImport> IntImportCaller;
+typedef ReferenceCaller<bool, void(const Callback<void(bool)> &), BoolExport> BoolExportCaller;
-inline void IntExport( int& self, const IntImportCallback& importCallback ){
- importCallback( self );
-}
-typedef ReferenceCaller<int, void(const IntImportCallback&), IntExport> IntExportCaller;
+#define IntImport impexp<int>::Import
+#define IntExport impexp<int>::Export
+typedef ReferenceCaller<int, void(const Callback<void(int)> &), IntExport> IntExportCaller;
-inline void SizeImport( std::size_t& self, std::size_t value ){
- self = value;
-}
-typedef ReferenceCaller<std::size_t, void(std::size_t), SizeImport> SizeImportCaller;
+#define SizeImport impexp<std::size_t>::Import
+#define SizeExport impexp<std::size_t>::Export
-inline void SizeExport( std::size_t& self, const SizeImportCallback& importCallback ){
- importCallback( self );
-}
-typedef ReferenceCaller<std::size_t, void(const SizeImportCallback&), SizeExport> SizeExportCaller;
+#define FloatImport impexp<float>::Import
+#define FloatExport impexp<float>::Export
-inline void FloatImport( float& self, float value ){
- self = value;
-}
-typedef ReferenceCaller<float, void(float), FloatImport> FloatImportCaller;
+typedef ReferenceCaller<float, void(const Callback<void(float)> &), FloatExport> FloatExportCaller;
-inline void FloatExport( float& self, const FloatImportCallback& importCallback ){
- importCallback( self );
-}
-typedef ReferenceCaller<float, void(const FloatImportCallback&), FloatExport> FloatExportCaller;
+#define StringImport impexp<CopiedString, const char *>::Import
+#define StringExport impexp<CopiedString, const char *>::Export
+template<>
+struct impexp<CopiedString, const char *> {
+ static void Import(CopiedString &self, const char *value) {
+ self = value;
+ }
-inline void StringImport( CopiedString& self, const char* value ){
- self = value;
-}
-typedef ReferenceCaller<CopiedString, void(const char*), StringImport> StringImportCaller;
-inline void StringExport( CopiedString& self, const StringImportCallback& importCallback ){
- importCallback( self.c_str() );
-}
-typedef ReferenceCaller<CopiedString, void(const StringImportCallback&), StringExport> StringExportCaller;
+ static void Export(CopiedString &self, const Callback<void(const char *)> &importCallback) {
+ importCallback(self.c_str());
+ }
+};
+
+typedef ReferenceCaller<CopiedString, void(const Callback<void(const char *)> &), StringExport> StringExportCaller;
struct DLG_DATA
return m_window;
}
-ui::CheckButton addCheckBox( ui::VBox vbox, const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback );
+ ui::CheckButton addCheckBox(ui::VBox vbox, const char *name, const char *flag, ImportExportCallback<bool> const &cb);
ui::CheckButton addCheckBox( ui::VBox vbox, const char* name, const char* flag, bool& data );
-void addCombo( ui::VBox vbox, const char* name, StringArrayRange values, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
+
+ void addCombo(ui::VBox vbox, const char *name, StringArrayRange values, ImportExportCallback<int> const &cb);
void addCombo( ui::VBox vbox, const char* name, int& data, StringArrayRange values );
void addSlider( ui::VBox vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment );
-void addRadio( ui::VBox vbox, const char* name, StringArrayRange names, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
+
+ void addRadio(ui::VBox vbox, const char *name, StringArrayRange names, ImportExportCallback<int> const &cb);
void addRadio( ui::VBox vbox, const char* name, int& data, StringArrayRange names );
-void addRadioIcons( ui::VBox vbox, const char* name, StringArrayRange icons, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
+
+ void addRadioIcons(ui::VBox vbox, const char *name, StringArrayRange icons, ImportExportCallback<int> const &cb);
void addRadioIcons( ui::VBox vbox, const char* name, int& data, StringArrayRange icons );
-ui::Widget addIntEntry( ui::VBox vbox, const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
+
+ ui::Widget addIntEntry(ui::VBox vbox, const char *name, ImportExportCallback<int> const &cb);
ui::Widget addEntry( ui::VBox vbox, const char* name, int& data ){
- return addIntEntry( vbox, name, IntImportCaller( data ), IntExportCaller( data ) );
+ return addIntEntry(vbox, name, mkImportExportCallback(data));
}
-ui::Widget addSizeEntry( ui::VBox vbox, const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback );
+
+ ui::Widget addSizeEntry(ui::VBox vbox, const char *name, ImportExportCallback<std::size_t> const &cb);
ui::Widget addEntry( ui::VBox vbox, const char* name, std::size_t& data ){
- return addSizeEntry( vbox, name, SizeImportCaller( data ), SizeExportCaller( data ) );
+ return addSizeEntry(vbox, name, mkImportExportCallback(data));
}
-ui::Widget addFloatEntry( ui::VBox vbox, const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback );
+
+ ui::Widget addFloatEntry(ui::VBox vbox, const char *name, ImportExportCallback<float> const &cb);
ui::Widget addEntry( ui::VBox vbox, const char* name, float& data ){
- return addFloatEntry( vbox, name, FloatImportCaller( data ), FloatExportCaller( data ) );
+ return addFloatEntry(vbox, name, mkImportExportCallback(data));
}
-ui::Widget addPathEntry( ui::VBox vbox, const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback );
+
+ ui::Widget
+ addPathEntry(ui::VBox vbox, const char *name, bool browse_directory, ImportExportCallback<const char *> const &cb);
ui::Widget addPathEntry( ui::VBox vbox, const char* name, CopiedString& data, bool directory );
ui::SpinButton addSpinner( ui::VBox vbox, const char* name, int& data, double value, double lower, double upper );
-ui::SpinButton addSpinner( ui::VBox vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
-ui::SpinButton addSpinner( ui::VBox vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback );
+
+ ui::SpinButton
+ addSpinner(ui::VBox vbox, const char *name, double value, double lower, double upper, ImportExportCallback<int> const &cb);
+
+ ui::SpinButton addSpinner(ui::VBox vbox, const char *name, double value, double lower, double upper,
+ ImportExportCallback<float> const &cb);
protected:
-void AddBoolToggleData( struct _GtkToggleButton& object, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback );
-void AddIntRadioData( struct _GtkRadioButton& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
-void AddTextEntryData( struct _GtkEntry& object, const StringImportCallback& importCallback, const StringExportCallback& exportCallback );
-void AddIntEntryData( struct _GtkEntry& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
-void AddSizeEntryData( struct _GtkEntry& object, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback );
-void AddFloatEntryData( struct _GtkEntry& object, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback );
-void AddFloatSpinnerData( struct _GtkSpinButton& object, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback );
-void AddIntSpinnerData( struct _GtkSpinButton& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
-void AddIntAdjustmentData( struct _GtkAdjustment& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
-void AddIntComboData( struct _GtkComboBox& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
+ void AddBoolToggleData(struct _GtkToggleButton &object, ImportExportCallback<bool> const &cb);
+
+ void AddIntRadioData(struct _GtkRadioButton &object, ImportExportCallback<int> const &cb);
+
+ void AddTextEntryData(struct _GtkEntry &object, ImportExportCallback<const char *> const &cb);
+
+ void AddIntEntryData(struct _GtkEntry &object, ImportExportCallback<int> const &cb);
+
+ void AddSizeEntryData(struct _GtkEntry &object, ImportExportCallback<std::size_t> const &cb);
+
+ void AddFloatEntryData(struct _GtkEntry &object, ImportExportCallback<float> const &cb);
+
+ void AddFloatSpinnerData(struct _GtkSpinButton &object, ImportExportCallback<float> const &cb);
+
+ void AddIntSpinnerData(struct _GtkSpinButton &object, ImportExportCallback<int> const &cb);
+
+ void AddIntAdjustmentData(struct _GtkAdjustment &object, ImportExportCallback<int> const &cb);
+
+ void AddIntComboData(struct _GtkComboBox &object, ImportExportCallback<int> const &cb);
void AddDialogData( struct _GtkToggleButton& object, bool& data );
void AddDialogData( struct _GtkRadioButton& object, int& data );
}
typedef ReferenceCaller<EntityCreator, void(bool), LightRadiiImport> LightRadiiImportCaller;
-void LightRadiiExport( EntityCreator& self, const BoolImportCallback& importer ){
+void LightRadiiExport( EntityCreator& self, const ImportExportCallback<bool>::Import_t& importer ){
importer( self.getLightRadii() );
}
-typedef ReferenceCaller<EntityCreator, void(const BoolImportCallback&), LightRadiiExport> LightRadiiExportCaller;
+typedef ReferenceCaller<EntityCreator, void(const ImportExportCallback<bool>::Import_t&), LightRadiiExport> LightRadiiExportCaller;
void Entity_constructPreferences( PreferencesPage& page ){
page.appendCheckBox(
"Show", "Light Radii",
- LightRadiiImportCaller( GlobalEntityCreator() ),
- LightRadiiExportCaller( GlobalEntityCreator() )
+ {LightRadiiImportCaller( GlobalEntityCreator() ),
+ LightRadiiExportCaller( GlobalEntityCreator() )}
);
}
void Entity_constructPage( PreferenceGroup& group ){
}
ToggleFilterFlag( const ToggleFilterFlag& other ) : m_mask( other.m_mask ), m_item( ActiveCaller( *this ) ){
}
-void active( const BoolImportCallback& importCallback ){
+void active( const ImportExportCallback<bool>::Import_t& importCallback ){
importCallback( ( g_filters_globals.exclude & m_mask ) != 0 );
}
-typedef MemberCaller<ToggleFilterFlag, void(const BoolImportCallback&), &ToggleFilterFlag::active> ActiveCaller;
+typedef MemberCaller<ToggleFilterFlag, void(const ImportExportCallback<bool>::Import_t&), &ToggleFilterFlag::active> ActiveCaller;
void toggle(){
g_filters_globals.exclude ^= m_mask;
m_item.update();
setGridPower( m_id );
}
typedef MemberCaller<GridMenuItem, void(), &GridMenuItem::set> SetCaller;
-void active( const BoolImportCallback& importCallback ){
+void active( const ImportExportCallback<bool>::Import_t& importCallback ){
importCallback( g_grid_power == m_id );
}
-typedef MemberCaller<GridMenuItem, void(const BoolImportCallback&), &GridMenuItem::active> ExportCaller;
+typedef MemberCaller<GridMenuItem, void(const ImportExportCallback<bool>::Import_t&), &GridMenuItem::active> ExportCaller;
};
GridMenuItem g_gridMenu0125( GRIDPOWER_0125 );
GroupDlg g_GroupDlg;
std::size_t g_current_page;
-std::vector<StringExportCallback> g_pages;
+std::vector<ImportExportCallback<const char *>::Export_t> g_pages;
}
void GroupDialog_updatePageTitle( ui::Window window, std::size_t pageIndex ){
}
-ui::Widget GroupDialog_addPage( const char* tabLabel, ui::Widget widget, const StringExportCallback& title ){
+ui::Widget GroupDialog_addPage( const char* tabLabel, ui::Widget widget, const ImportExportCallback<const char *>::Export_t& title ){
ui::Widget w = ui::Label( tabLabel );
w.show();
ui::Widget page = ui::Widget(gtk_notebook_get_nth_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gtk_notebook_insert_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), widget, w, -1 ) ));
ui::Window GroupDialog_getWindow();
void GroupDialog_show();
-inline void RawStringExport( const char* string, const StringImportCallback& importer ){
+inline void RawStringExport( const char* string, const ImportExportCallback<const char *>::Import_t& importer ){
importer( string );
}
-typedef ConstPointerCaller<char, void(const StringImportCallback&), RawStringExport> RawStringExportCaller;
-ui::Widget GroupDialog_addPage( const char* tabLabel, ui::Widget widget, const StringExportCallback& title );
+typedef ConstPointerCaller<char, void(const ImportExportCallback<const char *>::Import_t&), RawStringExport> RawStringExportCaller;
+ui::Widget GroupDialog_addPage( const char* tabLabel, ui::Widget widget, const ImportExportCallback<const char *>::Export_t& title );
void GroupDialog_showPage( ui::Widget page );
void GroupDialog_updatePageTitle( ui::Widget page );
void Paths_constructPreferences( PreferencesPage& page ){
page.appendPathEntry( "Engine Path", true,
- StringImportCallback( EnginePathImportCaller( g_strEnginePath ) ),
- StringExportCallback( StringExportCaller( g_strEnginePath ) )
+ {ImportExportCallback<const char *>::Import_t( EnginePathImportCaller( g_strEnginePath ) ),
+ ImportExportCallback<const char *>::Export_t( StringExportCaller( g_strEnginePath ) )}
);
}
void Paths_constructPage( PreferenceGroup& group ){
class BoolFunctionExport
{
public:
-static void apply( const BoolImportCallback& importCallback ){
+static void apply( const ImportExportCallback<bool>::Import_t& importCallback ){
importCallback( BoolFunction() );
}
};
-typedef FreeCaller<void(const BoolImportCallback&), &BoolFunctionExport<EdgeMode>::apply> EdgeModeApplyCaller;
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), &BoolFunctionExport<EdgeMode>::apply> EdgeModeApplyCaller;
EdgeModeApplyCaller g_edgeMode_button_caller;
-BoolExportCallback g_edgeMode_button_callback( g_edgeMode_button_caller );
+ImportExportCallback<bool>::Export_t g_edgeMode_button_callback( g_edgeMode_button_caller );
ToggleItem g_edgeMode_button( g_edgeMode_button_callback );
-typedef FreeCaller<void(const BoolImportCallback&), &BoolFunctionExport<VertexMode>::apply> VertexModeApplyCaller;
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), &BoolFunctionExport<VertexMode>::apply> VertexModeApplyCaller;
VertexModeApplyCaller g_vertexMode_button_caller;
-BoolExportCallback g_vertexMode_button_callback( g_vertexMode_button_caller );
+ImportExportCallback<bool>::Export_t g_vertexMode_button_callback( g_vertexMode_button_caller );
ToggleItem g_vertexMode_button( g_vertexMode_button_callback );
-typedef FreeCaller<void(const BoolImportCallback&), &BoolFunctionExport<FaceMode>::apply> FaceModeApplyCaller;
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), &BoolFunctionExport<FaceMode>::apply> FaceModeApplyCaller;
FaceModeApplyCaller g_faceMode_button_caller;
-BoolExportCallback g_faceMode_button_callback( g_faceMode_button_caller );
+ImportExportCallback<bool>::Export_t g_faceMode_button_callback( g_faceMode_button_caller );
ToggleItem g_faceMode_button( g_faceMode_button_callback );
void ComponentModeChanged(){
}
-void TranslateToolExport( const BoolImportCallback& importCallback ){
+void TranslateToolExport( const ImportExportCallback<bool>::Import_t& importCallback ){
importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eTranslate );
}
-void RotateToolExport( const BoolImportCallback& importCallback ){
+void RotateToolExport( const ImportExportCallback<bool>::Import_t& importCallback ){
importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eRotate );
}
-void ScaleToolExport( const BoolImportCallback& importCallback ){
+void ScaleToolExport( const ImportExportCallback<bool>::Import_t& importCallback ){
importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eScale );
}
-void DragToolExport( const BoolImportCallback& importCallback ){
+void DragToolExport( const ImportExportCallback<bool>::Import_t& importCallback ){
importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eDrag );
}
-void ClipperToolExport( const BoolImportCallback& importCallback ){
+void ClipperToolExport( const ImportExportCallback<bool>::Import_t& importCallback ){
importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eClip );
}
-FreeCaller<void(const BoolImportCallback&), TranslateToolExport> g_translatemode_button_caller;
-BoolExportCallback g_translatemode_button_callback( g_translatemode_button_caller );
+FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TranslateToolExport> g_translatemode_button_caller;
+ImportExportCallback<bool>::Export_t g_translatemode_button_callback( g_translatemode_button_caller );
ToggleItem g_translatemode_button( g_translatemode_button_callback );
-FreeCaller<void(const BoolImportCallback&), RotateToolExport> g_rotatemode_button_caller;
-BoolExportCallback g_rotatemode_button_callback( g_rotatemode_button_caller );
+FreeCaller<void(const ImportExportCallback<bool>::Import_t&), RotateToolExport> g_rotatemode_button_caller;
+ImportExportCallback<bool>::Export_t g_rotatemode_button_callback( g_rotatemode_button_caller );
ToggleItem g_rotatemode_button( g_rotatemode_button_callback );
-FreeCaller<void(const BoolImportCallback&), ScaleToolExport> g_scalemode_button_caller;
-BoolExportCallback g_scalemode_button_callback( g_scalemode_button_caller );
+FreeCaller<void(const ImportExportCallback<bool>::Import_t&), ScaleToolExport> g_scalemode_button_caller;
+ImportExportCallback<bool>::Export_t g_scalemode_button_callback( g_scalemode_button_caller );
ToggleItem g_scalemode_button( g_scalemode_button_callback );
-FreeCaller<void(const BoolImportCallback&), DragToolExport> g_dragmode_button_caller;
-BoolExportCallback g_dragmode_button_callback( g_dragmode_button_caller );
+FreeCaller<void(const ImportExportCallback<bool>::Import_t&), DragToolExport> g_dragmode_button_caller;
+ImportExportCallback<bool>::Export_t g_dragmode_button_callback( g_dragmode_button_caller );
ToggleItem g_dragmode_button( g_dragmode_button_callback );
-FreeCaller<void(const BoolImportCallback&), ClipperToolExport> g_clipper_button_caller;
-BoolExportCallback g_clipper_button_callback( g_clipper_button_caller );
+FreeCaller<void(const ImportExportCallback<bool>::Import_t&), ClipperToolExport> g_clipper_button_caller;
+ImportExportCallback<bool>::Export_t g_clipper_button_callback( g_clipper_button_caller );
ToggleItem g_clipper_button( g_clipper_button_callback );
void ToolChanged(){
}
-LatchedInt g_Layout_viewStyle( 0, "Window Layout" );
-LatchedBool g_Layout_enableDetachableMenus( true, "Detachable Menus" );
-LatchedBool g_Layout_enablePatchToolbar( true, "Patch Toolbar" );
-LatchedBool g_Layout_enablePluginToolbar( true, "Plugin Toolbar" );
+LatchedValue<int> g_Layout_viewStyle( 0, "Window Layout" );
+LatchedValue<bool> g_Layout_enableDetachableMenus( true, "Detachable Menus" );
+LatchedValue<bool> g_Layout_enablePatchToolbar( true, "Patch Toolbar" );
+LatchedValue<bool> g_Layout_enablePluginToolbar( true, "Plugin Toolbar" );
page.appendRadioIcons(
"Window Layout",
STRING_ARRAY_RANGE( layouts ),
- LatchedIntImportCaller( g_Layout_viewStyle ),
- IntExportCaller( g_Layout_viewStyle.m_latched )
+ mkImportExportCallback( g_Layout_viewStyle )
);
}
page.appendCheckBox(
"", "Detachable Menus",
- LatchedBoolImportCaller( g_Layout_enableDetachableMenus ),
- BoolExportCaller( g_Layout_enableDetachableMenus.m_latched )
+ mkImportExportCallback( g_Layout_enableDetachableMenus )
);
if ( !string_empty( g_pGameDescription->getKeyValue( "no_patch" ) ) ) {
page.appendCheckBox(
"", "Patch Toolbar",
- LatchedBoolImportCaller( g_Layout_enablePatchToolbar ),
- BoolExportCaller( g_Layout_enablePatchToolbar.m_latched )
+ mkImportExportCallback( g_Layout_enablePatchToolbar )
);
}
page.appendCheckBox(
"", "Plugin Toolbar",
- LatchedBoolImportCaller( g_Layout_enablePluginToolbar ),
- BoolExportCaller( g_Layout_enablePluginToolbar.m_latched )
+ mkImportExportCallback( g_Layout_enablePluginToolbar )
);
}
extern glwindow_globals_t g_glwindow_globals;
template<typename Value>
class LatchedValue;
-typedef LatchedValue<bool> LatchedBool;
-extern LatchedBool g_Layout_enableDetachableMenus;
+extern LatchedValue<bool> g_Layout_enableDetachableMenus;
void deleteSelection();
multimon_globals_t g_multimon_globals;
-LatchedBool g_Multimon_enableSysMenuPopups( false, "Floating windows sysmenu icons" );
+LatchedValue<bool> g_Multimon_enableSysMenuPopups( false, "Floating windows sysmenu icons" );
void MultiMonitor_constructPreferences( PreferencesPage& page ){
ui::CheckButton primary_monitor = page.appendCheckBox( "Multi Monitor", "Start on Primary Monitor", g_multimon_globals.m_bStartOnPrimMon );
ui::CheckButton popup = page.appendCheckBox(
"", "Disable system menu on popup windows",
- LatchedBoolImportCaller( g_Multimon_enableSysMenuPopups ),
- BoolExportCaller( g_Multimon_enableSysMenuPopups.m_latched )
+ mkImportExportCallback( g_Multimon_enableSysMenuPopups )
);
Widget_connectToggleDependency( popup, primary_monitor );
}
{
class PreferenceEntry
{
-StringImportCallback m_importer;
-StringExportCallback m_exporter;
+ImportExportCallback<const char *>::Import_t m_importer;
+ImportExportCallback<const char *>::Export_t m_exporter;
public:
-PreferenceEntry( const StringImportCallback& importer, const StringExportCallback& exporter )
+PreferenceEntry( const ImportExportCallback<const char *>::Import_t& importer, const ImportExportCallback<const char *>::Export_t& exporter )
: m_importer( importer ), m_exporter( exporter ){
}
void importString( const char* string ){
m_importer( string );
}
-void exportString( const StringImportCallback& importer ){
+void exportString( const ImportExportCallback<const char *>::Import_t& importer ){
m_exporter( importer );
}
};
return m_preferences.find( name );
}
-void registerPreference( const char* name, const StringImportCallback& importer, const StringExportCallback& exporter ){
+void registerPreference( const char* name, const ImportExportCallback<const char *>::Import_t& importer, const ImportExportCallback<const char *>::Export_t& exporter ){
m_preferences.insert( PreferenceEntries::value_type( name, PreferenceEntry( importer, exporter ) ) );
PreferenceCache::iterator i = m_cache.find( name );
if ( i != m_cache.end() ) {
m_sGameFile = ( *iGame )->mGameFile;
}
-void CGameDialog::GameFileExport( const IntImportCallback& importCallback ) const {
+void CGameDialog::GameFileExport( const ImportExportCallback<int>::Import_t& importCallback ) const {
// use m_sGameFile to set value
std::list<CGameDescription *>::const_iterator iGame;
int i = 0;
self.GameFileImport( value );
}
-void CGameDialog_GameFileExport( CGameDialog& self, const IntImportCallback& importCallback ){
+void CGameDialog_GameFileExport( CGameDialog& self, const ImportExportCallback<int>::Import_t& importCallback ){
self.GameFileExport( importCallback );
}
page.appendCombo(
"Select the game",
StringArrayRange( &( *games.begin() ), &( *games.end() ) ),
- ReferenceCaller<CGameDialog, void(int), CGameDialog_GameFileImport>( *this ),
- ReferenceCaller<CGameDialog, void(const IntImportCallback&), CGameDialog_GameFileExport>( *this )
+ {ReferenceCaller<CGameDialog, void(int), CGameDialog_GameFileImport>( *this ),
+ ReferenceCaller<CGameDialog, void(const ImportExportCallback<int>::Import_t&), CGameDialog_GameFileExport>( *this )}
);
page.appendCheckBox( "Startup", "Show Global Preferences", m_bGamePrompt );
}
gamename_set( value );
}
typedef FreeCaller<void(const char*), GameName_importString> GameNameImportStringCaller;
-void GameName_exportString( const StringImportCallback& importer ){
+void GameName_exportString( const ImportExportCallback<const char *>::Import_t& importer ){
importer( gamename_get() );
}
-typedef FreeCaller<void(const StringImportCallback&), GameName_exportString> GameNameExportStringCaller;
+typedef FreeCaller<void(const ImportExportCallback<const char *>::Import_t&), GameName_exportString> GameNameExportStringCaller;
void GameMode_importString( const char* value ){
gamemode_set( value );
}
typedef FreeCaller<void(const char*), GameMode_importString> GameModeImportStringCaller;
-void GameMode_exportString( const StringImportCallback& importer ){
+void GameMode_exportString( const ImportExportCallback<const char *>::Import_t& importer ){
importer( gamemode_get() );
}
-typedef FreeCaller<void(const StringImportCallback&), GameMode_exportString> GameModeExportStringCaller;
+typedef FreeCaller<void(const ImportExportCallback<const char *>::Import_t&), GameMode_exportString> GameModeExportStringCaller;
void RegisterPreferences( PreferenceSystem& preferences ){
ui::CheckButton appendCheckBox( const char* name, const char* flag, bool& data ){
return m_dialog.addCheckBox( m_vbox, name, flag, data );
}
-ui::CheckButton appendCheckBox( const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback ){
- return m_dialog.addCheckBox( m_vbox, name, flag, importCallback, exportCallback );
+ui::CheckButton appendCheckBox( const char* name, const char* flag, ImportExportCallback<bool> const &cb ){
+ return m_dialog.addCheckBox( m_vbox, name, flag, cb );
}
-void appendCombo( const char* name, StringArrayRange values, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){
- m_dialog.addCombo( m_vbox, name, values, importCallback, exportCallback );
+void appendCombo( const char* name, StringArrayRange values, ImportExportCallback<int> const &cb ){
+ m_dialog.addCombo( m_vbox, name, values, cb );
}
void appendCombo( const char* name, int& data, StringArrayRange values ){
m_dialog.addCombo( m_vbox, name, data, values );
void appendSlider( const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ){
m_dialog.addSlider( m_vbox, name, data, draw_value, low, high, value, lower, upper, step_increment, page_increment );
}
-void appendRadio( const char* name, StringArrayRange names, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){
- m_dialog.addRadio( m_vbox, name, names, importCallback, exportCallback );
+void appendRadio( const char* name, StringArrayRange names, ImportExportCallback<int> const &cb ){
+ m_dialog.addRadio( m_vbox, name, names, cb );
}
void appendRadio( const char* name, int& data, StringArrayRange names ){
m_dialog.addRadio( m_vbox, name, data, names );
}
-void appendRadioIcons( const char* name, StringArrayRange icons, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){
- m_dialog.addRadioIcons( m_vbox, name, icons, importCallback, exportCallback );
+void appendRadioIcons( const char* name, StringArrayRange icons, ImportExportCallback<int> const &cb ){
+ m_dialog.addRadioIcons( m_vbox, name, icons, cb );
}
void appendRadioIcons( const char* name, int& data, StringArrayRange icons ){
m_dialog.addRadioIcons( m_vbox, name, data, icons );
}
-ui::Widget appendEntry( const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){
- return m_dialog.addIntEntry( m_vbox, name, importCallback, exportCallback );
+ui::Widget appendEntry( const char* name, ImportExportCallback<int> const &cb ){
+ return m_dialog.addIntEntry( m_vbox, name, cb );
}
ui::Widget appendEntry( const char* name, int& data ){
return m_dialog.addEntry( m_vbox, name, data );
}
-ui::Widget appendEntry( const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback ){
- return m_dialog.addSizeEntry( m_vbox, name, importCallback, exportCallback );
+ui::Widget appendEntry( const char* name, ImportExportCallback<std::size_t> const &cb){
+ return m_dialog.addSizeEntry( m_vbox, name, cb );
}
ui::Widget appendEntry( const char* name, std::size_t& data ){
return m_dialog.addEntry( m_vbox, name, data );
}
-ui::Widget appendEntry( const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ){
- return m_dialog.addFloatEntry( m_vbox, name, importCallback, exportCallback );
+ui::Widget appendEntry( const char* name, ImportExportCallback<float> const &cb ){
+ return m_dialog.addFloatEntry( m_vbox, name, cb );
}
ui::Widget appendEntry( const char* name, float& data ){
return m_dialog.addEntry( m_vbox, name, data );
}
-ui::Widget appendPathEntry( const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback ){
- return m_dialog.addPathEntry( m_vbox, name, browse_directory, importCallback, exportCallback );
+ui::Widget appendPathEntry( const char* name, bool browse_directory, ImportExportCallback<const char *> const &cb ){
+ return m_dialog.addPathEntry( m_vbox, name, browse_directory, cb );
}
ui::Widget appendPathEntry( const char* name, CopiedString& data, bool directory ){
return m_dialog.addPathEntry( m_vbox, name, data, directory );
ui::SpinButton appendSpinner( const char* name, int& data, double value, double lower, double upper ){
return m_dialog.addSpinner( m_vbox, name, data, value, lower, upper );
}
-ui::SpinButton appendSpinner( const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){
- return m_dialog.addSpinner( m_vbox, name, value, lower, upper, importCallback, exportCallback );
+ui::SpinButton appendSpinner( const char* name, double value, double lower, double upper, ImportExportCallback<int> const &cb ){
+ return m_dialog.addSpinner( m_vbox, name, value, lower, upper, cb );
}
-ui::SpinButton appendSpinner( const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ){
- return m_dialog.addSpinner( m_vbox, name, value, lower, upper, importCallback, exportCallback );
+ui::SpinButton appendSpinner( const char* name, double value, double lower, double upper, ImportExportCallback<float> const &cb ){
+ return m_dialog.addSpinner( m_vbox, name, value, lower, upper, cb );
}
};
void PreferencesDialog_restartRequired( const char* staticName );
template<typename Value>
-class LatchedValue
-{
+class LatchedValue {
public:
-Value m_value;
-Value m_latched;
-const char* m_description;
-
-LatchedValue( Value value, const char* description ) : m_latched( value ), m_description( description ){
-}
-void useLatched(){
- m_value = m_latched;
-}
-void import( Value value ){
- m_latched = value;
- if ( m_latched != m_value ) {
- PreferencesDialog_restartRequired( m_description );
- }
-}
+ Value m_value;
+ Value m_latched;
+ const char *m_description;
+
+ LatchedValue(Value value, const char *description) : m_latched(value), m_description(description) {
+ }
+
+ void useLatched() {
+ m_value = m_latched;
+ }
+
+ void import(Value value) {
+ m_latched = value;
+ if (m_latched != m_value) {
+ PreferencesDialog_restartRequired(m_description);
+ }
+ }
};
-typedef LatchedValue<bool> LatchedBool;
-typedef MemberCaller<LatchedBool, void(bool), &LatchedBool::import> LatchedBoolImportCaller;
-
-typedef LatchedValue<int> LatchedInt;
-typedef MemberCaller<LatchedInt, void(int), &LatchedInt::import> LatchedIntImportCaller;
+template<class Self, class T = Self>
+ImportExportCallback<T> mkImportExportCallback(LatchedValue<Self> &self) {
+ return {
+ MemberCaller<LatchedValue<Self>, void(T), &LatchedValue<Self>::import>(self),
+ ReferenceCaller<Self, void(const Callback<void(T)> &), impexp<Self, T>::Export>(self.m_latched)
+ };
+}
/*!
holds information for a given game
ui::Window BuildDialog();
void GameFileImport( int value );
-void GameFileExport( const IntImportCallback& importCallback ) const;
+void GameFileExport( const ImportExportCallback<int>::Import_t& importCallback ) const;
/*!
construction of the dialog frame
int max_tex_size = 0;
const int max_texture_quality = 3;
-LatchedInt g_Textures_textureQuality( 3, "Texture Quality" );
+LatchedValue<int> g_Textures_textureQuality( 3, "Texture Quality" );
/// \brief This function does the actual processing of raw RGBA data into a GL texture.
/// It will also resample to power-of-two dimensions, generate the mipmaps and adjust gamma.
}
typedef ReferenceCaller<ETexturesMode, void(int), TextureModeImport> TextureModeImportCaller;
-void TextureModeExport( ETexturesMode& self, const IntImportCallback& importer ){
+void TextureModeExport( ETexturesMode& self, const ImportExportCallback<int>::Import_t& importer ){
switch ( self )
{
case eTextures_NEAREST:
importer( 4 );
}
}
-typedef ReferenceCaller<ETexturesMode, void(const IntImportCallback&), TextureModeExport> TextureModeExportCaller;
+typedef ReferenceCaller<ETexturesMode, void(const ImportExportCallback<int>::Import_t&), TextureModeExport> TextureModeExportCaller;
void Textures_constructPreferences( PreferencesPage& page ){
{
page.appendRadio(
"Texture Quality",
STRING_ARRAY_RANGE( percentages ),
- LatchedIntImportCaller( g_Textures_textureQuality ),
- IntExportCaller( g_Textures_textureQuality.m_latched )
+ mkImportExportCallback( g_Textures_textureQuality )
);
}
page.appendSpinner(
1.0,
0.0,
1.0,
- FloatImportCallback( TextureGammaImportCaller( g_texture_globals.fGamma ) ),
- FloatExportCallback( FloatExportCaller( g_texture_globals.fGamma ) )
+ {ImportExportCallback<float>::Import_t( TextureGammaImportCaller( g_texture_globals.fGamma ) ),
+ ImportExportCallback<float>::Export_t( FloatExportCaller( g_texture_globals.fGamma ) )}
);
{
const char* texture_mode[] = { "Nearest", "Nearest Mipmap", "Linear", "Bilinear", "Bilinear Mipmap", "Trilinear", "Anisotropy" };
page.appendCombo(
"Texture Render Mode",
STRING_ARRAY_RANGE( texture_mode ),
- IntImportCallback( TextureModeImportCaller( g_texture_mode ) ),
- IntExportCallback( TextureModeExportCaller( g_texture_mode ) )
+ {ImportExportCallback<int>::Import_t( TextureModeImportCaller( g_texture_mode ) ),
+ ImportExportCallback<int>::Export_t( TextureModeExportCaller( g_texture_mode ) )}
);
}
{
page.appendCombo(
"Hardware Texture Compression",
compression,
- TextureCompressionImportCaller( g_texture_globals.m_nTextureCompressionFormat ),
- IntExportCaller( reinterpret_cast<int&>( g_texture_globals.m_nTextureCompressionFormat ) )
+ {TextureCompressionImportCaller( g_texture_globals.m_nTextureCompressionFormat ),
+ IntExportCaller( reinterpret_cast<int&>( g_texture_globals.m_nTextureCompressionFormat ) )}
);
}
}
STARTUPSHADERS_COMMON,
};
-void TextureBrowser_hideUnusedExport( const BoolImportCallback& importer );
-typedef FreeCaller<void(const BoolImportCallback&), TextureBrowser_hideUnusedExport> TextureBrowserHideUnusedExport;
+void TextureBrowser_hideUnusedExport( const ImportExportCallback<bool>::Import_t& importer );
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_hideUnusedExport> TextureBrowserHideUnusedExport;
-void TextureBrowser_showShadersExport( const BoolImportCallback& importer );
-typedef FreeCaller<void(const BoolImportCallback&), TextureBrowser_showShadersExport> TextureBrowserShowShadersExport;
+void TextureBrowser_showShadersExport( const ImportExportCallback<bool>::Import_t& importer );
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_showShadersExport> TextureBrowserShowShadersExport;
-void TextureBrowser_showShaderlistOnly( const BoolImportCallback& importer );
-typedef FreeCaller<void(const BoolImportCallback&), TextureBrowser_showShaderlistOnly> TextureBrowserShowShaderlistOnlyExport;
+void TextureBrowser_showShaderlistOnly( const ImportExportCallback<bool>::Import_t& importer );
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_showShaderlistOnly> TextureBrowserShowShaderlistOnlyExport;
-void TextureBrowser_fixedSize( const BoolImportCallback& importer );
-typedef FreeCaller<void(const BoolImportCallback&), TextureBrowser_fixedSize> TextureBrowserFixedSizeExport;
+void TextureBrowser_fixedSize( const ImportExportCallback<bool>::Import_t& importer );
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_fixedSize> TextureBrowserFixedSizeExport;
-void TextureBrowser_filterMissing( const BoolImportCallback& importer );
-typedef FreeCaller<void(const BoolImportCallback&), TextureBrowser_filterMissing> TextureBrowserFilterMissingExport;
+void TextureBrowser_filterMissing( const ImportExportCallback<bool>::Import_t& importer );
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_filterMissing> TextureBrowserFilterMissingExport;
-void TextureBrowser_filterFallback( const BoolImportCallback& importer );
-typedef FreeCaller<void(const BoolImportCallback&), TextureBrowser_filterFallback> TextureBrowserFilterFallbackExport;
+void TextureBrowser_filterFallback( const ImportExportCallback<bool>::Import_t& importer );
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_filterFallback> TextureBrowserFilterFallbackExport;
-void TextureBrowser_enableAlpha( const BoolImportCallback& importer );
-typedef FreeCaller<void(const BoolImportCallback&), TextureBrowser_enableAlpha> TextureBrowserEnableAlphaExport;
+void TextureBrowser_enableAlpha( const ImportExportCallback<bool>::Import_t& importer );
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_enableAlpha> TextureBrowserEnableAlphaExport;
class TextureBrowser
{
bool TextureBrowser_hideUnused();
-void TextureBrowser_hideUnusedExport( const BoolImportCallback& importer ){
+void TextureBrowser_hideUnusedExport( const ImportExportCallback<bool>::Import_t& importer ){
importer( TextureBrowser_hideUnused() );
}
-typedef FreeCaller<void(const BoolImportCallback&), TextureBrowser_hideUnusedExport> TextureBrowserHideUnusedExport;
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_hideUnusedExport> TextureBrowserHideUnusedExport;
-void TextureBrowser_showShadersExport( const BoolImportCallback& importer ){
+void TextureBrowser_showShadersExport( const ImportExportCallback<bool>::Import_t& importer ){
importer( GlobalTextureBrowser().m_showShaders );
}
-typedef FreeCaller<void(const BoolImportCallback&), TextureBrowser_showShadersExport> TextureBrowserShowShadersExport;
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_showShadersExport> TextureBrowserShowShadersExport;
-void TextureBrowser_showShaderlistOnly( const BoolImportCallback& importer ){
+void TextureBrowser_showShaderlistOnly( const ImportExportCallback<bool>::Import_t& importer ){
importer( g_TextureBrowser_shaderlistOnly );
}
-typedef FreeCaller<void(const BoolImportCallback&), TextureBrowser_showShaderlistOnly> TextureBrowserShowShaderlistOnlyExport;
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_showShaderlistOnly> TextureBrowserShowShaderlistOnlyExport;
-void TextureBrowser_fixedSize( const BoolImportCallback& importer ){
+void TextureBrowser_fixedSize( const ImportExportCallback<bool>::Import_t& importer ){
importer( g_TextureBrowser_fixedSize );
}
-typedef FreeCaller<void(const BoolImportCallback&), TextureBrowser_fixedSize> TextureBrowser_FixedSizeExport;
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_fixedSize> TextureBrowser_FixedSizeExport;
-void TextureBrowser_filterMissing( const BoolImportCallback& importer ){
+void TextureBrowser_filterMissing( const ImportExportCallback<bool>::Import_t& importer ){
importer( g_TextureBrowser_filterMissing );
}
-typedef FreeCaller<void(const BoolImportCallback&), TextureBrowser_filterMissing> TextureBrowser_filterMissingExport;
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_filterMissing> TextureBrowser_filterMissingExport;
-void TextureBrowser_filterFallback( const BoolImportCallback& importer ){
+void TextureBrowser_filterFallback( const ImportExportCallback<bool>::Import_t& importer ){
importer( g_TextureBrowser_filterFallback );
}
-typedef FreeCaller<void(const BoolImportCallback&), TextureBrowser_filterFallback> TextureBrowser_filterFallbackExport;
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_filterFallback> TextureBrowser_filterFallbackExport;
-void TextureBrowser_enableAlpha( const BoolImportCallback& importer ){
+void TextureBrowser_enableAlpha( const ImportExportCallback<bool>::Import_t& importer ){
importer( g_TextureBrowser_enableAlpha );
}
-typedef FreeCaller<void(const BoolImportCallback&), TextureBrowser_enableAlpha> TextureBrowser_enableAlphaExport;
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_enableAlpha> TextureBrowser_enableAlphaExport;
void TextureBrowser_SetHideUnused( TextureBrowser& textureBrowser, bool hideUnused ){
if ( hideUnused ) {
TextureBrowser_activeShadersChanged( GlobalTextureBrowser() );
}
-void TextureBrowser_exportTitle( const StringImportCallback& importer ){
+void TextureBrowser_exportTitle( const ImportExportCallback<const char *>::Import_t& importer ){
StringOutputStream buffer( 64 );
buffer << "Textures: ";
if ( !string_empty( g_TextureBrowser_currentDirectory.c_str() ) ) {
}
typedef ReferenceCaller<TextureBrowser, void(int), TextureScaleImport> TextureScaleImportCaller;
-void TextureScaleExport( TextureBrowser& textureBrowser, const IntImportCallback& importer ){
+void TextureScaleExport( TextureBrowser& textureBrowser, const ImportExportCallback<int>::Import_t& importer ){
switch ( textureBrowser.m_textureScale )
{
case 10:
break;
}
}
-typedef ReferenceCaller<TextureBrowser, void(const IntImportCallback&), TextureScaleExport> TextureScaleExportCaller;
+typedef ReferenceCaller<TextureBrowser, void(const ImportExportCallback<int>::Import_t&), TextureScaleExport> TextureScaleExportCaller;
void UniformTextureSizeImport( TextureBrowser& textureBrowser, int value ){
void TextureBrowser_constructPreferences( PreferencesPage& page ){
page.appendCheckBox(
"", "Texture scrollbar",
- TextureBrowserImportShowScrollbarCaller( GlobalTextureBrowser() ),
- BoolExportCaller( GlobalTextureBrowser().m_showTextureScrollbar )
+ {TextureBrowserImportShowScrollbarCaller( GlobalTextureBrowser() ),
+ BoolExportCaller( GlobalTextureBrowser().m_showTextureScrollbar )}
);
{
const char* texture_scale[] = { "10%", "25%", "50%", "100%", "200%" };
page.appendCombo(
"Texture Thumbnail Scale",
STRING_ARRAY_RANGE( texture_scale ),
- IntImportCallback( TextureScaleImportCaller( GlobalTextureBrowser() ) ),
- IntExportCallback( TextureScaleExportCaller( GlobalTextureBrowser() ) )
+ {ImportExportCallback<int>::Import_t( TextureScaleImportCaller( GlobalTextureBrowser() ) ),
+ ImportExportCallback<int>::Export_t( TextureScaleExportCaller( GlobalTextureBrowser() ) )}
);
}
page.appendSpinner(
void TextureBrowser_Construct();
void TextureBrowser_Destroy();
-typedef Callback<void(const char*)> StringImportCallback;
-
extern ui::Widget g_page_textures;
-void TextureBrowser_exportTitle( const StringImportCallback& importer );
-typedef FreeCaller<void(const StringImportCallback&), TextureBrowser_exportTitle> TextureBrowserExportTitleCaller;
+void TextureBrowser_exportTitle( const ImportExportCallback<const char *>::Import_t& importer );
+typedef FreeCaller<void(const ImportExportCallback<const char *>::Import_t&), TextureBrowser_exportTitle> TextureBrowserExportTitleCaller;
const Vector3& TextureBrowser_getBackgroundColour( TextureBrowser& textureBrowser );
void TextureBrowser_setBackgroundColour( TextureBrowser& textureBrowser, const Vector3& colour );
undo.setLevels( levels );
}
typedef ReferenceCaller<RadiantUndoSystem, void(const char*), UndoLevels_importString> UndoLevelsImportStringCaller;
-void UndoLevels_exportString( const RadiantUndoSystem& undo, const StringImportCallback& importer ){
+void UndoLevels_exportString( const RadiantUndoSystem& undo, const ImportExportCallback<const char *>::Import_t& importer ){
Int_exportString( static_cast<int>( undo.getLevels() ), importer );
}
-typedef ConstReferenceCaller<RadiantUndoSystem, void(const StringImportCallback&), UndoLevels_exportString> UndoLevelsExportStringCaller;
+typedef ConstReferenceCaller<RadiantUndoSystem, void(const ImportExportCallback<const char *>::Import_t&), UndoLevels_exportString> UndoLevelsExportStringCaller;
#include "generic/callback.h"
self.setLevels( value );
}
typedef ReferenceCaller<RadiantUndoSystem, void(int), UndoLevelsImport> UndoLevelsImportCaller;
-void UndoLevelsExport( const RadiantUndoSystem& self, const IntImportCallback& importCallback ){
+void UndoLevelsExport( const RadiantUndoSystem& self, const ImportExportCallback<int>::Import_t& importCallback ){
importCallback( static_cast<int>( self.getLevels() ) );
}
-typedef ConstReferenceCaller<RadiantUndoSystem, void(const IntImportCallback&), UndoLevelsExport> UndoLevelsExportCaller;
+typedef ConstReferenceCaller<RadiantUndoSystem, void(const ImportExportCallback<int>::Import_t&), UndoLevelsExport> UndoLevelsExportCaller;
void Undo_constructPreferences( RadiantUndoSystem& undo, PreferencesPage& page ){
- page.appendSpinner( "Undo Queue Size", 64, 0, 1024, IntImportCallback( UndoLevelsImportCaller( undo ) ), IntExportCallback( UndoLevelsExportCaller( undo ) ) );
+ page.appendSpinner( "Undo Queue Size", 64, 0, 1024, {ImportExportCallback<int>::Import_t( UndoLevelsImportCaller( undo ) ), ImportExportCallback<int>::Export_t( UndoLevelsExportCaller( undo ) )} );
}
void Undo_constructPage( RadiantUndoSystem& undo, PreferenceGroup& group ){
PreferencesPage page( group.createPage( "Undo", "Undo Queue Settings" ) );
XY_UpdateAllWindows();
}
typedef FreeCaller<void(), ShowNamesToggle> ShowNamesToggleCaller;
-void ShowNamesExport( const BoolImportCallback& importer ){
+void ShowNamesExport( const ImportExportCallback<bool>::Import_t& importer ){
importer( GlobalEntityCreator().getShowNames() );
}
-typedef FreeCaller<void(const BoolImportCallback&), ShowNamesExport> ShowNamesExportCaller;
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), ShowNamesExport> ShowNamesExportCaller;
void ShowAnglesToggle(){
GlobalEntityCreator().setShowAngles( !GlobalEntityCreator().getShowAngles() );
XY_UpdateAllWindows();
}
typedef FreeCaller<void(), ShowAnglesToggle> ShowAnglesToggleCaller;
-void ShowAnglesExport( const BoolImportCallback& importer ){
+void ShowAnglesExport( const ImportExportCallback<bool>::Import_t& importer ){
importer( GlobalEntityCreator().getShowAngles() );
}
-typedef FreeCaller<void(const BoolImportCallback&), ShowAnglesExport> ShowAnglesExportCaller;
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), ShowAnglesExport> ShowAnglesExportCaller;
void ShowBlocksToggle(){
g_xywindow_globals_private.show_blocks ^= 1;
XY_UpdateAllWindows();
}
typedef FreeCaller<void(), ShowBlocksToggle> ShowBlocksToggleCaller;
-void ShowBlocksExport( const BoolImportCallback& importer ){
+void ShowBlocksExport( const ImportExportCallback<bool>::Import_t& importer ){
importer( g_xywindow_globals_private.show_blocks );
}
-typedef FreeCaller<void(const BoolImportCallback&), ShowBlocksExport> ShowBlocksExportCaller;
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), ShowBlocksExport> ShowBlocksExportCaller;
void ShowCoordinatesToggle(){
g_xywindow_globals_private.show_coordinates ^= 1;
XY_UpdateAllWindows();
}
typedef FreeCaller<void(), ShowCoordinatesToggle> ShowCoordinatesToggleCaller;
-void ShowCoordinatesExport( const BoolImportCallback& importer ){
+void ShowCoordinatesExport( const ImportExportCallback<bool>::Import_t& importer ){
importer( g_xywindow_globals_private.show_coordinates );
}
-typedef FreeCaller<void(const BoolImportCallback&), ShowCoordinatesExport> ShowCoordinatesExportCaller;
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), ShowCoordinatesExport> ShowCoordinatesExportCaller;
void ShowOutlineToggle(){
g_xywindow_globals_private.show_outline ^= 1;
XY_UpdateAllWindows();
}
typedef FreeCaller<void(), ShowOutlineToggle> ShowOutlineToggleCaller;
-void ShowOutlineExport( const BoolImportCallback& importer ){
+void ShowOutlineExport( const ImportExportCallback<bool>::Import_t& importer ){
importer( g_xywindow_globals_private.show_outline );
}
-typedef FreeCaller<void(const BoolImportCallback&), ShowOutlineExport> ShowOutlineExportCaller;
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), ShowOutlineExport> ShowOutlineExportCaller;
void ShowAxesToggle(){
g_xywindow_globals_private.show_axis ^= 1;
XY_UpdateAllWindows();
}
typedef FreeCaller<void(), ShowAxesToggle> ShowAxesToggleCaller;
-void ShowAxesExport( const BoolImportCallback& importer ){
+void ShowAxesExport( const ImportExportCallback<bool>::Import_t& importer ){
importer( g_xywindow_globals_private.show_axis );
}
-typedef FreeCaller<void(const BoolImportCallback&), ShowAxesExport> ShowAxesExportCaller;
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), ShowAxesExport> ShowAxesExportCaller;
void ShowWorkzoneToggle(){
g_xywindow_globals_private.d_show_work ^= 1;
XY_UpdateAllWindows();
}
typedef FreeCaller<void(), ShowWorkzoneToggle> ShowWorkzoneToggleCaller;
-void ShowWorkzoneExport( const BoolImportCallback& importer ){
+void ShowWorkzoneExport( const ImportExportCallback<bool>::Import_t& importer ){
importer( g_xywindow_globals_private.d_show_work );
}
-typedef FreeCaller<void(const BoolImportCallback&), ShowWorkzoneExport> ShowWorkzoneExportCaller;
+typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), ShowWorkzoneExport> ShowWorkzoneExportCaller;
ShowNamesExportCaller g_show_names_caller;
-BoolExportCallback g_show_names_callback( g_show_names_caller );
+ImportExportCallback<bool>::Export_t g_show_names_callback( g_show_names_caller );
ToggleItem g_show_names( g_show_names_callback );
ShowAnglesExportCaller g_show_angles_caller;
-BoolExportCallback g_show_angles_callback( g_show_angles_caller );
+ImportExportCallback<bool>::Export_t g_show_angles_callback( g_show_angles_caller );
ToggleItem g_show_angles( g_show_angles_callback );
ShowBlocksExportCaller g_show_blocks_caller;
-BoolExportCallback g_show_blocks_callback( g_show_blocks_caller );
+ImportExportCallback<bool>::Export_t g_show_blocks_callback( g_show_blocks_caller );
ToggleItem g_show_blocks( g_show_blocks_callback );
ShowCoordinatesExportCaller g_show_coordinates_caller;
-BoolExportCallback g_show_coordinates_callback( g_show_coordinates_caller );
+ImportExportCallback<bool>::Export_t g_show_coordinates_callback( g_show_coordinates_caller );
ToggleItem g_show_coordinates( g_show_coordinates_callback );
ShowOutlineExportCaller g_show_outline_caller;
-BoolExportCallback g_show_outline_callback( g_show_outline_caller );
+ImportExportCallback<bool>::Export_t g_show_outline_callback( g_show_outline_caller );
ToggleItem g_show_outline( g_show_outline_callback );
ShowAxesExportCaller g_show_axes_caller;
-BoolExportCallback g_show_axes_callback( g_show_axes_caller );
+ImportExportCallback<bool>::Export_t g_show_axes_callback( g_show_axes_caller );
ToggleItem g_show_axes( g_show_axes_callback );
ShowWorkzoneExportCaller g_show_workzone_caller;
-BoolExportCallback g_show_workzone_callback( g_show_workzone_caller );
+ImportExportCallback<bool>::Export_t g_show_workzone_callback( g_show_workzone_caller );
ToggleItem g_show_workzone( g_show_workzone_callback );
void XYShow_registerCommands(){
self.set( value );
}
typedef ReferenceCaller<ToggleShown, void(bool), ToggleShown_importBool> ToggleShownImportBoolCaller;
-void ToggleShown_exportBool( const ToggleShown& self, const BoolImportCallback& importer ){
+void ToggleShown_exportBool( const ToggleShown& self, const ImportExportCallback<bool>::Import_t& importer ){
importer( self.active() );
}
-typedef ConstReferenceCaller<ToggleShown, void(const BoolImportCallback&), ToggleShown_exportBool> ToggleShownExportBoolCaller;
+typedef ConstReferenceCaller<ToggleShown, void(const ImportExportCallback<bool>::Import_t&), ToggleShown_exportBool> ToggleShownExportBoolCaller;
void XYWindow_Construct(){