@@ -17,6 +17,7 @@ public EditorContainer (IHostResourceProvider hostResources, IEditorView editorV
1717		} 
1818
1919		private  const  string  FrameChangedObservableProperty  =  "frame" ; 
20+ 		private  readonly  NSString  observerKeyPath  =  new  NSString  ( FrameChangedObservableProperty ) ; 
2021
2122		public  IEditorView  EditorView  =>  ( IEditorView ) NativeContainer ; 
2223
@@ -131,62 +132,62 @@ private void UpdateVariations ()
131132				if  ( this . viewModelAsPropertyViewModel . HasVariations )  { 
132133
133134					if  ( this . viewModelAsPropertyViewModel . IsVariant )  { 
134- 
135- 						if  ( this . deleteVariantButton  ==  null )  { 
136- 							this . deleteVariantButton  =  new  VariationButton  ( HostResources ,  "pe-variation-delete-button-active-mac-10" ,  "pe-variation-delete-button-mac-10" )  { 
137- 								AccessibilityEnabled  =  true , 
138- 								AccessibilityTitle  =  Properties . Resources . AccessibilityDeleteVariationButton , 
139- 								Command  =  this . viewModelAsPropertyViewModel . RemoveVariationCommand , 
140- 								ToolTip  =  Properties . Resources . RemoveVariant , 
141- 								TranslatesAutoresizingMaskIntoConstraints  =  false , 
142- 							} ; 
143- 
144- 							AddSubview  ( this . deleteVariantButton ) ; 
145- 							AddConstraints  ( new [ ]  { 
146- 								NSLayoutConstraint . Create  ( this . deleteVariantButton ,  NSLayoutAttribute . Top ,  NSLayoutRelation . Equal ,  this ,  NSLayoutAttribute . Top ,  1f ,  8f ) , 
147- 								NSLayoutConstraint . Create  ( this . deleteVariantButton ,  NSLayoutAttribute . Left ,  NSLayoutRelation . Equal ,  this ,  NSLayoutAttribute . Left ,  1f ,  20f ) , 
148- 							} ) ; 
149- 
150- 							this . variationControlsList . Add  ( this . deleteVariantButton ) ; 
151- 
152- 							// Hook into the delete button's frame change, so we can fire off some drawing. If there's a better way, let me know. 
153- 							this . deleteVariantButton . AddObserver  ( this ,  new  NSString  ( FrameChangedObservableProperty ) ,  NSKeyValueObservingOptions . New ,  IntPtr . Zero ) ; 
154- 						} 
135+ 						this . deleteVariantButton  =  new  VariationButton  ( HostResources ,  "pe-variation-delete-button-active-mac-10" ,  "pe-variation-delete-button-mac-10" )  { 
136+ 							AccessibilityEnabled  =  true , 
137+ 							AccessibilityTitle  =  Properties . Resources . AccessibilityDeleteVariationButton , 
138+ 							Command  =  this . viewModelAsPropertyViewModel . RemoveVariationCommand , 
139+ 							ToolTip  =  Properties . Resources . RemoveVariant , 
140+ 							TranslatesAutoresizingMaskIntoConstraints  =  false , 
141+ 						} ; 
142+ 
143+ 						AddSubview  ( this . deleteVariantButton ) ; 
144+ 						AddConstraints  ( new [ ]  { 
145+ 							NSLayoutConstraint . Create  ( this . deleteVariantButton ,  NSLayoutAttribute . Top ,  NSLayoutRelation . Equal ,  this ,  NSLayoutAttribute . Top ,  1f ,  8f ) , 
146+ 							NSLayoutConstraint . Create  ( this . deleteVariantButton ,  NSLayoutAttribute . Left ,  NSLayoutRelation . Equal ,  this ,  NSLayoutAttribute . Left ,  1f ,  20f ) , 
147+ 						} ) ; 
148+ 
149+ 						this . variationControlsList . Add  ( this . deleteVariantButton ) ; 
150+ 
151+ 						// Hook into the delete button's frame change, so we can fire off some drawing. If there's a better way, let me know. 
152+ 						this . deleteVariantButton . AddObserver  ( this ,  this . observerKeyPath ,  NSKeyValueObservingOptions . New ,  IntPtr . Zero ) ; 
153+ 						
154+ 
155+ 						// Cache these before the loop 
156+ 						var  variationBgColour  =  HostResources . GetNamedColor  ( NamedResources . FrameBoxButtonBackgroundColor ) ; 
155157
156158						NSView  previousControl  =  this . deleteVariantButton ; 
157159						foreach  ( PropertyVariationOption  item  in  this . viewModelAsPropertyViewModel . Variation )  { 
158- 							var  selectedVariationTextField  =  new  UnfocusableTextField  { 
159- 								BackgroundColor  =  HostResources . GetNamedColor   ( NamedResources . FrameBoxButtonBackgroundColor ) , 
160+ 							var  selectedVariationTextField  =  new  UnfocusableTextField  { 
161+ 								BackgroundColor  =  variationBgColour , 
160162								Bordered  =  false , 
161- 								Font  =  NSFont . SystemFontOfSize   ( NSFont . SystemFontSizeForControlSize   ( NSControlSize . Small )   -   1f ) , 
163+ 								Font  =  VariationOptionFont , 
162164								TranslatesAutoresizingMaskIntoConstraints  =  false , 
163165								StringValue  =  string . Format  ( " {0}: {1} " ,  item . Category ,  item . Name ) , 
164166							} ; 
165167
166168							AddSubview  ( selectedVariationTextField ) ; 
167- 							AddConstraints  ( new [ ]  { 
168- 								NSLayoutConstraint . Create  ( selectedVariationTextField ,  NSLayoutAttribute . Top ,  NSLayoutRelation . Equal ,  this ,  NSLayoutAttribute . Top ,  1f ,  5f ) , 
169+ 							AddConstraints  ( new [ ]  { 
170+ 								NSLayoutConstraint . Create  ( selectedVariationTextField ,  NSLayoutAttribute . Top ,  NSLayoutRelation . Equal ,  this ,  NSLayoutAttribute . Top ,  1f ,  VariationBorderOffset ) , 
169171								NSLayoutConstraint . Create  ( selectedVariationTextField ,  NSLayoutAttribute . Left ,  NSLayoutRelation . Equal ,  previousControl ,  NSLayoutAttribute . Right ,  1f ,  6f ) , 
170172								NSLayoutConstraint . Create  ( selectedVariationTextField ,  NSLayoutAttribute . Height ,  NSLayoutRelation . Equal ,  1f ,  16f ) , 
171173							} ) ; 
172174
173175							previousControl  =  selectedVariationTextField ; 
174176							this . variationControlsList . Add  ( selectedVariationTextField ) ; 
175177						} 
176- 					}  else  { 
177- 						if  ( this . addVariantButton  ==  null )  { 
178- 							this . addVariantButton  =  new  VariationButton  ( HostResources ,  "pe-variation-add-button-active-mac-10" ,  "pe-variation-add-button-mac-10" )  { 
179- 								AccessibilityEnabled  =  true , 
180- 								AccessibilityTitle  =  Properties . Resources . AccessibilityAddVariationButton , 
181- 								Command  =  this . viewModelAsPropertyViewModel . RequestCreateVariantCommand , 
182- 								ToolTip  =  Properties . Resources . AddVariant , 
183- 								TranslatesAutoresizingMaskIntoConstraints  =  false , 
184- 							} ; 
185- 
186- 							LeftEdgeView  =  this . addVariantButton ; 
187- 
188- 							this . variationControlsList . Add  ( this . addVariantButton ) ; 
189- 						} 
178+ 					}  else  { 
179+ 						this . addVariantButton  =  new  VariationButton  ( HostResources ,  "pe-variation-add-button-active-mac-10" ,  "pe-variation-add-button-mac-10" )  { 
180+ 							AccessibilityEnabled  =  true , 
181+ 							AccessibilityTitle  =  Properties . Resources . AccessibilityAddVariationButton , 
182+ 							Command  =  this . viewModelAsPropertyViewModel . RequestCreateVariantCommand , 
183+ 							ToolTip  =  Properties . Resources . AddVariant , 
184+ 							TranslatesAutoresizingMaskIntoConstraints  =  false , 
185+ 						} ; 
186+ 
187+ 						LeftEdgeView  =  this . addVariantButton ; 
188+ 
189+ 						this . variationControlsList . Add  ( this . addVariantButton ) ; 
190+ 						
190191					} 
191192				} 
192193			} 
@@ -201,7 +202,11 @@ private void ClearSubViews ()
201202			this . variationControlsList . Clear  ( ) ; 
202203
203204			this . addVariantButton  =  null ; 
204- 			this . deleteVariantButton  =  null ; 
205+ 
206+ 			if  ( this . deleteVariantButton  !=  null )  { 
207+ 				this . deleteVariantButton . RemoveObserver  ( this ,  this . observerKeyPath ) ; 
208+ 				this . deleteVariantButton  =  null ; 
209+ 			} 
205210		} 
206211
207212		private  void  ClearChildLayers  ( ) 
@@ -315,6 +320,8 @@ public NSColor LabelTextColor {
315320		private  VariationButton  addVariantButton ; 
316321		private  const  float  treeLineLeftEdge  =  14f ; 
317322		private  const  float  treeLineLeafIndent  =  4f ; 
323+ 		internal  const  float  VariationBorderOffset  =  5f ; 
324+ 		internal  static   NSFont  VariationOptionFont  =  NSFont . SystemFontOfSize  ( NSFont . SystemFontSizeForControlSize  ( NSControlSize . Small )  -  1f ) ; 
318325		private  nfloat  ViewVariationChildVerticalDrawPoint  =>  this . deleteVariantButton . Frame . Top  +  5 ; 
319326		private  nfloat  ViewVariationParentVerticalDrawPoint  =>  this . addVariantButton . Frame . Top  -  2 ; 
320327		private  PropertyViewModel  viewModelAsPropertyViewModel ; 
0 commit comments