MCPcopy Create free account
hub / github.com/TankOs/SFGUI / HandleUpdate

Method HandleUpdate

src/SFGUI/Scrollbar.cpp:276–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274}
275
276void Scrollbar::HandleUpdate( float seconds ) {
277 auto stepper_speed = Context::Get().GetEngine().GetProperty<float>( "StepperSpeed", shared_from_this() );
278
279 m_elapsed_time += seconds;
280
281 if( m_elapsed_time < (1.f / stepper_speed) ) {
282 return;
283 }
284
285 if( m_repeat_wait ) {
286 auto stepper_repeat_delay = Context::Get().GetEngine().GetProperty<std::uint32_t>( "StepperRepeatDelay", shared_from_this() );
287
288 if( m_elapsed_time < (static_cast<float>( stepper_repeat_delay ) / 1000.f) ) {
289 return;
290 }
291
292 m_repeat_wait = false;
293 }
294
295 m_elapsed_time = 0.f;
296
297 // Increment / Decrement value while one of the steppers is pressed
298 if( m_decrease_pressed ) {
299 GetAdjustment()->Decrement();
300 Invalidate();
301 return;
302 }
303 else if( m_increase_pressed ) {
304 GetAdjustment()->Increment();
305 Invalidate();
306 return;
307 }
308
309 auto slider_rect = GetSliderRect();
310 slider_rect.position.x += GetAllocation().position.x;
311 slider_rect.position.y += GetAllocation().position.y;
312
313 // Increment / Decrement page while mouse is pressed on the trough
314 if( m_page_decreasing ) {
315 GetAdjustment()->DecrementPage();
316
317 if( GetOrientation() == Orientation::HORIZONTAL ) {
318 if( slider_rect.position.x + slider_rect.size.x < static_cast<float>( m_page_decreasing ) ) {
319 m_page_decreasing = 0;
320 }
321 }
322 else {
323 if( slider_rect.position.y + slider_rect.size.y < static_cast<float>( m_page_decreasing ) ) {
324 m_page_decreasing = 0;
325 }
326 }
327
328 Invalidate();
329 return;
330 }
331 else if( m_page_increasing ) {
332 GetAdjustment()->IncrementPage();
333

Callers

nothing calls this directly

Calls 4

DecrementMethod · 0.80
IncrementMethod · 0.80
DecrementPageMethod · 0.80
IncrementPageMethod · 0.80

Tested by

no test coverage detected