public void ApplyOnSelfSizeChanged(float dWidth, float dHeight, bool applyPivot) { int cnt = _defs.Count; if (cnt == 0) { return; } float ox = _owner.x; float oy = _owner.y; for (int i = 0; i < cnt; i++) { RelationDef info = _defs[i]; switch (info.type) { case RelationType.Center_Center: _owner.x -= (0.5f - (applyPivot ? _owner.pivotX : 0)) * dWidth; break; case RelationType.Right_Center: case RelationType.Right_Left: case RelationType.Right_Right: _owner.x -= (1 - (applyPivot ? _owner.pivotX : 0)) * dWidth; break; case RelationType.Middle_Middle: _owner.y -= (0.5f - (applyPivot ? _owner.pivotY : 0)) * dHeight; break; case RelationType.Bottom_Middle: case RelationType.Bottom_Top: case RelationType.Bottom_Bottom: _owner.y -= (1 - (applyPivot ? _owner.pivotY : 0)) * dHeight; break; } } if (!ToolSet.Approximately(ox, _owner.x) || !ToolSet.Approximately(oy, _owner.y)) { ox = _owner.x - ox; oy = _owner.y - oy; _owner.UpdateGearFromRelations(1, ox, oy); if (_owner.parent != null) { int transCount = _owner.parent._transitions.Count; for (int i = 0; i < transCount; i++) { _owner.parent._transitions[i].UpdateFromRelations(_owner.id, ox, oy); } } } }
void __targetSizeChanged(EventContext context) { if (_owner.relations.handling != null || _owner.group != null && _owner.group._updating != 0) { _targetData.Z = _target._width; _targetData.W = _target._height; return; } _owner.relations.handling = (GObject)context.sender; float ox = _owner.x; float oy = _owner.y; float ow = _owner._rawWidth; float oh = _owner._rawHeight; int cnt = _defs.Count; for (int i = 0; i < cnt; i++) { ApplyOnSizeChanged(_defs[i]); } _targetData.Z = _target._width; _targetData.W = _target._height; if (!ToolSet.Approximately(ox, _owner.x) || !ToolSet.Approximately(oy, _owner.y)) { ox = _owner.x - ox; oy = _owner.y - oy; _owner.UpdateGearFromRelations(1, ox, oy); if (_owner.parent != null) { int transCount = _owner.parent._transitions.Count; for (int i = 0; i < transCount; i++) { _owner.parent._transitions[i].UpdateFromRelations(_owner.id, ox, oy); } } } if (!ToolSet.Approximately(ow, _owner._rawWidth) || !ToolSet.Approximately(oh, _owner._rawHeight)) { ow = _owner._rawWidth - ow; oh = _owner._rawHeight - oh; _owner.UpdateGearFromRelations(2, ow, oh); } _owner.relations.handling = null; }
/// <summary> /// /// </summary> /// <param name="wv"></param> /// <param name="hv"></param> public void SetSize(float wv, float hv) { bool wc = !ToolSet.Approximately(wv, _contentRect.Width); bool hc = !ToolSet.Approximately(hv, _contentRect.Height); if (wc || hc) { _contentRect.Width = wv; _contentRect.Height = hv; OnSizeChanged(wc, hc); } }
void __targetXYChanged(EventContext context) { if (_owner.relations.handling != null || _owner.group != null && _owner.group._updating != 0) { _targetData.X = _target.x; _targetData.Y = _target.y; return; } _owner.relations.handling = (GObject)context.sender; float ox = _owner.x; float oy = _owner.y; float dx = _target.x - _targetData.X; float dy = _target.y - _targetData.Y; int cnt = _defs.Count; for (int i = 0; i < cnt; i++) { ApplyOnXYChanged(_defs[i], dx, dy); } _targetData.X = _target.x; _targetData.Y = _target.y; if (!ToolSet.Approximately(ox, _owner.x) || !ToolSet.Approximately(oy, _owner.y)) { ox = _owner.x - ox; oy = _owner.y - oy; _owner.UpdateGearFromRelations(1, ox, oy); if (_owner.parent != null) { int transCount = _owner.parent._transitions.Count; for (int i = 0; i < transCount; i++) { _owner.parent._transitions[i].UpdateFromRelations(_owner.id, ox, oy); } } } _owner.relations.handling = null; }