# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1630400266 0 # Node ID 34c4cb84834a99cf206fede60b2b0263222bba99 # Parent 42bc7ddd675174258e4a4cfc648c3f84a5316af8 iOS: Fix a miscalculation during DWSplitBar resize. Also put in some safety checks, clamping percet 0 to 100. diff -r 42bc7ddd6751 -r 34c4cb84834a ios/dw.m --- a/ios/dw.m Mon Aug 30 23:35:30 2021 +0000 +++ b/ios/dw.m Tue Aug 31 08:57:46 2021 +0000 @@ -1991,7 +1991,15 @@ -(void *)userdata { return userdata; } -(void)setUserdata:(void *)input { userdata = input; } -(float)percent { return percent; } --(void)setPercent:(float)input { percent = input; [self resize]; } +-(void)setPercent:(float)input +{ + percent = input; + if(percent > 100.0) + percent = 100.0; + else if(percent < 0.0) + percent = 0.0; + [self resize]; +} -(id)topLeft { return topleft; } -(void)setTopLeft:(id)input { @@ -2017,9 +2025,9 @@ half.origin.x = half.origin.y = 0; if(splittype == DW_HORZ) - half.size.width = (100.0/percent) * rect.size.width; + half.size.width = (percent/100.0) * rect.size.width; else - half.size.height = (100.0/percent) * rect.size.height; + half.size.height = (percent/100.0) * rect.size.height; if(topleft) { DWBox *view = topleft; @@ -2029,9 +2037,15 @@ _dw_handle_resize_events(box); } if(splittype == DW_HORZ) + { half.origin.x = half.size.width; + half.size.width = rect.size.width - half.size.width; + } else + { half.origin.y = half.size.height; + half.size.height = rect.size.height - half.size.height; + } if(bottomright) { DWBox *view = bottomright;