Skip to content

Commit

Permalink
Finish refactoring of platform code.
Browse files Browse the repository at this point in the history
This commit finally unifies all main() functions and moves the few
remaining application-wide functions where they belong.
  • Loading branch information
whitequark committed Jul 18, 2018
1 parent 350d2ad commit 4987d12
Show file tree
Hide file tree
Showing 19 changed files with 277 additions and 374 deletions.
34 changes: 16 additions & 18 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in

if(WIN32)
set(util_SOURCES
platform/w32util.cpp)
platform/utilwin.cpp)
else()
set(util_SOURCES
platform/unixutil.cpp)
platform/utilunix.cpp)
endif()

if(APPLE)
Expand Down Expand Up @@ -102,11 +102,13 @@ else()
message(FATAL_ERROR "Unsupported OpenGL version ${OPENGL}")
endif()

set(platform_SOURCES
${gl_SOURCES}
platform/entrygui.cpp)

if(WIN32)
set(platform_SOURCES
platform/w32main.cpp
platform/guiwin.cpp
${gl_SOURCES})
list(APPEND platform_SOURCES
platform/guiwin.cpp)

set(platform_LIBRARIES
comctl32
Expand All @@ -115,16 +117,12 @@ elseif(APPLE)
add_compile_options(
-fobjc-arc)

set(platform_SOURCES
platform/cocoamain.mm
platform/guimac.mm
list(APPEND platform_SOURCES
render/rendergl.cpp
${gl_SOURCES})
platform/guimac.mm)
else()
set(platform_SOURCES
platform/gtkmain.cpp
platform/guigtk.cpp
${gl_SOURCES})
list(APPEND platform_SOURCES
platform/guigtk.cpp)

set(platform_LIBRARIES
${SPACEWARE_LIBRARIES})
Expand All @@ -137,9 +135,9 @@ else()
endif()

set(every_platform_SOURCES
platform/w32main.cpp
platform/gtkmain.cpp
platform/cocoamain.mm)
platform/guiwin.cpp
platform/guigtk.cpp
platform/guimac.mm)

# solvespace library

Expand Down Expand Up @@ -362,7 +360,7 @@ target_compile_options(solvespace-headless
# solvespace command-line executable

add_executable(solvespace-cli
platform/climain.cpp
platform/entrycli.cpp
$<TARGET_PROPERTY:resources,EXTRA_SOURCES>)

target_link_libraries(solvespace-cli
Expand Down
91 changes: 0 additions & 91 deletions src/platform/cocoamain.mm

This file was deleted.

File renamed without changes.
33 changes: 33 additions & 0 deletions src/platform/entrygui.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//-----------------------------------------------------------------------------
// Our main() function for the graphical interface.
//
// Copyright 2018 <whitequark@whitequark.org>
//-----------------------------------------------------------------------------
#include "solvespace.h"

using namespace SolveSpace;

int main(int argc, char** argv) {
std::vector<std::string> args = InitPlatform(argc, argv);

Platform::InitGui(argc, argv);
Platform::Open3DConnexion();
SS.Init();

if(args.size() >= 2) {
if(args.size() > 2) {
dbp("Only the first file passed on command line will be opened.");
}

SS.Load(Platform::Path::From(args.back()).Expand(/*fromCurrentDirectory=*/true));
}

Platform::RunGui();

Platform::Close3DConnexion();
SS.Clear();

SK.Clear();

return 0;
}
140 changes: 0 additions & 140 deletions src/platform/gtkmain.cpp

This file was deleted.

7 changes: 6 additions & 1 deletion src/platform/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,12 @@ FileDialogRef CreateSaveFileDialog(WindowRef parentWindow);
// Application-wide APIs
//-----------------------------------------------------------------------------

void Exit();
std::vector<Platform::Path> GetFontFiles();
void OpenInBrowser(const std::string &url);

void InitGui(int argc, char **argv);
void RunGui();
void ExitGui();

}

Expand Down

0 comments on commit 4987d12

Please sign in to comment.