Changes to WIP ScrollingRect
This commit is contained in:
172
main.cpp
172
main.cpp
@@ -37,27 +37,36 @@ JUI::Scene* CreateScene() {
|
||||
|
||||
Scene *root = new Scene();
|
||||
|
||||
auto* nineslice_demo_window = new JUI::Window(root);
|
||||
nineslice_demo_window->CornerRounding(5);
|
||||
nineslice_demo_window->Size({50_percent, 50_percent});
|
||||
nineslice_demo_window->SetTitle("9-Slice Demo");
|
||||
nineslice_demo_window->Visible(false);
|
||||
|
||||
|
||||
auto* topbar = new UtilityBar(root);
|
||||
topbar->ZIndex(3);
|
||||
auto* file = topbar->AddButton("File");
|
||||
file->SetTooltip("This Dick Nigga", 0.5f);
|
||||
auto* file = topbar->AddButton("Demos");
|
||||
|
||||
file->OnClickEvent += [&, root, file] (Vector2 pos, JUI::MouseButton btn)
|
||||
auto* file_tt = new JUI::Tooltip(file);
|
||||
file_tt->SetContent("Tooltip");
|
||||
|
||||
file->OnClickEvent += [&, root, nineslice_demo_window] (Vector2 pos, JUI::MouseButton btn)
|
||||
{
|
||||
auto* ctx_menu = new ContextMenu(root);
|
||||
ctx_menu->Position(UDim2(0,20,0,0));
|
||||
ctx_menu->AddItem("A");
|
||||
ctx_menu->AddItem("B");
|
||||
ctx_menu->AddItem("c");
|
||||
ctx_menu->ZIndex(3);
|
||||
auto* open_nineslice = ctx_menu->AddItem("9-Slice Widget Demo");
|
||||
|
||||
ctx_menu->MouseExit += [ctx_menu] (Vector2 _)
|
||||
{
|
||||
ctx_menu->Visible(false);
|
||||
ctx_menu->Parent(nullptr);
|
||||
// TODO: Collect
|
||||
open_nineslice->OnClickEvent += [&, nineslice_demo_window] (Vector2 pos, JUI::MouseButton btn) {
|
||||
nineslice_demo_window->Visible(true);
|
||||
};
|
||||
|
||||
auto* open_scroll = ctx_menu->AddItem("Scroll Widget Demo");
|
||||
|
||||
open_scroll->OnClickEvent += [&] (Vector2 pos, JUI::MouseButton btn) {};
|
||||
ctx_menu->AddItem("");
|
||||
ctx_menu->ZIndex(3);
|
||||
|
||||
};
|
||||
|
||||
topbar->AddButton("Edit");
|
||||
@@ -84,6 +93,9 @@ JUI::Scene* CreateScene() {
|
||||
button->AlignLeft();
|
||||
button->Padding(5_px);
|
||||
|
||||
auto* tt2 = new JUI::Tooltip(button);
|
||||
tt2->SetContent("Test 123");
|
||||
|
||||
auto* button2 = new TextButton(s1_vert);
|
||||
//button2->Position({5, 105, 0, 0});
|
||||
button2->Size({0, 35, 1, 0});
|
||||
@@ -112,127 +124,25 @@ JUI::Scene* CreateScene() {
|
||||
input_form->SetTextSize(14);
|
||||
|
||||
|
||||
//auto* main_wnd = new Window(root);
|
||||
//auto* left = new HorizontalListLayout();
|
||||
|
||||
auto* other_window = new JUI::Window(root);
|
||||
other_window->Position({10_percent, 10_percent});
|
||||
other_window->Size({30_percent, 25_percent});
|
||||
other_window->SetTitle("Another Window");
|
||||
|
||||
|
||||
//auto* btn = new TextButton(root);
|
||||
auto* scroller = new JUI::ScrollingRect(other_window->GetViewportInstance());
|
||||
scroller->Size({100_percent, 100_percent});
|
||||
scroller->BGColor(Colors::Reds::LightCoral);
|
||||
|
||||
|
||||
/*
|
||||
auto* JUI = new TextRect(root);
|
||||
JUI->SetClipsDescendants(true);
|
||||
JUI->SetFont(FreeSans);
|
||||
JUI->SetTextSize(48);
|
||||
JUI->SetTextColor({32, 48, 192});
|
||||
JUI->SetContent("Josh User Interface");
|
||||
JUI->AlignBottom();
|
||||
JUI->AlignCenterHorizontally();
|
||||
JUI->AnchorPoint(Vector2(0.5f, 0.5f));
|
||||
JUI->Position({50_percent, 50_percent});
|
||||
//JUI->Size({30_percent, 10_percent});
|
||||
JUI->FitText(true);
|
||||
JUI->Padding(20_px);
|
||||
JUI->BGColor({64, 64, 64, 128});
|
||||
JUI->SetBorderWidth(2);
|
||||
JUI->BorderColor({255, 255, 255, 128});
|
||||
auto* Redacted = new TextRect(root);
|
||||
Redacted->SetFont(FreeSans);
|
||||
Redacted->SetTextSize(32);
|
||||
Redacted->SetTextColor({255, 255, 255});
|
||||
Redacted->SetContent("Redacted Software Group");
|
||||
Redacted->Position({50_percent, 60_percent});
|
||||
//Redacted->Size({30_percent, 10_percent});
|
||||
Redacted->AlignCenterHorizontally();
|
||||
Redacted->AlignTop();
|
||||
Redacted->AnchorPoint(Vector2(0.5f, .5f));
|
||||
Redacted->FitText(true);
|
||||
Redacted->Padding(10_px);
|
||||
Redacted->BGColor({32, 48, 192});
|
||||
Redacted->SetBorderWidth(1);
|
||||
Redacted->BorderColor({64, 64, 64});
|
||||
|
||||
|
||||
//auto* scrollRect = new ScrollingRect(root);
|
||||
|
||||
|
||||
// Rect //
|
||||
Rect *rect_element = new Rect(root);
|
||||
rect_element->Name("JimBob");
|
||||
|
||||
//Rect* element = new Rect(root);
|
||||
|
||||
//rect_element->Name("JimBob");
|
||||
//element->BGColor({0,255,0});
|
||||
rect_element->BGColor({0, 64, 0});
|
||||
rect_element->Size({0, 0, 0.1f, 0.2f});
|
||||
rect_element->SetClipsDescendants(true);
|
||||
rect_element->BorderColor({255, 255, 255});
|
||||
rect_element->SetBorderWidth(2.f);
|
||||
|
||||
rect_element->MouseEnter += [rect_element](auto coords) {
|
||||
|
||||
rect_element->BGColor({0, 128, 0});
|
||||
};
|
||||
|
||||
rect_element->MouseExit += [rect_element](auto coords) {
|
||||
rect_element->BGColor({0, 64, 0});
|
||||
};
|
||||
|
||||
// End Rect //
|
||||
|
||||
Slider* slide = new Slider(root);
|
||||
slide->Size({200, 40, 0, 0});
|
||||
slide->BGColor({255, 255, 0});
|
||||
slide->Position({0, 0, 0.125, 0.125});
|
||||
|
||||
// Button //
|
||||
Button *button_element = new Button(root);
|
||||
button_element->Name("BobJim");
|
||||
button_element->BaseBGColor({64, 0, 64});
|
||||
button_element->PressedBGColor({0, 64, 64});
|
||||
button_element->Size({0, 0, 0.1f, 0.1f});
|
||||
button_element->Position({0,0,0.25f,0.25f});
|
||||
//button_element->SetClipsDescendants(true);
|
||||
button_element->BaseBorderColor({255, 255, 255});
|
||||
button_element->SetBorderWidth(2.f);
|
||||
|
||||
auto bpos = rect_element->Size();
|
||||
|
||||
//exit(1);
|
||||
//button_element->Position(
|
||||
// {bpos.X.Pixels, bpos.Y.Pixels, bpos.X.Scale - 0.2f, 0}); // I don't know how to use sx and sy - maxine
|
||||
//button_element->OnToggleOnEvent += [rect_element] () {
|
||||
// rect_element->BGColor({64, 0, 0});
|
||||
//};
|
||||
//button_element->OnToggleOffEvent += [rect_element] () {
|
||||
// rect_element->BGColor({0, 64, 0});
|
||||
//};
|
||||
//button_element->OnToggleEvent += [button_element] () {
|
||||
// Color4 incbg = button_element->BGColor();
|
||||
// Once an overflow occurs it will reset anyway
|
||||
// Thanks computer science
|
||||
// if (incbg.b < 255)
|
||||
// incbg.b += 10;
|
||||
// button_element->BGColor(incbg);
|
||||
//};
|
||||
Text* btntext = new Text(button_element);
|
||||
btntext->SetContent("I AM BUTTON");
|
||||
btntext->SetFont(FreeSans);
|
||||
btntext->SetTextSize(8);
|
||||
btntext->SetTextColor({255, 0, 0});
|
||||
// End Button //
|
||||
*/
|
||||
// Window //
|
||||
auto* win_element = new JUI::Window(root);
|
||||
win_element->CornerRounding(5);
|
||||
win_element->Size({50_percent, 50_percent});
|
||||
win_element->SetTitle("Window Widget");
|
||||
//win_element->Padding(1_px);
|
||||
//nineslice_demo_window->Padding(1_px);
|
||||
// End Window //
|
||||
|
||||
|
||||
auto* nineslice = new JUI::NineSliceRect(win_element);
|
||||
auto* nineslice = new JUI::NineSliceRect(nineslice_demo_window);
|
||||
nineslice->Content(slicer);
|
||||
nineslice->Size({100_percent, 100_percent});
|
||||
nineslice->BGColor(Colors::Transparent);
|
||||
@@ -249,11 +159,11 @@ JUI::Scene* CreateScene() {
|
||||
nineslice->CenterQuad({{96, 96}, {384-(96*2), 378-(96*2)}});
|
||||
|
||||
|
||||
auto darkie = new JUI::Image(win_element->GetViewportInstance(), sample_texture);
|
||||
auto darkie = new JUI::Image(nineslice_demo_window->GetViewportInstance(), sample_texture);
|
||||
darkie->FitImageToParent(true);
|
||||
darkie->Color({255,255,255,128});
|
||||
|
||||
auto list = new VerticalListLayout(win_element->GetViewportInstance());
|
||||
auto list = new VerticalListLayout(nineslice_demo_window->GetViewportInstance());
|
||||
list->Padding(10_px);
|
||||
|
||||
|
||||
@@ -283,7 +193,7 @@ public:
|
||||
|
||||
void initGL() {
|
||||
auto size = GetSize();
|
||||
auto vec_size = Vector2(size.x, size.y);
|
||||
auto vec_size = Vector2i(size.x, size.y);
|
||||
bool result = JGL::Init(vec_size, 0.f, 0.f);
|
||||
JGL::Update(vec_size);
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
@@ -306,9 +216,9 @@ public:
|
||||
void OnRefresh(float elapsed) override {
|
||||
Update(elapsed);
|
||||
auto size = GetSize();
|
||||
Vector2 vSize = Vector2(size.x, size.y);
|
||||
Vector2i vSize = Vector2i(size.x, size.y);
|
||||
JGL::Update(vSize);
|
||||
scene->SetViewportSize(vSize);
|
||||
scene->SetViewportSize(Vector2(vSize));
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
@@ -373,8 +283,8 @@ int main()
|
||||
|
||||
|
||||
window->OnResizeRequestEvent += [&] (ReWindow::WindowResizeRequestEvent e){
|
||||
Vector2 size = Vector2(e.Size.x, e.Size.y);//window->getLastKnownResize();
|
||||
scene->SetViewportSize(size);
|
||||
Vector2i size = Vector2i(e.Size.x, e.Size.y);//window->getLastKnownResize();
|
||||
scene->SetViewportSize(Vector2(size));
|
||||
std::cout << size.x << "," << size.y << std::endl;
|
||||
JGL::Update(size);
|
||||
};
|
||||
|
Reference in New Issue
Block a user