override public void Setup_AfterAdd(XML cxml) { base.Setup_AfterAdd(cxml); XML xml = cxml.GetNode("Button"); if (xml == null) { return; } this.title = (string)xml.GetAttribute("title"); this.icon = (string)xml.GetAttribute("icon"); string str; str = (string)xml.GetAttribute("titleColor"); if (str != null) { this.titleColor = ToolSet.ConvertFromHtmlColor(str); } str = (string)xml.GetAttribute("controller"); if (str != null) { _relatedController = parent.GetController(str); } else { _relatedController = null; } _pageOption.id = (string)xml.GetAttribute("page"); this.selected = (string)xml.GetAttribute("checked") == "true"; }
/** @inheritDoc */ public override Rect GetBounds(DisplayObject targetSpace) { Rect bounds = base.GetBounds(targetSpace); // if we have a scissor rect, intersect it with our bounds if (_clipRect != null) { Rect clip = GetClipRect(targetSpace); bounds = ToolSet.Intersection(ref bounds, ref clip); } return(bounds); }
protected override void AddStatus(string pageId, string value) { Color col = ToolSet.ConvertFromHtmlColor(value); if (pageId == null) { _default.color = col; } else { _storage[pageId] = new GearColorValue(col); } }
override public void Setup_AfterAdd(XML cxml) { base.Setup_AfterAdd(cxml); XML xml = cxml.GetNode("ComboBox"); if (xml == null) { return; } string str; str = (string)xml.GetAttribute("titleColor"); if (str != null) { this.titleColor = ToolSet.ConvertFromHtmlColor(str); } str = (string)xml.GetAttribute("visibleItemCount"); if (str != null) { _visibleItemCount = int.Parse(str); } XMLList col = xml.Elements("item"); _items = new string[col.Count]; _values = new string[col.Count]; int i = 0; foreach (XML ix in col) { _items[i] = ix.GetAttribute("title"); _values[i] = ix.GetAttribute("value"); i++; } this.text = (string)xml.GetAttribute("title"); if (str != null && str.Length > 0) { _selectedIndex = Array.IndexOf(_items, this.text); } else if (_items.Length > 0) { _selectedIndex = 0; } else { _selectedIndex = -1; } }
override public void Render(RenderSupport support, float parentAlpha) { if (_clipRect != null) { Rect clipRect = support.PushClipRect(GetClipRectNR(stage)); if (ToolSet.IsEmptyRect(ref clipRect)) { // empty clipping bounds - no need to render children. support.PopClipRect(); return; } } base.Render(support, parentAlpha); if (_clipRect != null) { support.PopClipRect(); } }
private void __mouseMove(object obj) { MouseEvent evt = (MouseEvent)obj; float xx = evt.StageX / GRoot.contentScaleFactor; float yy = evt.StageY / GRoot.contentScaleFactor; if (!ToolSet.IsEmptyRect(ref sDragBounds)) { if (xx < sDragBounds.x || yy < sDragBounds.y || xx + _owner.width > sDragBounds.xMax || yy + _owner.height > sDragBounds.yMax) { return; } } _owner.SetXY((int)(sLocalDragStart.x + xx - sGlobalDragStart.x), (int)(sLocalDragStart.y + yy - sGlobalDragStart.y)); }
private void __touchMove2(EventContext context) { InputEvent evt = context.inputEvent; float xx = evt.x / GRoot.contentScaleFactor; float yy = evt.y / GRoot.contentScaleFactor; if (!ToolSet.IsEmptyRect(ref sDragBounds)) { if (xx < sDragBounds.x || yy < sDragBounds.y || xx + _owner.width > sDragBounds.xMax || yy + _owner.height > sDragBounds.yMax) { return; } } _owner.SetXY((int)(sLocalDragStart.x + xx - sGlobalDragStart.x), (int)(sLocalDragStart.y + yy - sGlobalDragStart.y)); }
override public void Setup_AfterAdd(XML cxml) { base.Setup_AfterAdd(cxml); XML xml = cxml.GetNode("Label"); if (xml == null) { return; } this.title = (string)xml.GetAttribute("title"); this.icon = (string)xml.GetAttribute("icon"); string str = (string)xml.GetAttribute("titleColor"); if (str != null) { this.titleColor = ToolSet.ConvertFromHtmlColor(str); } }
/** The clipping rectangle can be used to limit rendering in the current render target to * a certain area. This method expects the rectangle in stage coordinates. Internally, * it uses the 'scissorRectangle' of stage3D, which works with pixel coordinates. * Any pushed rectangle is intersected with the previous rectangle; the method returns * that intersection. */ //public Rectangle PushClipRect(Rectangle rectangle) //{ // if (mClipRectStack.Count < mClipRectStackSize + 1) // mClipRectStack.Add(new Rectangle()); // mClipRectStack[mClipRectStackSize].copyFrom(rectangle); // rectangle = mClipRectStack[mClipRectStackSize]; // // intersect with the last pushed clip rect // if (mClipRectStackSize > 0) // rectangle.intersect(mClipRectStack[mClipRectStackSize-1], // rectangle); // ++mClipRectStackSize; // ApplyClipRect(); // // return the intersected clip rect so callers can skip draw calls if it's empty // return rectangle; //} public Rect PushClipRect(Rect rectangle) { if (mClipRectStack.Count < mClipRectStackSize + 1) { mClipRectStack.Add(new Rect()); } mClipRectStack[mClipRectStackSize] = rectangle; // intersect with the last pushed clip rect if (mClipRectStackSize > 0) { Rect clip = mClipRectStack[mClipRectStackSize - 1]; rectangle = ToolSet.Intersection(ref clip, ref rectangle); mClipRectStack[mClipRectStackSize] = rectangle; } ++mClipRectStackSize; ApplyClipRect(); // return the intersected clip rect so callers can skip draw calls if it's empty return(rectangle); }
void MouseEvents(Vector2 mousePosition, TouchInfo touch, bool mouseLeftDown, bool mouseLeftUp, bool mouseRightDown, bool mouseRightUp) { bool hitTested = false; if (mousePosition.x >= 0 && mousePosition.y >= 0) { if (touch.x != mousePosition.x || touch.y != mousePosition.y) { touchPosition = mousePosition; touch.x = mousePosition.x; touch.y = mousePosition.y; _touchTarget = HitTest(mousePosition, true); hitTested = true; touch.target = _touchTarget; touch.UpdateEvent(); onTouchMove.Call(touch.evt); if (touch.lastRollOver != _touchTarget) { HandleRollOver(touch); } } } else { mousePosition = touchPosition; } if (mouseLeftDown) { if (!touch.began) { touch.began = true; _touchCount++; touch.clickCancelled = false; touch.downX = touch.x; touch.downY = touch.y; if (!hitTested) { _touchTarget = HitTest(mousePosition, true); hitTested = true; touch.target = _touchTarget; } this.focus = _touchTarget; if (_touchTarget != null) { touch.UpdateEvent(); _touchTarget.onTouchBegin.BubbleCall(touch.evt); } } } if (mouseLeftUp) { if (touch.began) { touch.began = false; _touchCount--; if (!hitTested) { _touchTarget = HitTest(mousePosition, true); hitTested = true; touch.target = _touchTarget; } if (_touchTarget != null) { touch.UpdateEvent(); _touchTarget.onTouchEnd.BubbleCall(touch.evt); if (!touch.clickCancelled && Mathf.Abs(touch.x - touch.downX) < 50 && Mathf.Abs(touch.y - touch.downY) < 50) { if (ToolSet.RealtimeSinceStartup() - touch.lastClickTime < 0.35f) { if (touch.clickCount == 2) { touch.clickCount = 1; } else { touch.clickCount++; } } else { touch.clickCount = 1; } touch.lastClickTime = ToolSet.RealtimeSinceStartup(); touch.UpdateEvent(); _touchTarget.onClick.BubbleCall(touch.evt); } } } } if (mouseRightDown) { if (!hitTested) { _touchTarget = HitTest(mousePosition, true); hitTested = true; touch.target = _touchTarget; } if (_touchTarget != null) { touch.UpdateEvent(); _touchTarget.onRightClick.BubbleCall(touch.evt); } } }
override public void Setup_BeforeAdd(XML xml) { base.Setup_BeforeAdd(xml); string str; this.displayAsPassword = (string)xml.GetAttribute("password") == "true"; str = (string)xml.GetAttribute("font"); if (str != null) { _font = str; } str = (string)xml.GetAttribute("fontSize"); if (str != null) { _fontSize = int.Parse(str); } str = (string)xml.GetAttribute("color"); if (str != null) { _textFormat.color = ToolSet.ConvertFromHtmlColor(str); } str = (string)xml.GetAttribute("align"); if (str != null) { _align = FieldTypes.parseAlign(str); } str = (string)xml.GetAttribute("vAlign"); if (str != null) { _verticalAlign = FieldTypes.parseVerticalAlign(str); } str = (string)xml.GetAttribute("leading"); if (str != null) { _leading = int.Parse(str); } else { _leading = 3; } str = (string)xml.GetAttribute("letterSpacing"); if (str != null) { _letterSpacing = int.Parse(str); } _ubbEnabled = (string)xml.GetAttribute("ubb") == "true"; this.displayAsPassword = (string)xml.GetAttribute("password") == "true"; str = (string)xml.GetAttribute("autoSize"); _updatingSize = true; if (str != null) { this.autoSize = FieldTypes.parseAutoSizeType(str); } UpdateTextFormat(); _updatingSize = false; str = (string)xml.GetAttribute("text"); if (str != null && str.Length > 0) { this.text = (string)xml.GetAttribute("text"); } else { this.text = (string)xml.GetAttribute("demoText"); } }