@@ -33,6 +33,13 @@ public static int contentScaleLevel
33
33
GObject _tooltipWin ;
34
34
GObject _defaultTooltipWin ;
35
35
36
+ GComponent _popupLayer ;
37
+ public GComponent popupLayer
38
+ {
39
+ get { return _popupLayer != null ? _popupLayer : this ; }
40
+ set { _popupLayer = value ; }
41
+ }
42
+
36
43
internal static GRoot _inst ;
37
44
public static GRoot inst
38
45
{
@@ -130,7 +137,7 @@ public void ApplyContentScaleFactor()
130
137
/// <param name="win"></param>
131
138
public void ShowWindow ( Window win )
132
139
{
133
- AddChild ( win ) ;
140
+ popupLayer . AddChild ( win ) ;
134
141
AdjustModalLayer ( ) ;
135
142
}
136
143
@@ -162,8 +169,8 @@ public void HideWindowImmediately(Window win)
162
169
/// <param name="dispose">True to dispose the window.</param>
163
170
public void HideWindowImmediately ( Window win , bool dispose )
164
171
{
165
- if ( win . parent == this )
166
- RemoveChild ( win , dispose ) ;
172
+ if ( win . parent == popupLayer )
173
+ popupLayer . RemoveChild ( win , dispose ) ;
167
174
else if ( dispose )
168
175
win . Dispose ( ) ;
169
176
@@ -176,24 +183,24 @@ public void HideWindowImmediately(Window win, bool dispose)
176
183
/// <param name="win"></param>
177
184
public void BringToFront ( Window win )
178
185
{
179
- int cnt = this . numChildren ;
186
+ int cnt = popupLayer . numChildren ;
180
187
int i ;
181
188
if ( _modalLayer != null && _modalLayer . parent != null && ! win . modal )
182
- i = GetChildIndex ( _modalLayer ) - 1 ;
189
+ i = popupLayer . GetChildIndex ( _modalLayer ) - 1 ;
183
190
else
184
191
i = cnt - 1 ;
185
192
186
193
for ( ; i >= 0 ; i -- )
187
194
{
188
- GObject g = GetChildAt ( i ) ;
195
+ GObject g = popupLayer . GetChildAt ( i ) ;
189
196
if ( g == win )
190
197
return ;
191
198
if ( g is Window )
192
199
break ;
193
200
}
194
201
195
202
if ( i >= 0 )
196
- SetChildIndex ( win , i ) ;
203
+ popupLayer . SetChildIndex ( win , i ) ;
197
204
}
198
205
199
206
/// <summary>
@@ -208,12 +215,12 @@ public void ShowModalWait()
208
215
if ( _modalWaitPane == null || _modalWaitPane . isDisposed )
209
216
{
210
217
_modalWaitPane = UIPackage . CreateObjectFromURL ( UIConfig . globalModalWaiting ) ;
211
- _modalWaitPane . SetHome ( this ) ;
218
+ _modalWaitPane . SetHome ( popupLayer ) ;
212
219
}
213
- _modalWaitPane . SetSize ( this . width , this . height ) ;
214
- _modalWaitPane . AddRelation ( this , RelationType . Size ) ;
220
+ _modalWaitPane . SetSize ( popupLayer . width , popupLayer . height ) ;
221
+ _modalWaitPane . AddRelation ( popupLayer , RelationType . Size ) ;
215
222
216
- AddChild ( _modalWaitPane ) ;
223
+ popupLayer . AddChild ( _modalWaitPane ) ;
217
224
}
218
225
}
219
226
@@ -223,7 +230,7 @@ public void ShowModalWait()
223
230
public void CloseModalWait ( )
224
231
{
225
232
if ( _modalWaitPane != null && _modalWaitPane . parent != null )
226
- RemoveChild ( _modalWaitPane ) ;
233
+ popupLayer . RemoveChild ( _modalWaitPane ) ;
227
234
}
228
235
229
236
/// <summary>
@@ -258,10 +265,10 @@ public void CloseAllWindows()
258
265
/// <returns></returns>
259
266
public Window GetTopWindow ( )
260
267
{
261
- int cnt = this . numChildren ;
268
+ int cnt = popupLayer . numChildren ;
262
269
for ( int i = cnt - 1 ; i >= 0 ; i -- )
263
270
{
264
- GObject g = this . GetChildAt ( i ) ;
271
+ GObject g = popupLayer . GetChildAt ( i ) ;
265
272
if ( g is Window )
266
273
{
267
274
return ( Window ) ( g ) ;
@@ -288,10 +295,10 @@ public GGraph modalLayer
288
295
void CreateModalLayer ( )
289
296
{
290
297
_modalLayer = new GGraph ( ) ;
291
- _modalLayer . DrawRect ( this . width , this . height , 0 , Color . white , UIConfig . modalLayerColor ) ;
292
- _modalLayer . AddRelation ( this , RelationType . Size ) ;
298
+ _modalLayer . DrawRect ( popupLayer . width , popupLayer . height , 0 , Color . white , UIConfig . modalLayerColor ) ;
299
+ _modalLayer . AddRelation ( popupLayer , RelationType . Size ) ;
293
300
_modalLayer . name = _modalLayer . gameObjectName = "ModalLayer" ;
294
- _modalLayer . SetHome ( this ) ;
301
+ _modalLayer . SetHome ( popupLayer ) ;
295
302
}
296
303
297
304
/// <summary>
@@ -346,26 +353,26 @@ private void AdjustModalLayer()
346
353
if ( _modalLayer == null || _modalLayer . isDisposed )
347
354
CreateModalLayer ( ) ;
348
355
349
- int cnt = this . numChildren ;
356
+ int cnt = popupLayer . numChildren ;
350
357
351
358
if ( _modalWaitPane != null && _modalWaitPane . parent != null )
352
- SetChildIndex ( _modalWaitPane , cnt - 1 ) ;
359
+ popupLayer . SetChildIndex ( _modalWaitPane , cnt - 1 ) ;
353
360
354
361
for ( int i = cnt - 1 ; i >= 0 ; i -- )
355
362
{
356
- GObject g = this . GetChildAt ( i ) ;
363
+ GObject g = popupLayer . GetChildAt ( i ) ;
357
364
if ( ( g is Window ) && ( g as Window ) . modal )
358
365
{
359
366
if ( _modalLayer . parent == null )
360
- AddChildAt ( _modalLayer , i ) ;
367
+ popupLayer . AddChildAt ( _modalLayer , i ) ;
361
368
else
362
- SetChildIndexBefore ( _modalLayer , i ) ;
369
+ popupLayer . SetChildIndexBefore ( _modalLayer , i ) ;
363
370
return ;
364
371
}
365
372
}
366
373
367
374
if ( _modalLayer . parent != null )
368
- RemoveChild ( _modalLayer ) ;
375
+ _modalLayer . RemoveFromParent ( ) ;
369
376
}
370
377
371
378
/// <summary>
@@ -448,7 +455,7 @@ public void ShowPopup(GObject popup, GObject target, PopupDirection dir, bool cl
448
455
GObject p = target ;
449
456
while ( p != null )
450
457
{
451
- if ( p . parent == this )
458
+ if ( p . parent == popupLayer )
452
459
{
453
460
if ( popup . sortingOrder < p . sortingOrder )
454
461
{
@@ -460,7 +467,7 @@ public void ShowPopup(GObject popup, GObject target, PopupDirection dir, bool cl
460
467
}
461
468
}
462
469
463
- AddChild ( popup ) ;
470
+ popupLayer . AddChild ( popup ) ;
464
471
AdjustModalLayer ( ) ;
465
472
466
473
if ( ( popup is Window ) && target == null && dir == PopupDirection . Auto )
@@ -495,14 +502,14 @@ public Vector2 GetPoupPosition(GObject popup, GObject target, PopupDirection dir
495
502
}
496
503
else
497
504
{
498
- pos = this . GlobalToLocal ( Stage . inst . touchPosition ) ;
505
+ pos = popupLayer . GlobalToLocal ( Stage . inst . touchPosition ) ;
499
506
}
500
507
float xx , yy ;
501
508
xx = pos . x ;
502
- if ( xx + popup . width > this . width )
509
+ if ( xx + popup . width > popupLayer . width )
503
510
xx = xx + size . x - popup . width ;
504
511
yy = pos . y + size . y ;
505
- if ( ( dir == PopupDirection . Auto && yy + popup . height > this . height )
512
+ if ( ( dir == PopupDirection . Auto && yy + popup . height > popupLayer . height )
506
513
|| dir == PopupDirection . Up )
507
514
{
508
515
yy = pos . y - popup . height - 1 ;
@@ -622,7 +629,7 @@ void ClosePopup(GObject target)
622
629
if ( target is Window )
623
630
( ( Window ) target ) . Hide ( ) ;
624
631
else
625
- RemoveChild ( target ) ;
632
+ target . RemoveFromParent ( ) ;
626
633
}
627
634
}
628
635
@@ -652,7 +659,7 @@ public void ShowTooltips(string msg, float delay)
652
659
}
653
660
654
661
_defaultTooltipWin = UIPackage . CreateObjectFromURL ( resourceURL ) ;
655
- _defaultTooltipWin . SetHome ( this ) ;
662
+ _defaultTooltipWin . SetHome ( popupLayer ) ;
656
663
_defaultTooltipWin . touchable = false ;
657
664
}
658
665
@@ -690,13 +697,13 @@ void __showTooltipsWin(object param)
690
697
float xx = Stage . inst . touchPosition . x + 10 ;
691
698
float yy = Stage . inst . touchPosition . y + 20 ;
692
699
693
- Vector2 pt = this . GlobalToLocal ( new Vector2 ( xx , yy ) ) ;
700
+ Vector2 pt = popupLayer . GlobalToLocal ( new Vector2 ( xx , yy ) ) ;
694
701
xx = pt . x ;
695
702
yy = pt . y ;
696
703
697
- if ( xx + _tooltipWin . width > this . width )
704
+ if ( xx + _tooltipWin . width > popupLayer . width )
698
705
xx = xx - _tooltipWin . width ;
699
- if ( yy + _tooltipWin . height > this . height )
706
+ if ( yy + _tooltipWin . height > popupLayer . height )
700
707
{
701
708
yy = yy - _tooltipWin . height - 1 ;
702
709
if ( yy < 0 )
@@ -705,7 +712,7 @@ void __showTooltipsWin(object param)
705
712
706
713
_tooltipWin . x = Mathf . RoundToInt ( xx ) ;
707
714
_tooltipWin . y = Mathf . RoundToInt ( yy ) ;
708
- AddChild ( _tooltipWin ) ;
715
+ popupLayer . AddChild ( _tooltipWin ) ;
709
716
}
710
717
711
718
/// <summary>
@@ -716,7 +723,7 @@ public void HideTooltips()
716
723
if ( _tooltipWin != null )
717
724
{
718
725
if ( _tooltipWin . parent != null )
719
- RemoveChild ( _tooltipWin ) ;
726
+ _tooltipWin . RemoveFromParent ( ) ;
720
727
_tooltipWin = null ;
721
728
}
722
729
}
0 commit comments