From b817a16c051f59bba08a9217a8d3c8eee1a63c1f Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 14 Jun 2016 22:55:55 +0200 Subject: [PATCH] Adds missing delete() method for darwin --- darwin/form.m | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/darwin/form.m b/darwin/form.m index 3d27520b..08a3b6da 100644 --- a/darwin/form.m +++ b/darwin/form.m @@ -40,7 +40,7 @@ - (CGFloat)paddingAmount; - (void)establishOurConstraints; - (void)append:(NSString *)label c:(uiControl *)c stretchy:(int)stretchy; -//TODO- (void)delete:(int)n; +- (void)delete:(int)n; - (int)isPadded; - (void)setPadded:(int)p; - (BOOL)hugsTrailing; @@ -388,7 +388,31 @@ struct uiForm { [fc release]; // we don't need the initial reference now } -//TODO- (void)delete:(int)n +- (void)delete:(int)n +{ + formChild *fc; + int stretchy; + + fc = (formChild *) [self->children objectAtIndex:n]; + stretchy = fc.stretchy; + + uiControlSetParent(fc.c, NULL); + uiDarwinControlSetSuperview(uiDarwinControl(fc.c), nil); + + uiDarwinControlSetHuggingPriority(uiDarwinControl(fc.c), fc.oldHorzHuggingPri, NSLayoutConstraintOrientationHorizontal); + uiDarwinControlSetHuggingPriority(uiDarwinControl(fc.c), fc.oldVertHuggingPri, NSLayoutConstraintOrientationVertical); + + [fc.label removeFromSuperview]; + + [self->children removeObjectAtIndex:n]; + + [self establishOurConstraints]; + if (stretchy) { + self->nStretchy--; + if (self->nStretchy == 0) + uiDarwinNotifyEdgeHuggingChanged(uiDarwinControl(self->f)); + } +} - (int)isPadded {