-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): create window for win32 (#21)
Signed-off-by: Tony Gorez <[email protected]>
- Loading branch information
Showing
12 changed files
with
79 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
if(APPLE) | ||
add_subdirectory(window) | ||
endif() | ||
add_subdirectory(window) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
if(APPLE) | ||
add_subdirectory(appkit) | ||
elseif(WIN32) | ||
add_subdirectory(win32) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
noa_library( | ||
NAMESPACE sourcemeta | ||
PROJECT native | ||
NAME window | ||
VARIANT win32 | ||
FOLDER "Native/Ui/Window" | ||
SOURCES window_win32.cc) | ||
|
||
noa_library_install( | ||
NAMESPACE sourcemeta | ||
PROJECT native | ||
NAME window | ||
VARIANT win32) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <Windows.h> | ||
#include <sourcemeta/native/window.h> | ||
|
||
namespace sourcemeta::native { | ||
|
||
Window::Window() : internal_(nullptr) { | ||
const char CLASS_NAME[] = "NativeWin32WindowClass"; | ||
|
||
WNDCLASS wc = {}; | ||
wc.lpfnWndProc = DefWindowProc; // Use default window procedure for now | ||
wc.hInstance = GetModuleHandle(NULL); | ||
wc.lpszClassName = CLASS_NAME; | ||
RegisterClass(&wc); | ||
|
||
// TODO(tony): add parameter for title | ||
HWND hwnd = | ||
CreateWindowEx(0, CLASS_NAME, "Window Title", WS_OVERLAPPEDWINDOW, | ||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, | ||
NULL, // Parent window | ||
NULL, // Menu | ||
GetModuleHandle(NULL), NULL); | ||
|
||
internal_ = hwnd; | ||
} | ||
|
||
Window::~Window() { | ||
if (internal_) { | ||
DestroyWindow(static_cast<HWND>(internal_)); | ||
} | ||
} | ||
|
||
auto Window::size(const unsigned int width, const unsigned int height) -> void { | ||
SetWindowPos(static_cast<HWND>(internal_), NULL, 0, 0, // Ignore position | ||
width, height, SWP_NOMOVE | SWP_NOZORDER); | ||
} | ||
|
||
auto Window::show() -> void { | ||
ShowWindow(static_cast<HWND>(internal_), SW_SHOW); | ||
} | ||
|
||
} // namespace sourcemeta::native |