Skip to content

Commit c730d79

Browse files
committed
tests update
1 parent f130117 commit c730d79

File tree

16 files changed

+198
-129
lines changed

16 files changed

+198
-129
lines changed

tests/align/src/main.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,18 +312,27 @@ utki::shared_ref<ruis::container> make_layout(utki::shared_ref<ruis::context> c)
312312
}
313313

314314
class application : public ruisapp::application{
315+
ruisapp::window& window;
315316
public:
316317
application() :
317318
ruisapp::application(
318-
"ruis-tests",
319+
{
320+
.name = "ruis-tests"
321+
}
322+
),
323+
window(this->make_window(
319324
{
320325
.dims = {1024, 800}
321326
}
322-
)
327+
))
323328
{
324-
this->gui.init_standard_widgets(*this->get_res_file("../../res/ruis_res/"));
329+
this->window.gui.init_standard_widgets(*this->get_res_file("../../res/ruis_res/"));
330+
331+
this->window.gui.set_root(make_layout(this->window.gui.context));
325332

326-
this->gui.set_root(make_layout(this->gui.context));
333+
this->window.gui.context.get().window().close_handler = [this](){
334+
this->quit();
335+
};
327336
}
328337
};
329338

tests/app2/src/application.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include "application.hpp"
2+
3+
#include <ruis/widget/proxy/key_proxy.hpp>
4+
#include <ruisapp/application.hpp>
5+
6+
#include "gui.hpp"
7+
8+
application::application() :
9+
ruisapp::application({
10+
.name = "ruis-tests"
11+
}),
12+
window(this->make_window({.dims = {1024, 800}}))
13+
{
14+
this->window.gui.init_standard_widgets(*this->get_res_file("../../res/ruis_res/"));
15+
16+
this->window.gui.context.get().localization.get() =
17+
ruis::localization(tml::read(*this->get_res_file("res/localization/en.tml")));
18+
19+
this->window.gui.context.get().loader().mount_res_pack(*this->get_res_file("res/"));
20+
21+
// clang-format off
22+
auto kp = ruis::make::key_proxy(
23+
this->window.gui.context,
24+
{
25+
.container_params{
26+
.layout = ruis::layout::pile
27+
}
28+
},
29+
{
30+
make_root_widgets_structure(this->window.gui.context)
31+
}
32+
);
33+
// clang-format on
34+
35+
kp.get().key_handler = [this](ruis::key_proxy&, const ruis::key_event& e) -> bool {
36+
if (e.is_down) {
37+
if (e.combo.key == ruis::key::escape) {
38+
this->quit();
39+
}
40+
}
41+
return false;
42+
};
43+
44+
this->window.gui.set_root(std::move(kp));
45+
}

tests/app2/src/application.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#pragma once
2+
3+
#include <ruisapp/application.hpp>
4+
5+
class application : public ruisapp::application
6+
{
7+
public:
8+
ruisapp::window& window;
9+
10+
application();
11+
12+
static application& inst()
13+
{
14+
return static_cast<application&>(ruisapp::inst());
15+
}
16+
};

tests/app2/src/gui.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <ruis/widget/slider/slider.hpp>
1515
#include <ruisapp/application.hpp>
1616

17+
#include "application.hpp"
1718
#include "rectangles_window.hpp"
1819
#include "table_list_window.hpp"
1920
#include "table_tree_view_window.hpp"
@@ -301,13 +302,13 @@ utki::shared_ref<ruis::window> make_selection_box_window(
301302
ASSERT(sel < language_id_to_name_mapping.size())
302303

303304
sb.context.get().post_to_ui_thread([lng = language_id_to_name_mapping.at(sel).first]() {
304-
auto& app = ruisapp::inst();
305+
auto& app = application::inst();
305306

306307
// std::cout << "new localization = " << lng << std::endl;
307308

308-
app.gui.context.get().localization.get() =
309+
app.window.gui.context.get().localization.get() =
309310
ruis::localization(tml::read(*app.get_res_file(utki::cat("res/localization/", lng, ".tml"))));
310-
app.gui.get_root().reload();
311+
app.window.gui.get_root().reload();
311312
});
312313
};
313314

tests/app2/src/main.cpp

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,4 @@
1-
#include <ruis/widget/proxy/key_proxy.hpp>
2-
#include <ruisapp/application.hpp>
3-
4-
#include "gui.hpp"
5-
6-
class application : public ruisapp::application
7-
{
8-
public:
9-
application() :
10-
ruisapp::application(
11-
"ruis-tests",
12-
{
13-
.dims = {1024, 800}
14-
}
15-
)
16-
{
17-
this->gui.init_standard_widgets(*this->get_res_file("../../res/ruis_res/"));
18-
19-
this->gui.context.get().localization.get() =
20-
ruis::localization(tml::read(*this->get_res_file("res/localization/en.tml")));
21-
22-
this->gui.context.get().loader().mount_res_pack(*this->get_res_file("res/"));
23-
24-
// clang-format off
25-
auto kp = ruis::make::key_proxy(
26-
this->gui.context,
27-
{
28-
.container_params{
29-
.layout = ruis::layout::pile
30-
}
31-
},
32-
{
33-
make_root_widgets_structure(this->gui.context)
34-
}
35-
);
36-
// clang-format on
37-
38-
kp.get().key_handler = [this](ruis::key_proxy&, const ruis::key_event& e) -> bool {
39-
if (e.is_down) {
40-
if (e.combo.key == ruis::key::escape) {
41-
this->quit();
42-
}
43-
}
44-
return false;
45-
};
46-
47-
this->gui.set_root(std::move(kp));
48-
}
49-
};
1+
#include "application.hpp"
502

