Skip to content

Commit 162ecf4

Browse files
committed
touch test app: improve list page
1 parent 1470c88 commit 162ecf4

4 files changed

Lines changed: 66 additions & 4 deletions

File tree

src/ruis/widget/base/touch/flickable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2727
using namespace ruis::touch;
2828

2929
namespace {
30-
constexpr auto friction_coefficient = 0.005;
30+
constexpr auto friction_coefficient = 0.001;
3131
} // namespace
3232

3333
flickable::flickable(utki::shared_ref<ruis::context> context) :

src/ruis/widget/group/touch/list.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ list::list(utki::shared_ref<ruis::context> context, all_parameters params) :
3030
std::move(params.widget_params)
3131
),
3232
ruis::list(this->context, std::move(params)),
33-
flickable(this->context)
33+
flickable(this->context)
3434
{}
3535

3636
ruis::event_status list::on_mouse_button(const mouse_button_event& event)

src/ruis/widget/label/padding.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class padding :
3636
{
3737
public:
3838
struct parameters {
39-
sides<length> borders;
39+
sides<length> borders; // TODO: make sides<styled<length>>
4040
};
4141

4242
private:

tests/touch/src/list_page.cpp

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2222
#include "list_page.hpp"
2323

2424
#include <ruis/widget/group/touch/list.hpp>
25+
#include <ruis/widget/label/gap.hpp>
26+
#include <ruis/widget/label/padding.hpp>
2527
#include <ruis/widget/label/text.hpp>
28+
#include <utki/string.hpp>
29+
#include <utki/unicode.hpp>
2630

2731
#include "style.hpp"
2832

@@ -43,7 +47,65 @@ class list_page_provider : public ruis::list_provider
4347

4448
utki::shared_ref<ruis::widget> get_widget(size_t index) override
4549
{
46-
return m::text(this->context, {}, U"Hello world!"s);
50+
// clang-format off
51+
auto button = m::push_button(this->context,
52+
{
53+
.layout_params{
54+
.dims = {ruis::dim::min, ruis::length::make_pp(30)}
55+
}
56+
},
57+
{
58+
m::text(this->context, {}, U"Button"s)
59+
}
60+
);
61+
// clang-format on
62+
63+
button.get().click_handler = [index](auto& btn) {
64+
std::cout << "Item #" << index << " button cliecked" << std::endl;
65+
};
66+
67+
// clang-format off
68+
return m::column(this->context,
69+
{
70+
.layout_params{
71+
.dims = {ruis::dim::fill, ruis::dim::min}
72+
}
73+
},
74+
{
75+
m::padding(this->context,
76+
{
77+
.container_params{
78+
.layout = ruis::layout::row
79+
},
80+
.padding_params{
81+
.borders = {ruis::length::make_pp(3)}
82+
}
83+
},
84+
{
85+
m::text(this->context, {}, utki::to_utf32(utki::cat("Item #", index))),
86+
m::gap(this->context,
87+
{
88+
.layout_params{
89+
.dims = {ruis::length::make_pp(5), ruis::dim::min}
90+
}
91+
}
92+
),
93+
std::move(button)
94+
}
95+
),
96+
m::gap(this->context,
97+
{
98+
.layout_params{
99+
.dims = {ruis::dim::fill, ruis::length::make_pp(1)}
100+
},
101+
.color_params{
102+
.color = 0xff808080
103+
}
104+
}
105+
)
106+
}
107+
);
108+
// clang-format on
47109
}
48110
};
49111
} // namespace

0 commit comments

Comments
 (0)