Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed最顶层windows设置了sortingOrder的情况,modal graph layer设置index-2错位的情况 #52

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion demo/assets/Script/Lib/fairygui.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,7 @@ declare namespace fgui {
private static _inst;
static get inst(): GRoot;
static create(): GRoot;
createModalLayer(): GComponent;
constructor();
protected onDestroy(): void;
getTouchPosition(touchId?: number): cc.Vec2;
Expand All @@ -1295,7 +1296,7 @@ declare namespace fgui {
closeAllExceptModals(): void;
closeAllWindows(): void;
getTopWindow(): Window;
get modalLayer(): GGraph;
get modalLayer(): GComponent;
get hasModalWindow(): boolean;
get modalWaiting(): boolean;
getPopupPosition(popup: GObject, target?: GObject, dir?: PopupDirection | boolean, result?: cc.Vec2): cc.Vec2;
Expand Down
22 changes: 15 additions & 7 deletions demo/assets/Script/Lib/fairygui.js
Original file line number Diff line number Diff line change
Expand Up @@ -2084,7 +2084,7 @@ window.__extends = (this && this.__extends) || (function () {
this._partner.callLater(this.buildNativeDisplayList);
if (dispose)
child.dispose();
else
else if (child.node)
child.node.parent = null;
this.setBoundsChangedFlag();
return child;
Expand Down Expand Up @@ -2187,8 +2187,8 @@ window.__extends = (this && this.__extends) || (function () {
return oldIndex;
var cnt = this._children.length;
if (this._sortingChildCount > 0) {
if (index > (cnt - this._sortingChildCount - 1))
index = cnt - this._sortingChildCount - 1;
if (index > (cnt - this._sortingChildCount))
index = cnt - this._sortingChildCount;
}
if (oldIndex < index)
return this._setChildIndex(child, oldIndex, index - 1);
Expand Down Expand Up @@ -9125,10 +9125,7 @@ window.__extends = (this && this.__extends) || (function () {
_this._volumeScale = 1;
_this._popupStack = new Array();
_this._justClosedPopups = new Array();
_this._modalLayer = new fgui.GGraph();
_this._modalLayer.setSize(_this.width, _this.height);
_this._modalLayer.drawRect(0, cc.Color.TRANSPARENT, fgui.UIConfig.modalLayerColor);
_this._modalLayer.addRelation(_this, fgui.RelationType.Size);
_this._modalLayer = _this.createModalLayer();
_this._thisOnResized = _this.onWinResize.bind(_this);
_this._inputProcessor = _this.node.addComponent(fgui.InputProcessor);
_this._inputProcessor._captureCallback = _this.onTouchBegin_1;
Expand All @@ -9155,6 +9152,17 @@ window.__extends = (this && this.__extends) || (function () {
GRoot._inst.node.parent = cc.director.getScene();
return GRoot._inst;
};
GRoot.prototype.createModalLayer = function () {
var layer = new fgui.GComponent();
layer.setSize(this.width, this.height);
var graph = new fgui.GGraph();
graph.setSize(this.width, this.height);
graph.drawRect(0, cc.Color.TRANSPARENT, fgui.UIConfig.modalLayerColor);
graph.addRelation(this, fgui.RelationType.Size);
layer.addChild(graph);
layer.addRelation(this, fgui.RelationType.Size);
return layer;
};
GRoot.prototype.onDestroy = function () {
if (CC_EDITOR) {
cc.engine.off('design-resolution-changed', this._thisOnResized);
Expand Down
3 changes: 2 additions & 1 deletion source/bin/fairygui.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,7 @@ declare namespace fgui {
private static _inst;
static get inst(): GRoot;
static create(): GRoot;
createModalLayer(): GComponent;
constructor();
protected onDestroy(): void;
getTouchPosition(touchId?: number): cc.Vec2;
Expand All @@ -1295,7 +1296,7 @@ declare namespace fgui {
closeAllExceptModals(): void;
closeAllWindows(): void;
getTopWindow(): Window;
get modalLayer(): GGraph;
get modalLayer(): GComponent;
get hasModalWindow(): boolean;
get modalWaiting(): boolean;
getPopupPosition(popup: GObject, target?: GObject, dir?: PopupDirection | boolean, result?: cc.Vec2): cc.Vec2;
Expand Down
22 changes: 15 additions & 7 deletions source/bin/fairygui.js
Original file line number Diff line number Diff line change
Expand Up @@ -2084,7 +2084,7 @@ window.__extends = (this && this.__extends) || (function () {
this._partner.callLater(this.buildNativeDisplayList);
if (dispose)
child.dispose();
else
else if (child.node)
child.node.parent = null;
this.setBoundsChangedFlag();
return child;
Expand Down Expand Up @@ -2187,8 +2187,8 @@ window.__extends = (this && this.__extends) || (function () {
return oldIndex;
var cnt = this._children.length;
if (this._sortingChildCount > 0) {
if (index > (cnt - this._sortingChildCount - 1))
index = cnt - this._sortingChildCount - 1;
if (index > (cnt - this._sortingChildCount))
index = cnt - this._sortingChildCount;
}
if (oldIndex < index)
return this._setChildIndex(child, oldIndex, index - 1);
Expand Down Expand Up @@ -9125,10 +9125,7 @@ window.__extends = (this && this.__extends) || (function () {
_this._volumeScale = 1;
_this._popupStack = new Array();
_this._justClosedPopups = new Array();
_this._modalLayer = new fgui.GGraph();
_this._modalLayer.setSize(_this.width, _this.height);
_this._modalLayer.drawRect(0, cc.Color.TRANSPARENT, fgui.UIConfig.modalLayerColor);
_this._modalLayer.addRelation(_this, fgui.RelationType.Size);
_this._modalLayer = _this.createModalLayer();
_this._thisOnResized = _this.onWinResize.bind(_this);
_this._inputProcessor = _this.node.addComponent(fgui.InputProcessor);
_this._inputProcessor._captureCallback = _this.onTouchBegin_1;
Expand All @@ -9155,6 +9152,17 @@ window.__extends = (this && this.__extends) || (function () {
GRoot._inst.node.parent = cc.director.getScene();
return GRoot._inst;
};
GRoot.prototype.createModalLayer = function () {
var layer = new fgui.GComponent();
layer.setSize(this.width, this.height);
var graph = new fgui.GGraph();
graph.setSize(this.width, this.height);
graph.drawRect(0, cc.Color.TRANSPARENT, fgui.UIConfig.modalLayerColor);
graph.addRelation(this, fgui.RelationType.Size);
layer.addChild(graph);
layer.addRelation(this, fgui.RelationType.Size);
return layer;
};
GRoot.prototype.onDestroy = function () {
if (CC_EDITOR) {
cc.engine.off('design-resolution-changed', this._thisOnResized);
Expand Down
6 changes: 3 additions & 3 deletions source/src/fairygui/GComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ namespace fgui {
if (dispose)
child.dispose();
else
child.node.parent = null;
if(child.node) child.node.parent = null;

this.setBoundsChangedFlag();

Expand Down Expand Up @@ -283,8 +283,8 @@ namespace fgui {

var cnt: number = this._children.length;
if (this._sortingChildCount > 0) {
if (index > (cnt - this._sortingChildCount - 1))
index = cnt - this._sortingChildCount - 1;
if (index > (cnt - this._sortingChildCount ))
index = cnt - this._sortingChildCount ;
}

if (oldIndex < index)
Expand Down
28 changes: 20 additions & 8 deletions source/src/fairygui/GRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace fgui {
export class GRoot extends GComponent {
public static contentScaleLevel: number = 0;

private _modalLayer: GGraph;
private _modalLayer: GComponent;
private _popupStack: Array<GObject>;
private _justClosedPopups: Array<GObject>;
private _modalWaitPane: GObject;
Expand All @@ -13,7 +13,7 @@ namespace fgui {
private _volumeScale: number;
private _inputProcessor: InputProcessor;
private _thisOnResized: Function;

private static _inst: GRoot;

public static get inst(): GRoot {
Expand All @@ -29,7 +29,18 @@ namespace fgui {

return GRoot._inst;
}

public createModalLayer(): GComponent {

let layer = new GComponent();
layer.setSize(this.width, this.height);
let graph = new GGraph();
graph.setSize(this.width, this.height);
graph.drawRect(0, cc.Color.TRANSPARENT, UIConfig.modalLayerColor);
graph.addRelation(this, RelationType.Size);
layer.addChild(graph);
layer.addRelation(this, RelationType.Size);
return layer;
}
public constructor() {
super();

Expand All @@ -39,10 +50,11 @@ namespace fgui {
this._popupStack = new Array<GObject>();
this._justClosedPopups = new Array<GObject>();

this._modalLayer = new GGraph();
this._modalLayer.setSize(this.width, this.height);
this._modalLayer.drawRect(0, cc.Color.TRANSPARENT, UIConfig.modalLayerColor);
this._modalLayer.addRelation(this, RelationType.Size);
this._modalLayer = this.createModalLayer();
// this._modalLayer = new GGraph();
// this._modalLayer.setSize(this.width, this.height);
// this._modalLayer.drawRect(0, cc.Color.TRANSPARENT, UIConfig.modalLayerColor);
// this._modalLayer.addRelation(this, RelationType.Size);

this._thisOnResized = this.onWinResize.bind(this);

Expand Down Expand Up @@ -180,7 +192,7 @@ namespace fgui {
return null;
}

public get modalLayer(): GGraph {
public get modalLayer(): GComponent {
return this._modalLayer;
}

Expand Down