Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zeroing-engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
zeroing-engine
Commits
cf66b590
Commit
cf66b590
authored
Jun 22, 2020
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复
parent
5e81e6a4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
120 additions
and
113 deletions
+120
-113
Container.ts
src/2d/display/Container.ts
+111
-104
ScrollView.ts
src/zeroing/game-warpper/nodes/ScrollView.ts
+9
-9
No files found.
src/2d/display/Container.ts
View file @
cf66b590
...
...
@@ -12,6 +12,9 @@ import {afterConstructor} from "../../zeroing/decorators/after-constructor";
import
{
injectProperties
,
instantiateScript
,
toBoolean
}
from
"../../zeroing/utils/index"
;
import
{
isUI
}
from
"../../zeroing/game-warpper/nodes/IUIComponent"
;
import
Transform
from
"../math/Transform"
;
import
{
ScrollView
}
from
"../../zeroing/game-warpper/nodes/ScrollView"
;
const
skipIndexTypes
=
[
'ScrollView'
,
'ScrollList'
];
/**
* 容器类
...
...
@@ -288,8 +291,12 @@ export default class Container extends DisplayObject {
while
(
node
.
parent
)
{
let
child
=
node
;
node
=
node
.
parent
;
let
index
=
node
.
children
.
indexOf
(
child
);
path
.
unshift
(
index
);
if
(
skipIndexTypes
.
indexOf
(
node
.
instanceType
)
>=
0
)
{
}
else
{
let
index
=
node
.
children
.
indexOf
(
child
);
path
.
unshift
(
index
);
}
if
(
node
===
untilNode
)
{
break
;
}
...
...
@@ -511,19 +518,19 @@ export default class Container extends DisplayObject {
this._bounds.height = this._height;
}*/
if
(
widthSetted
||
heightSetted
)
{
const
rect
=
this
.
_localBoundsSelf
;
var
matrix
=
this
.
transform
.
worldMatrix
;
matrix
.
transformPoint
(
rect
.
x
,
rect
.
y
,
DisplayObject
.
_p1
);
matrix
.
transformPoint
(
rect
.
x
+
rect
.
width
,
rect
.
y
,
DisplayObject
.
_p2
);
matrix
.
transformPoint
(
rect
.
x
+
rect
.
width
,
rect
.
y
+
rect
.
height
,
DisplayObject
.
_p3
);
matrix
.
transformPoint
(
rect
.
x
,
rect
.
y
+
rect
.
height
,
DisplayObject
.
_p4
);
Rectangle
.
createFromPoints
(
this
.
_bounds
,
DisplayObject
.
_p1
,
DisplayObject
.
_p2
,
DisplayObject
.
_p3
,
DisplayObject
.
_p4
);
if
(
widthSetted
||
heightSetted
)
{
const
rect
=
this
.
_localBoundsSelf
;
var
matrix
=
this
.
transform
.
worldMatrix
;
matrix
.
transformPoint
(
rect
.
x
,
rect
.
y
,
DisplayObject
.
_p1
);
matrix
.
transformPoint
(
rect
.
x
+
rect
.
width
,
rect
.
y
,
DisplayObject
.
_p2
);
matrix
.
transformPoint
(
rect
.
x
+
rect
.
width
,
rect
.
y
+
rect
.
height
,
DisplayObject
.
_p3
);
matrix
.
transformPoint
(
rect
.
x
,
rect
.
y
+
rect
.
height
,
DisplayObject
.
_p4
);
Rectangle
.
createFromPoints
(
this
.
_bounds
,
DisplayObject
.
_p1
,
DisplayObject
.
_p2
,
DisplayObject
.
_p3
,
DisplayObject
.
_p4
);
return
true
;
}
return
false
;
}
return
true
;
}
return
false
;
}
/**
* 检测点是否在任何child上
...
...
@@ -533,7 +540,7 @@ export default class Container extends DisplayObject {
//如果不可见
if
(
!
this
.
visible
)
return
null
//如果禁止子级的鼠标事件
if
(
isMouseEvent
&&
!
this
.
mouseChildren
){
if
(
isMouseEvent
&&
!
this
.
mouseChildren
)
{
return
this
.
hitTestSelf
(
globalPoint
);
}
var
children
=
this
.
children
;
...
...
@@ -724,103 +731,103 @@ export default class Container extends DisplayObject {
this
.
mouseChildren
=
false
;
}
/**
* 一般用于获取宽高并设置
* 包括子级的,容器的尽量少用,子类可重写
* @member {number}
*/
get
width
():
number
{
let
value
=
this
.
_width
;
return
!
value
&&
value
!=
0
?
this
.
scale
.
x
*
this
.
getLocalBounds
().
width
:
value
;
}
/**
* 一般用于获取宽高并设置
* 包括子级的,容器的尽量少用,子类可重写
* @member {number}
*/
get
width
():
number
{
let
value
=
this
.
_width
;
return
!
value
&&
value
!=
0
?
this
.
scale
.
x
*
this
.
getLocalBounds
().
width
:
value
;
}
set
width
(
value
:
number
)
{
// const width = this.getLocalBounds().width;
// if (width !== 0) {
// this.scale.x = value / width;
// } else {
// this.scale.x = 1;
// }
if
(
this
.
_width
!==
value
)
{
if
(
!
value
&&
value
!=
0
)
{
this
.
_width
=
undefined
;
}
else
{
//子类有用,有_width,才需设置scaleX
this
.
_width
=
value
;
this
.
_localBoundsSelf
.
width
=
value
;
//if (this.stage) this.stage.layoutInvalid = true;
}
this
.
dispatchEvent
(
Event
.
RESIZE
);
this
.
dispatchEvent
(
Event
.
MAYBE_ALIGN
);
// 如果它设置了 percentWidth 或同时设置了 left 和 right 则表示他的宽度是相对的,则对于父级来说它的宽度永远是 0
this
.
__width
=
(
toBoolean
(
this
.
percentWidth
)
||
(
toBoolean
(
this
.
left
)
&&
toBoolean
(
this
.
right
)))
?
0
:
value
;
}
}
/**
* 高度同width
* @member {number}
*/
get
height
():
number
{
let
value
=
this
.
_height
;
return
!
value
&&
value
!=
0
?
this
.
scale
.
y
*
this
.
getLocalBounds
().
height
:
value
;
}
// if (width !== 0) {
// this.scale.x = value / width;
// } else {
// this.scale.x = 1;
// }
if
(
this
.
_width
!==
value
)
{
if
(
!
value
&&
value
!=
0
)
{
this
.
_width
=
undefined
;
}
else
{
//子类有用,有_width,才需设置scaleX
this
.
_width
=
value
;
this
.
_localBoundsSelf
.
width
=
value
;
//if (this.stage) this.stage.layoutInvalid = true;
}
this
.
dispatchEvent
(
Event
.
RESIZE
);
this
.
dispatchEvent
(
Event
.
MAYBE_ALIGN
);
// 如果它设置了 percentWidth 或同时设置了 left 和 right 则表示他的宽度是相对的,则对于父级来说它的宽度永远是 0
this
.
__width
=
(
toBoolean
(
this
.
percentWidth
)
||
(
toBoolean
(
this
.
left
)
&&
toBoolean
(
this
.
right
)))
?
0
:
value
;
}
}
/**
* 高度同width
* @member {number}
*/
get
height
():
number
{
let
value
=
this
.
_height
;
return
!
value
&&
value
!=
0
?
this
.
scale
.
y
*
this
.
getLocalBounds
().
height
:
value
;
}
set
height
(
value
:
number
)
{
// const height = this.getLocalBounds().height;
// if (height !== 0) {
// this.scale.y = value / height;
// } else {
// this.scale.y = 1;
// }
if
(
!
value
&&
value
!=
0
)
{
this
.
_height
=
undefined
;
}
else
{
if
(
this
.
_height
!==
value
)
{
this
.
_height
=
value
;
this
.
_localBoundsSelf
.
height
=
value
;
//if (this.stage) this.stage.layoutInvalid = true;
}
this
.
dispatchEvent
(
Event
.
RESIZE
);
this
.
dispatchEvent
(
Event
.
MAYBE_ALIGN
);
// 如果它设置了 percentHeight 或同时设置了 top 和 bottom 则表示他的高度是相对的,则对于父级来说它的高度永远是 0
this
.
__height
=
(
toBoolean
(
this
.
percentHeight
)
||
(
toBoolean
(
this
.
top
)
&&
toBoolean
(
this
.
bottom
)))
?
0
:
value
;
}
}
protected
__width
=
0
;
// 忽略 相对宽度 的 宽度,在父级计算自动宽度的时候用到
protected
__height
=
0
;
// 忽略 相对高度 的 高度,在父级计算自动高度的时候用到
get
x
():
number
{
return
this
.
position
.
x
;
}
set
x
(
value
:
number
)
{
if
(
value
==
this
.
transform
.
position
.
x
)
return
;
this
.
transform
.
position
.
x
=
value
;
this
.
dispatchEvent
(
Event
.
MAYBE_ALIGN
);
}
get
y
():
number
{
return
this
.
position
.
y
;
}
set
y
(
value
:
number
)
{
if
(
value
==
this
.
transform
.
position
.
y
)
return
;
this
.
transform
.
position
.
y
=
value
;
this
.
dispatchEvent
(
Event
.
MAYBE_ALIGN
);
}
// if (height !== 0) {
// this.scale.y = value / height;
// } else {
// this.scale.y = 1;
// }
if
(
!
value
&&
value
!=
0
)
{
this
.
_height
=
undefined
;
}
else
{
if
(
this
.
_height
!==
value
)
{
this
.
_height
=
value
;
this
.
_localBoundsSelf
.
height
=
value
;
//if (this.stage) this.stage.layoutInvalid = true;
}
this
.
dispatchEvent
(
Event
.
RESIZE
);
this
.
dispatchEvent
(
Event
.
MAYBE_ALIGN
);
// 如果它设置了 percentHeight 或同时设置了 top 和 bottom 则表示他的高度是相对的,则对于父级来说它的高度永远是 0
this
.
__height
=
(
toBoolean
(
this
.
percentHeight
)
||
(
toBoolean
(
this
.
top
)
&&
toBoolean
(
this
.
bottom
)))
?
0
:
value
;
}
}
protected
__width
=
0
;
// 忽略 相对宽度 的 宽度,在父级计算自动宽度的时候用到
protected
__height
=
0
;
// 忽略 相对高度 的 高度,在父级计算自动高度的时候用到
get
x
():
number
{
return
this
.
position
.
x
;
}
set
x
(
value
:
number
)
{
if
(
value
==
this
.
transform
.
position
.
x
)
return
;
this
.
transform
.
position
.
x
=
value
;
this
.
dispatchEvent
(
Event
.
MAYBE_ALIGN
);
}
get
y
():
number
{
return
this
.
position
.
y
;
}
set
y
(
value
:
number
)
{
if
(
value
==
this
.
transform
.
position
.
y
)
return
;
this
.
transform
.
position
.
y
=
value
;
this
.
dispatchEvent
(
Event
.
MAYBE_ALIGN
);
}
clone
(
withEvents
=
false
,
withScripts
=
false
)
{
let
target
=
this
.
constructor
.
apply
(
Object
.
create
(
this
.
constructor
.
prototype
));
...
...
src/zeroing/game-warpper/nodes/ScrollView.ts
View file @
cf66b590
...
...
@@ -9,15 +9,15 @@ import {IUIComponent} from "./IUIComponent";
export
const
proxyMethods
=
[
'onChildrenChange'
,
'addChild'
,
//
'addChildAt',
//
'swapChildren',
//
'getChildIndex',
//
'setChildIndex',
//
'getChildAt',
//
'getChildByName',
//
'removeChild',
//
'removeChildAt',
//
'removeChildren',
'addChildAt'
,
'swapChildren'
,
'getChildIndex'
,
'setChildIndex'
,
'getChildAt'
,
'getChildByName'
,
'removeChild'
,
'removeChildAt'
,
'removeChildren'
,
];
export
class
ScrollView
extends
ScrollViewBase
implements
IUIComponent
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment