Skip to content

Commit b686595

Browse files
committed
fix build
1 parent f9ab97c commit b686595

File tree

6 files changed

+45
-22
lines changed

6 files changed

+45
-22
lines changed

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

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2626

2727
using namespace ruis::touch;
2828

29+
flickable::flickable(utki::shared_ref<ruis::context> context) :
30+
friction(context.get().units.dots_per_pp() * 0.005)
31+
{}
32+
2933
ruis::event_status flickable::on_mouse_button(const mouse_button_event& event)
3034
{
3135
if (event.button != mouse_button::left) {
@@ -161,17 +165,14 @@ ruis::event_status flickable::on_mouse_move(const mouse_move_event& event)
161165
}();
162166

163167
// move the cursor out of any widget to update hovered states
164-
this->flickable_on_mouse_move({
165-
.pos = pos,
166-
.pointer_id = this->cur_pointer_id
167-
});
168-
169-
this->flickable_on_mouse_button({
170-
.action = button_action::release,
171-
.pos = pos,
172-
.button = mouse_button::left,
173-
.pointer_id = this->cur_pointer_id
174-
});
168+
this->flickable_on_mouse_move({.pos = pos, .pointer_id = this->cur_pointer_id});
169+
170+
this->flickable_on_mouse_button(
171+
{.action = button_action::release,
172+
.pos = pos,
173+
.button = mouse_button::left,
174+
.pointer_id = this->cur_pointer_id}
175+
);
175176
}
176177

177178
this->flickable_scroll_by(-delta);
@@ -199,7 +200,9 @@ void flickable::update(uint32_t dt_ms)
199200
auto scrolled_by = this->flickable_scroll_by(-this->velocity_px_per_ms * ruis::real(dt_ms));
200201

201202
using std::copysign;
202-
auto velocity_sign = this->velocity_px_per_ms.comp_op([](const auto& e){return copysign(real(1), e);});
203+
auto velocity_sign = this->velocity_px_per_ms.comp_op([](const auto& e) {
204+
return copysign(real(1), e);
205+
});
203206

204207
auto prev_velocity_px_per_ms = this->velocity_px_per_ms;
205208

@@ -210,14 +213,16 @@ void flickable::update(uint32_t dt_ms)
210213

211214
// std::cout << "this->velocity_px_per_ms = " << this->velocity_px_per_ms << std::endl;
212215

213-
for(auto [prev, cur, scrolled_px] : utki::views::zip(prev_velocity_px_per_ms, this->velocity_px_per_ms, scrolled_by)){
216+
for (auto [prev, cur, scrolled_px] :
217+
utki::views::zip(prev_velocity_px_per_ms, this->velocity_px_per_ms, scrolled_by))
218+
{
214219
using std::signbit;
215-
if(signbit(prev) != signbit(cur) || scrolled_px == 0){
220+
if (signbit(prev) != signbit(cur) || scrolled_px == 0) {
216221
cur = ruis::real(0);
217222
}
218223
}
219224

220-
if(this->velocity_px_per_ms.is_zero()){
225+
if (this->velocity_px_per_ms.is_zero()) {
221226
this->context.get().updater.get().stop(*this);
222227
this->cur_state = state::idle;
223228
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,16 @@ class flickable :
6363
ruis::vec2 calculate_touch_velocity_for_at_least_3_points_using_ols_method_px_per_ms();
6464

6565
// inertial scrolling state
66-
ruis::real friction = this->context.get().units.dots_per_pp() * 0.005; // TODO: update if dots per pp changes
66+
ruis::real friction; // TODO: update if dots per pp changes
6767
ruis::vec2 velocity_px_per_ms;
6868

6969
public:
7070
event_status on_mouse_button(const mouse_button_event& event) override;
7171
event_status on_mouse_move(const mouse_move_event& event) override;
7272

7373
protected:
74+
flickable(utki::shared_ref<ruis::context> context);
75+
7476
// TODO: doxygen
7577
virtual event_status flickable_on_mouse_button(const mouse_button_event& event) = 0;
7678
virtual event_status flickable_on_mouse_move(const mouse_move_event& event) = 0;

src/ruis/widget/button/push_button.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ event_status push_button::on_mouse_button(const mouse_button_event& e)
5757
if (this->pointer_id == e.pointer_id) {
5858
// released the same pointer which has pressed the button before
5959

60-
std::cout << "push_button: released" << std::endl;
60+
// std::cout << "push_button: released" << std::endl;
6161

6262
this->set_pressed(false);
6363
}

src/ruis/widget/container.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,12 @@ void container::on_hovered_change(unsigned pointer_id)
263263
}
264264

265265
// the container has just became unhovered
266-
utki::assert([&](){return !this->is_hovered(pointer_id);}, SL);
266+
utki::assert(
267+
[&]() {
268+
return !this->is_hovered(pointer_id);
269+
},
270+
SL
271+
);
267272

268273
// unhover all the children
269274
blocked_flag_guard blocked_guard(this->is_blocked);

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ scroll_area::scroll_area(
3838
this->context,
3939
{},
4040
std::move(children)
41-
)
42-
// clang-format on
41+
),
42+
// clang-format on
43+
flickable(this->context)
4344
{}
4445

4546
ruis::event_status scroll_area::on_mouse_button(const mouse_button_event& event)

src/ruis/widget/widget.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,10 +442,20 @@ void widget::set_hovered(bool is_hovered, unsigned pointer_id)
442442
// TRACE(<< "widget::setHovered(): isHovered = " << isHovered << " this->name() = " << this->name() << std::endl)
443443

444444
if (is_hovered) {
445-
utki::assert([&](){return !this->is_hovered(pointer_id);}, SL);
445+
utki::assert(
446+
[&]() {
447+
return !this->is_hovered(pointer_id);
448+
},
449+
SL
450+
);
446451
this->hovered.insert(pointer_id);
447452
} else {
448-
utki::assert([&](){return this->is_hovered(pointer_id);}, SL);
453+
utki::assert(
454+
[&]() {
455+
return this->is_hovered(pointer_id);
456+
},
457+
SL
458+
);
449459
this->hovered.erase(pointer_id);
450460
}
451461

0 commit comments

Comments
 (0)