Created
February 15, 2017 12:59
-
-
Save recp/d1d934a3ea8429518efab7128356ef65 to your computer and use it in GitHub Desktop.
libui - usage
This file contains hidden or 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
#include <ui-app.h> | |
#include <ui-window.h> | |
using namespace ui; | |
int main(int argc, const char *argv[]) { | |
App app; | |
Window mainWindow({{10,0}, {800, 600}}); | |
/* close app with window */ | |
mainWindow.setCloseBehavior(kWindowCloseBehavior_AppShouldExit); | |
View view1({{10, 10}, {150, 150}}); | |
view1.setBackgroundColor({1, 0, 0}); | |
View view2({{5, 5}, {50, 50}}); | |
view2.setBackgroundColor({1, 1, 1}); | |
/* add view2 to view1 */ | |
view1.addSubview(view2); | |
/* add view 1 to window's content view */ | |
mainWindow.contentView()->addSubview(view1); | |
View view3({{10, 10}, {30, 30}}); | |
view3.setBackgroundColor({0, 0, 1}); | |
view2.addSubview(view3); | |
mainWindow.show(); | |
app.run(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Win32 (Wİndows 10):
Cocoa (macOS 10.12)