Jump to content

WidgetTreeBox ruler bug


photo

Recommended Posts

Problem

 

WidgetTreeBox ruler position calculation fails when scrolling down for large item counts (in our test case 10000+).

 

WidgetTreeBox item scrolling (by keys or ruler dragging) and ruler rendering works correctly for "upper" part of item list. When scrolling to the end of the list, ruler suddenly disappears/gets rendered outside of WidgetTreeBox ruler area or WidgetTreeBox jumps back to start of item list.

 

post-82-061905600 1287559168_thumb.jpg

Link to comment

Cause

 

int value range exceeded on ruler Y position calculation in WidgetVScroll.cpp due to large object_size of WidgetTree for large item counts.

 

Bug Fix

 

use intermediate double value precision for button_y/value calculation

 

void WidgetVScroll::checkCallbacks(int x,int y) {
   ....
   int button_y = (object_size == frame_size) ? h : int( (height - h * 2 - button_height) * double(value) / double(object_size - frame_size) ) + h;
   ...
   if(gui->getMouseGrab()) {
      if(gui->getMouseButton() & App::BUTTON_LEFT) {
          if(pressed == 5) {
       value = (object_size == frame_size) ? 0 : (mouse_y - h - mouse_offset) * int( double(object_size - frame_size) / double(height - h * 2 - button_height) );
    .....

 

void WidgetVScroll::render() {
   .....
   int button_y = (object_size == frame_size) ? h : int( (height - h * 2 - button_height) * double(value) / double( object_size - frame_size ) ) + h;
   .....

Link to comment
×
×
  • Create New...