@@ -237,8 +237,8 @@ void ScrollBar::paint_event(PaintEvent& event)
237
237
238
238
painter.fill_rect_with_dither_pattern (rect (), palette ().button ().lightened (1 .3f ), palette ().button ());
239
239
240
- bool decrement_pressed = m_automatic_scrolling_kind == AutomaticScrollingKind ::DecrementButton;
241
- bool increment_pressed = m_automatic_scrolling_kind == AutomaticScrollingKind ::IncrementButton;
240
+ bool decrement_pressed = m_pressed_component == Component ::DecrementButton;
241
+ bool increment_pressed = m_pressed_component == Component ::IncrementButton;
242
242
243
243
Gfx::StylePainter::paint_button (painter, decrement_button_rect (), palette (), Gfx::ButtonStyle::Normal, decrement_pressed, m_hovered_component == Component::DecrementButton);
244
244
Gfx::StylePainter::paint_button (painter, increment_button_rect (), palette (), Gfx::ButtonStyle::Normal, increment_pressed, m_hovered_component == Component::IncrementButton);
@@ -256,20 +256,20 @@ void ScrollBar::paint_event(PaintEvent& event)
256
256
}
257
257
258
258
if (has_scrubber ())
259
- Gfx::StylePainter::paint_button (painter, scrubber_rect (), palette (), Gfx::ButtonStyle::Normal, false , m_hovered_component == Component::Scrubber || m_scrubber_in_use );
259
+ Gfx::StylePainter::paint_button (painter, scrubber_rect (), palette (), Gfx::ButtonStyle::Normal, false , m_hovered_component == Component::Scrubber || m_pressed_component == Component::Scrubber );
260
260
}
261
261
262
262
void ScrollBar::on_automatic_scrolling_timer_fired ()
263
263
{
264
- if (m_automatic_scrolling_kind == AutomaticScrollingKind ::DecrementButton && component_at_position (m_last_mouse_position) == Component::DecrementButton) {
264
+ if (m_pressed_component == Component ::DecrementButton && component_at_position (m_last_mouse_position) == Component::DecrementButton) {
265
265
set_value (value () - m_step);
266
266
return ;
267
267
}
268
- if (m_automatic_scrolling_kind == AutomaticScrollingKind ::IncrementButton && component_at_position (m_last_mouse_position) == Component::IncrementButton) {
268
+ if (m_pressed_component == Component ::IncrementButton && component_at_position (m_last_mouse_position) == Component::IncrementButton) {
269
269
set_value (value () + m_step);
270
270
return ;
271
271
}
272
- if (m_automatic_scrolling_kind == AutomaticScrollingKind ::Gutter && component_at_position (m_last_mouse_position) == Component::Gutter) {
272
+ if (m_pressed_component == Component ::Gutter && component_at_position (m_last_mouse_position) == Component::Gutter) {
273
273
scroll_by_page (m_last_mouse_position);
274
274
return ;
275
275
}
@@ -283,46 +283,42 @@ void ScrollBar::mousedown_event(MouseEvent& event)
283
283
return ;
284
284
285
285
m_last_mouse_position = event.position ();
286
- Component clicked_component = component_at_position (m_last_mouse_position);
286
+ m_pressed_component = component_at_position (m_last_mouse_position);
287
287
288
- if (clicked_component == Component::DecrementButton) {
289
- set_automatic_scrolling_active (true , AutomaticScrollingKind ::DecrementButton);
288
+ if (m_pressed_component == Component::DecrementButton) {
289
+ set_automatic_scrolling_active (true , Component ::DecrementButton);
290
290
update ();
291
291
return ;
292
292
}
293
- if (clicked_component == Component::IncrementButton) {
294
- set_automatic_scrolling_active (true , AutomaticScrollingKind ::IncrementButton);
293
+ if (m_pressed_component == Component::IncrementButton) {
294
+ set_automatic_scrolling_active (true , Component ::IncrementButton);
295
295
update ();
296
296
return ;
297
297
}
298
298
299
299
if (event.shift ()) {
300
300
scroll_to_position (event.position ());
301
- clicked_component = component_at_position (event.position ());
302
- ASSERT (clicked_component == Component::Scrubber);
301
+ m_pressed_component = component_at_position (event.position ());
302
+ ASSERT (m_pressed_component == Component::Scrubber);
303
303
}
304
- if (clicked_component == Component::Scrubber) {
305
- m_scrubber_in_use = true ;
306
- m_scrubbing = true ;
304
+ if (m_pressed_component == Component::Scrubber) {
307
305
m_scrub_start_value = value ();
308
306
m_scrub_origin = event.position ();
309
307
update ();
310
308
return ;
311
309
}
312
310
ASSERT (!event.shift ());
313
311
314
- ASSERT (clicked_component == Component::Gutter);
315
- set_automatic_scrolling_active (true , AutomaticScrollingKind ::Gutter);
312
+ ASSERT (m_pressed_component == Component::Gutter);
313
+ set_automatic_scrolling_active (true , Component ::Gutter);
316
314
update ();
317
315
}
318
316
319
317
void ScrollBar::mouseup_event (MouseEvent& event)
320
318
{
321
319
if (event.button () != MouseButton::Left)
322
320
return ;
323
- m_scrubber_in_use = false ;
324
- set_automatic_scrolling_active (false , AutomaticScrollingKind::None);
325
- m_scrubbing = false ;
321
+ set_automatic_scrolling_active (false , Component::None);
326
322
update ();
327
323
}
328
324
@@ -334,10 +330,10 @@ void ScrollBar::mousewheel_event(MouseEvent& event)
334
330
Widget::mousewheel_event (event);
335
331
}
336
332
337
- void ScrollBar::set_automatic_scrolling_active (bool active, AutomaticScrollingKind kind )
333
+ void ScrollBar::set_automatic_scrolling_active (bool active, Component pressed_component )
338
334
{
339
- m_automatic_scrolling_kind = kind ;
340
- if (m_automatic_scrolling_kind == AutomaticScrollingKind ::Gutter)
335
+ m_pressed_component = pressed_component ;
336
+ if (m_pressed_component == Component ::Gutter)
341
337
m_automatic_scrolling_timer->set_interval (200 );
342
338
else
343
339
m_automatic_scrolling_timer->set_interval (100 );
@@ -383,7 +379,7 @@ ScrollBar::Component ScrollBar::component_at_position(const Gfx::IntPoint& posit
383
379
return Component::IncrementButton;
384
380
if (rect ().contains (position))
385
381
return Component::Gutter;
386
- return Component::Invalid ;
382
+ return Component::None ;
387
383
}
388
384
389
385
void ScrollBar::mousemove_event (MouseEvent& event)
@@ -395,7 +391,7 @@ void ScrollBar::mousemove_event(MouseEvent& event)
395
391
if (old_hovered_component != m_hovered_component) {
396
392
update ();
397
393
}
398
- if (!m_scrubbing )
394
+ if (m_pressed_component != Component::Scrubber )
399
395
return ;
400
396
float delta = orientation () == Orientation::Vertical ? (event.y () - m_scrub_origin.y ()) : (event.x () - m_scrub_origin.x ());
401
397
float scrubbable_range = scrubbable_range_in_pixels ();
@@ -406,8 +402,8 @@ void ScrollBar::mousemove_event(MouseEvent& event)
406
402
407
403
void ScrollBar::leave_event (Core::Event&)
408
404
{
409
- if (m_hovered_component != Component::Invalid ) {
410
- m_hovered_component = Component::Invalid ;
405
+ if (m_hovered_component != Component::None ) {
406
+ m_hovered_component = Component::None ;
411
407
update ();
412
408
}
413
409
}
@@ -416,7 +412,7 @@ void ScrollBar::change_event(Event& event)
416
412
{
417
413
if (event.type () == Event::Type::EnabledChange) {
418
414
if (!is_enabled ())
419
- m_scrubbing = false ;
415
+ set_automatic_scrolling_active ( false , Component::None) ;
420
416
}
421
417
return Widget::change_event (event);
422
418
}
0 commit comments