513
const ruisapp::application_factory app_fac([](auto executable, auto args) {
524
return std::make_unique<::application>();

tests/aspect_ratio_proxy/src/main.cpp

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,33 @@ using namespace ruis::make;
1414
}
1515

1616
class application : public ruisapp::application{
17+
ruisapp::window& window;
1718
public:
1819
application() :
19-
ruisapp::application(
20-
"ruis-tests",
21-
{
20+
ruisapp::application({
21+
.name = "ruis-tests"}
22+
),
23+
window(this->make_window({
2224
.dims = {1024, 800}
23-
}
24-
)
25+
}))
2526
{
26-
this->gui.init_standard_widgets(*this->get_res_file("../../res/ruis_res/"));
27+
this->window.gui.context.get().window().close_handler = [this](){
28+
this->quit();
29+
};
30+
31+
this->window.gui.init_standard_widgets(*this->get_res_file("../../res/ruis_res/"));
32+
33+
auto ctx = this->window.gui.context;
2734

2835
// clang-format off
29-
auto c = m::container(this->gui.context,
36+
auto c = m::container(ctx,
3037
{
3138
.container_params{
3239
.layout = ruis::layout::trivial
3340
}
3441
},
3542
{
36-
m::window(this->gui.context,
43+
m::window(ctx,
3744
{
3845
.widget_params{
3946
.rectangle = {{200, 200}, {200, 100}}
@@ -44,14 +51,14 @@ class application : public ruisapp::application{
4451
.title = U"aspect ratio proxy"s
4552
},
4653
{
47-
m::pile(this->gui.context,
54+
m::pile(ctx,
4855
{
4956
.layout_params{
5057
.dims = {ruis::dim::min, ruis::dim::fill}
5158
}
5259
},
5360
{
54-
m::aspect_ratio_proxy(this->gui.context,
61+
m::aspect_ratio_proxy(ctx,
5562
{
5663
.layout_params{
5764
.dims = {ruis::dim::min, ruis::dim::fill}
@@ -61,7 +68,7 @@ class application : public ruisapp::application{
6168
}
6269
}
6370
),
64-
m::rectangle(this->gui.context,
71+
m::rectangle(ctx,
6572
{
6673
.layout_params{
6774
.dims = {ruis::dim::fill, ruis::dim::fill}
@@ -71,7 +78,7 @@ class application : public ruisapp::application{
7178
}
7279
}
7380
),
74-
m::text(this->gui.context,
81+
m::text(ctx,
7582
{},
7683
U"1:2"s
7784
)
@@ -83,7 +90,7 @@ class application : public ruisapp::application{
8390
);
8491
// clang-format on
8592

86-
this->gui.set_root(c);
93+
this->window.gui.set_root(c);
8794
}
8895
};
8996

tests/book/src/main.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,33 @@ namespace m{
2424
}
2525

2626
class application : public ruisapp::application{
27+
ruisapp::window& window;
2728
public:
2829
application() :
29-
ruisapp::application(
30-
"ruis-tests",
30+
ruisapp::application({
31+
.name = "ruis-tests"
32+
}),
33+
window(this->make_window(
3134
{
3235
.dims = {640, 480}
3336
}
34-
)
37+
))
3538
{
36-
this->gui.init_standard_widgets(*this->get_res_file("../../res/ruis_res/"));
39+
this->window.gui.context.get().window().close_handler = [this](){
40+
this->quit();
41+
};
3742

38-
this->gui.context.get().loader().mount_res_pack(*this->get_res_file("res/"));
43+
this->window.gui.init_standard_widgets(*this->get_res_file("../../res/ruis_res/"));
44+
45+
this->window.gui.context.get().loader().mount_res_pack(*this->get_res_file("res/"));
46+
47+
auto& ctx = this->window.gui.context;
3948

4049
// clang-format off
41-
auto c = m::column(this->gui.context,
50+
auto c = m::column(ctx,
4251
{},
4352
{
44-
m::book(this->gui.context,
53+
m::book(ctx,
4554
{
4655
.layout_params{
4756
.dims = {ruis::dim::fill, ruis::dim::max},
@@ -56,12 +65,12 @@ class application : public ruisapp::application{
5665
);
5766
// clang-format on
5867

59-
this->gui.set_root(c);
68+
this->window.gui.set_root(c);
6069

6170
auto& book = c.get().get_widget_as<ruis::book>("book");
6271

6372
{
64-
auto mp = make_main_page(this->gui.context);
73+
auto mp = make_main_page(ctx);
6574

6675
mp.get().get_widget_as<ruis::push_button>("cube_button").click_handler = [&mp = mp.get()](ruis::push_button& b){
6776
mp.get_parent_book()->push(utki::make_shared<cube_page>(mp.context));

tests/busy/src/main.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,25 @@
1010
#include "root_gui.hpp"
1111

1212
class application : public ruisapp::application{
13+
ruisapp::window& window;
1314
public:
1415
application() :
1516
ruisapp::application(
16-
"ruis-tests",
1717
{
18+
.name = "ruis-tests"}
19+
),
20+
window(this->make_window({
1821
.dims = {1024, 800}
19-
}
20-
)
22+
}))
2123
{
22-
this->gui.init_standard_widgets(*this->get_res_file("../../res/ruis_res/"));
24+
this->window.gui.context.get().window().close_handler = [this](){
25+
this->quit();
26+
};
27+
28+
this->window.gui.init_standard_widgets(*this->get_res_file("../../res/ruis_res/"));
2329

24-
auto c = make_root_gui(this->gui.context);
25-
this->gui.set_root(c);
30+
auto c = make_root_gui(this->window.gui.context);
31+
this->window.gui.set_root(c);
2632

2733
{
2834
auto spinner = utki::make_weak_from(

tests/easing/src/main.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@
55

66
class application : public ruisapp::application
77
{
8+
ruisapp::window& window;
9+
810
public:
911
application() :
10-
ruisapp::application(
11-
"ruis-tests",
12-
{
13-
.dims = {1024, 800}
14-
}
15-
)
12+
ruisapp::application({
13+
.name = "ruis-tests",
14+
}),
15+
window(this->make_window({.dims = {1024, 800}}))
1616
{
17-
this->gui.init_standard_widgets(*this->get_res_file("../../res/ruis_res/"));
17+
this->window.gui.init_standard_widgets(*this->get_res_file("../../res/ruis_res/"));
1818

1919
// this->gui.context.get().loader.mount_res_pack(*this->get_res_file("res/"));
2020

2121
auto kp = ruis::make::key_proxy(
22-
this->gui.context,
22+
this->window.gui.context,
2323
{.container_params = {.layout = ruis::layout::pile}},
24-
{make_gui(this->gui.context)}
24+
{make_gui(this->window.gui.context)}
2525
);
2626

2727
kp.get().key_handler = [this](ruis::key_proxy&, const ruis::key_event& e) -> bool {
@@ -33,7 +33,11 @@ class application : public ruisapp::application
3333
return false;
3434
};
3535

36-
this->gui.set_root(std::move(kp));
36+
this->window.gui.set_root(std::move(kp));
37+
38+
this->window.gui.context.get().window().close_handler = [this]() {
39+
this->quit();
40+
};
3741
}
3842
};
3943

0 commit comments

Comments
 (0)