Skip to content

Instantly share code, notes, and snippets.

@recp
Created February 15, 2017 12:59
Show Gist options
  • Save recp/d1d934a3ea8429518efab7128356ef65 to your computer and use it in GitHub Desktop.
Save recp/d1d934a3ea8429518efab7128356ef65 to your computer and use it in GitHub Desktop.
libui - usage
#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;
}
@recp
Copy link
Author

recp commented Feb 15, 2017

Win32 (Wİndows 10): win32 windows10

Cocoa (macOS 10.12) cocoa macos 10 12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment