forked from aleksanderkoder/VanityUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource.cpp
More file actions
68 lines (49 loc) · 1.82 KB
/
Copy pathSource.cpp
File metadata and controls
68 lines (49 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "IvoryUI.h"
#include <iostream>
int main(int argc, char* argv[])
{
Ivory::Setup(1920, 1080);
//Ivory::DisableVsync();
// Create a rendering context via Ivory. Can also pass an existing renderer to the Ivory Setup() method instead.
SDL_Renderer* renderer = Ivory::CreateRenderingContext("IVORY UI");
SDL_Color black = { 0,0,0,255 };
Label* l = Ivory::CreateLabel("Hello, Ivory!");
Button* b = Ivory::CreateButton("Page 2");
auto tb = Ivory::CreateTextbox("Text char limit", 350);
auto img = Ivory::CreateImage("db3991d70eff2556d448c9d911e71a11_400x400.jpeg", 600, 0, 50, 50);
auto cb = Ivory::CreateCheckbox(550);
auto sl = Ivory::CreateSlider(650, 500, 250, 20, 60, 60);
tb->SetBackgroundImage("db3991d70eff2556d448c9d911e71a11_400x400.jpeg");
auto div = Ivory::CreateDivision(0, 0, 600, 600);
auto div2 = Ivory::CreateDivision(100, 100, 200, 200);
auto div3 = Ivory::CreateDivision(100, 100, 200, 200);
div->AddChild(div2);
div2->AddChild(div3);
div3->AddChild(b);
div3->AddChild(tb);
div3->AddChild(img);
div3->AddChild(l);
div3->AddChild(cb);
auto btn = Ivory::CreateButton("Back to page 1");
b->SetDimensions("50%", "100%");
Page* p = Ivory::CreatePage();
Page* p2 = Ivory::CreatePage();
p->AddElement(div);
p->AddElement(sl);
p2->AddElement(btn);
Ivory::DisplayPage(p);
while (Ivory::IsRunning()) {
Ivory::Prepare();
//tb->SetValue(std::to_string(sl->GetValue()));
if (b->IsPressed()) {
std::cout << "Button pressed!" << std::endl;
Ivory::DisplayPage(p2);
}
if (btn->IsPressed())
Ivory::DisplayPage(p);
Ivory::Render();
SDL_RenderPresent(renderer);
}
//SDL_Delay(10000);
return 0;
}