diff options
Diffstat (limited to 'utils/themeeditor/graphics/rbviewport.cpp')
-rw-r--r-- | utils/themeeditor/graphics/rbviewport.cpp | 48 |
1 files changed, 15 insertions, 33 deletions
diff --git a/utils/themeeditor/graphics/rbviewport.cpp b/utils/themeeditor/graphics/rbviewport.cpp index 3a239c7f35..4422f19b86 100644 --- a/utils/themeeditor/graphics/rbviewport.cpp +++ b/utils/themeeditor/graphics/rbviewport.cpp | |||
@@ -30,8 +30,6 @@ | |||
30 | #include "tag_table.h" | 30 | #include "tag_table.h" |
31 | #include "skin_parser.h" | 31 | #include "skin_parser.h" |
32 | 32 | ||
33 | /* Pause at beginning/end of scroll */ | ||
34 | const double RBViewport::scrollPause = 0.5; | ||
35 | /* Pixels/second of text scrolling */ | 33 | /* Pixels/second of text scrolling */ |
36 | const double RBViewport::scrollRate = 30; | 34 | const double RBViewport::scrollRate = 30; |
37 | 35 | ||
@@ -302,23 +300,18 @@ void RBViewport::alignLeft() | |||
302 | if(difference > 0) | 300 | if(difference > 0) |
303 | { | 301 | { |
304 | /* Subtracting out complete cycles */ | 302 | /* Subtracting out complete cycles */ |
305 | double totalTime = 2 * scrollPause + difference / scrollRate; | 303 | double totalTime = 2 * difference / scrollRate; |
306 | scrollTime -= totalTime * std::floor(scrollTime / totalTime); | 304 | scrollTime -= totalTime * std::floor(scrollTime / totalTime); |
307 | 305 | ||
308 | /* Calculating the offset */ | 306 | /* Calculating the offset */ |
309 | if(scrollTime < scrollPause) | 307 | if(scrollTime < static_cast<double>(difference) / scrollRate) |
310 | { | 308 | { |
311 | return; | 309 | leftGraphic->setOffset(scrollRate * scrollTime); |
312 | } | ||
313 | else if(scrollTime < scrollPause + difference / scrollRate) | ||
314 | { | ||
315 | scrollTime -= scrollPause; | ||
316 | int offset = scrollRate * scrollTime; | ||
317 | leftGraphic->setOffset(offset); | ||
318 | } | 310 | } |
319 | else | 311 | else |
320 | { | 312 | { |
321 | leftGraphic->setOffset(difference); | 313 | scrollTime -= static_cast<double>(difference) / scrollRate; |
314 | leftGraphic->setOffset(difference - scrollRate * scrollTime); | ||
322 | } | 315 | } |
323 | } | 316 | } |
324 | } | 317 | } |
@@ -352,23 +345,18 @@ void RBViewport::alignCenter() | |||
352 | if(difference > 0) | 345 | if(difference > 0) |
353 | { | 346 | { |
354 | /* Subtracting out complete cycles */ | 347 | /* Subtracting out complete cycles */ |
355 | double totalTime = 2 * scrollPause + difference / scrollRate; | 348 | double totalTime = 2 * difference / scrollRate; |
356 | scrollTime -= totalTime * std::floor(scrollTime / totalTime); | 349 | scrollTime -= totalTime * std::floor(scrollTime / totalTime); |
357 | 350 | ||
358 | /* Calculating the offset */ | 351 | /* Calculating the offset */ |
359 | if(scrollTime < scrollPause) | 352 | if(scrollTime < static_cast<double>(difference) / scrollRate) |
360 | { | ||
361 | return; | ||
362 | } | ||
363 | else if(scrollTime < scrollPause + difference / scrollRate) | ||
364 | { | 353 | { |
365 | scrollTime -= scrollPause; | 354 | centerGraphic->setOffset(scrollRate * scrollTime); |
366 | int offset = scrollRate * scrollTime; | ||
367 | centerGraphic->setOffset(offset); | ||
368 | } | 355 | } |
369 | else | 356 | else |
370 | { | 357 | { |
371 | centerGraphic->setOffset(difference); | 358 | scrollTime -= static_cast<double>(difference) / scrollRate; |
359 | centerGraphic->setOffset(difference - scrollRate * scrollTime); | ||
372 | } | 360 | } |
373 | } | 361 | } |
374 | 362 | ||
@@ -397,25 +385,19 @@ void RBViewport::alignRight() | |||
397 | if(difference > 0) | 385 | if(difference > 0) |
398 | { | 386 | { |
399 | /* Subtracting out complete cycles */ | 387 | /* Subtracting out complete cycles */ |
400 | double totalTime = 2 * scrollPause + difference / scrollRate; | 388 | double totalTime = 2 * difference / scrollRate; |
401 | scrollTime -= totalTime * std::floor(scrollTime / totalTime); | 389 | scrollTime -= totalTime * std::floor(scrollTime / totalTime); |
402 | 390 | ||
403 | /* Calculating the offset */ | 391 | /* Calculating the offset */ |
404 | if(scrollTime < scrollPause) | 392 | if(scrollTime < static_cast<double>(difference) / scrollRate) |
405 | { | 393 | { |
406 | return; | 394 | rightGraphic->setOffset(scrollRate * scrollTime); |
407 | } | ||
408 | else if(scrollTime < scrollPause + difference / scrollRate) | ||
409 | { | ||
410 | scrollTime -= scrollPause; | ||
411 | int offset = scrollRate * scrollTime; | ||
412 | rightGraphic->setOffset(offset); | ||
413 | } | 395 | } |
414 | else | 396 | else |
415 | { | 397 | { |
416 | rightGraphic->setOffset(difference); | 398 | scrollTime -= static_cast<double>(difference) / scrollRate; |
399 | rightGraphic->setOffset(difference - scrollRate * scrollTime); | ||
417 | } | 400 | } |
418 | } | 401 | } |
419 | |||
420 | } | 402 | } |
421 | 403 | ||