Mercurial > dwindows
changeset 2647:34c4cb84834a
iOS: Fix a miscalculation during DWSplitBar resize.
Also put in some safety checks, clamping percet 0 to 100.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 31 Aug 2021 08:57:46 +0000 |
parents | 42bc7ddd6751 |
children | 2362cb4b7ef9 |
files | ios/dw.m |
diffstat | 1 files changed, 17 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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;