// ReSharper restore MemberCanBePrivate.Global #endregion protected override void CreateChildren() { base.CreateChildren(); #region Background _background = new RectShape { Id = "background", Left = 0, Right = 0, Top = 0, Bottom = 0 }; AddChild(_background); #endregion #region Border _border = new RectShape { Id = "border", Left = 0, Right = 0, Top = 0, Bottom = 0, MouseEnabled = false }; AddChild(_border); #endregion #region Header background _headerBackground = new RectShape { Id = "headerBackground", //Color = (Color?)GetStyle("headerBackgroundColor"), Left = 1, Right = 1, Top = 1, Height = 50 }; AddChild(_headerBackground); #endregion #region Header group HeaderGroup = new Group { Id = "headerGroup", Layout = new AbsoluteLayout(), Left = 1, Right = 1, Top = 1, Height = 50 }; AddChild(HeaderGroup); #endregion #region Icon + label group HGroup hgroup = new HGroup { Left = 10, VerticalCenter = 0, Gap = 6, VerticalAlign = VerticalAlign.Middle }; HeaderGroup.AddChild(hgroup); #endregion #region Icon display HeaderIconDisplay = new Image { //Id = "titleLabel", //Text = "miki!", Left = 10, VerticalCenter = 0 }; hgroup.AddChild(HeaderIconDisplay); #endregion #region Title label TitleDisplay = new Label { //Id = "titleLabel", Left = 10, VerticalCenter = 0 }; //TitleLabel.SetStyle("textColor", UnityEngine.Color.white); hgroup.AddChild(TitleDisplay); #endregion #region Tools ToolGroup = new Group { Id = "toolGroup", Layout = new HorizontalLayout { HorizontalAlign = HorizontalAlign.Right, VerticalAlign = VerticalAlign.Middle, Gap = 4 }, Right = 6, VerticalCenter = 0, MouseEnabled = true // not draggable when clicking space between buttons --- false // to be draggable on possible tools label click }; HeaderGroup.AddChild(ToolGroup); #endregion #region Content background _contentGroupBackground = new RectShape { Left = 6, Right = 6, Top = 50, Bottom = 50 }; AddChild(_contentGroupBackground); #endregion #region Scroller _scroller = new Scroller { SkinClass = EvaluateSkinClassFromStyle("scrollerSkin"), Left = 6, Right = 6, Top = 50, Bottom = 50 }; AddChild(_scroller); #endregion #region Content group ContentGroup = new Group { Id = "contentGroup", //Left = 6, //Right = 6, //Top = 50, //Bottom = 50 }; //AddChild(ContentGroup); _scroller.Viewport = ContentGroup; #endregion #region Control bar background _controlBarBackground = new RectShape { Id = "controlBarBackground", Left = 1, Right = 1, Bottom = 1, Height = 50, Alpha = 0.5f // note: alpha! }; AddChild(_controlBarBackground); #endregion #region Control bar ControlBarGroup = new Group { Id = "controlBar", Layout = new HorizontalLayout { HorizontalAlign = HorizontalAlign.Right, VerticalAlign = VerticalAlign.Middle, Gap = 4, PaddingLeft = 6, PaddingRight = 6, PaddingTop = 6, PaddingBottom = 6 }, Left = 1, Right = 1, Bottom = 1, Height = 50, MouseEnabled = true // not draggable when clicking space between buttons --- false // to be draggable on possible tools label click }; AddChild(ControlBarGroup); #endregion }
protected override void CreateChildren() { base.CreateChildren(); #region Background _background = new RectShape { Id = "background", Left = 0, Right = 0, Top = 0, Bottom = 0 }; AddChild(_background); #endregion #region Border _border = new RectShape { Id = "overlay", Left = 0, Right = 0, Top = 0, Bottom = 0, MouseEnabled = false }; AddChild(_border); #endregion #region Header background _headerBackground = new RectShape { Id = "headerBackground", //Color = (Color?)GetStyle("headerBackgroundColor"), Left = 1, Right = 1, Top = 1, Height = 50 }; AddChild(_headerBackground); #endregion #region Header group HeaderGroup = new Group { Id = "headerGroup", Layout = new AbsoluteLayout(), Left = 1, Right = 1, Top = 1, Height = 50, MouseEnabled = true }; AddChild(HeaderGroup); #endregion #region Icon + label group _labelGroup = new HGroup { Left = 10, VerticalCenter = 0, Gap = 6, VerticalAlign = VerticalAlign.Middle, ClipAndEnableScrolling = true }; HeaderGroup.AddChild(_labelGroup); #endregion #region Icon display HeaderIconDisplay = new Image(); _labelGroup.AddChild(HeaderIconDisplay); #endregion #region Label display TitleDisplay = new Label(); _labelGroup.AddChild(TitleDisplay); #endregion #region Move area MoveArea = new Group { Id = "move_area", Layout = new AbsoluteLayout(), Left = 0, Right = 0, Top = 0, Bottom = 0, MouseEnabled = true }; HeaderGroup.AddChild(MoveArea); #endregion #region Tools ToolGroup = new Group { Id = "toolGroup", Layout = new HorizontalLayout { HorizontalAlign = HorizontalAlign.Right, VerticalAlign = VerticalAlign.Middle, Gap = 4 }, Right = 6, VerticalCenter = 0, MouseEnabled = true // not draggable when clicking space between buttons --- false // to be draggable on possible tools label click }; HeaderGroup.AddChild(ToolGroup); #endregion #region Content background _contentGroupBackground = new RectShape { Id = "contentGroupBackground", //Color = Color.white, Left = 6, Right = 6, Top = 50, Bottom = 50 }; AddChild(_contentGroupBackground); #endregion #region Scroller _scroller = new Scroller { Left = 6, Right = 6, Top = 50, Bottom = 50 }; AddChild(_scroller); #endregion #region Content group ContentGroup = new HGroup { Id = "contentGroup", Gap = 10, PaddingLeft = 10, PaddingRight = 10, PaddingTop = 10, PaddingBottom = 10, HorizontalAlign = HorizontalAlign.Center, VerticalAlign = VerticalAlign.Middle }; AddChild(ContentGroup); _scroller.Viewport = ContentGroup; #endregion #region Icon IconDisplay = new Image(); ContentGroup.AddChild(IconDisplay); #endregion #region Message display MessageDisplay = new Label { Multiline = true, MaxWidth = 800, MaxHeight = 600, Color = Color.black, }; MessageDisplay.SetStyle("labelStyle", GetStyle("labelStyle")); MessageDisplay.SetStyle("font", GetStyle("labelFont")); ContentGroup.AddChild(MessageDisplay); #endregion #region Control bar background _controlBarBackground = new RectShape { Id = "controlBarBackground", Left = 1, Right = 1, Bottom = 1, Height = 50, Alpha = 0.5f, MouseEnabled = false }; AddChild(_controlBarBackground); #endregion #region Control bar ControlBarGroup = new Group { Id = "controlBar", //ClipAndEnableScrolling = true, // this introduces a child positioning bug Layout = new HorizontalLayout { HorizontalAlign = HorizontalAlign.Right, VerticalAlign = VerticalAlign.Bottom, Gap = 4, PaddingLeft = 6, PaddingRight = 6, PaddingTop = 6, PaddingBottom = 6 }, ClipAndEnableScrolling = true, Left = 1, Right = 1, Bottom = 1, Height = 50, MouseEnabled = true // not draggable when clicking space between buttons --- false // to be draggable on possible tools label click }; AddChild(ControlBarGroup); #endregion }
// ReSharper restore MemberCanBePrivate.Global #endregion protected override void CreateChildren() { //Debug.Log("Button skin creating children"); base.CreateChildren(); #region Background _background = new RectShape { Left = 0, Right = 0, Top = 0, Bottom = 0, Alpha = 0.5f }; //_background.SetStyle("backgroundStyle", ButtonStyle.Instance); AddChild(_background); #endregion #region Box Group box = new Group { HorizontalCenter = 0, VerticalCenter = 0 }; AddChild(box); _boxBg = new RectShape { Left = 0, Right = 0, Top = 0, Bottom = 0, HorizontalCenter = 0, VerticalCenter = 0, /*MinWidth = 300, MinHeight = 100*/ }; //_background.SetStyle("backgroundStyle", ButtonStyle.Instance); _background.SetStyle("backgroundColor", Color.blue); box.AddChild(_boxBg); #endregion HGroup hGroup = new HGroup { Left = 10, Right = 10, Top = 10, Bottom = 10, HorizontalCenter = 0, VerticalCenter = 0, VerticalAlign = VerticalAlign.Middle }; box.AddChild(hGroup); #region Icon IconDisplay = new Image { MouseEnabled = false }; hGroup.AddChild(IconDisplay); #endregion #region Label LabelDisplay = new Label { Text = "miki", MouseEnabled = false, //Width = 100 }; hGroup.AddChild(LabelDisplay); #endregion }
override protected void CreateChildren() { base.CreateChildren(); #region Controls Toolbar toolbar = new Toolbar(); toolbar.Plugins.Add(new TabManager { ArrowsEnabled = true }); AddChild(toolbar); #region Text field _txtSearch = new TextField { StyleName = "search", Text = "croatian coast", FocusEnabled = true, Width = 400 }; _txtSearch.SetFocus(); _txtSearch.KeyUp += delegate(Event e) { KeyboardEvent ke = (KeyboardEvent)e; if (ke.KeyCode == KeyCode.Return) { _newSearch = true; Search(); } }; toolbar.AddContentChild(_txtSearch); #endregion Button btnLoad = new Button { Text = "Load data", SkinClass = typeof(ImageButtonSkin), Icon = ImageLoader.Instance.Load("Icons/arrow_refresh"), AutoRepeat = true }; btnLoad.ButtonDown += delegate { Search(); btnLoad.Text = "Load more..."; }; toolbar.AddContentChild(btnLoad); Button btnClear = new Button { Text = "Remove all", SkinClass = typeof(ImageButtonSkin), Icon = ImageLoader.Instance.Load("Icons/cancel"), AutoRepeat = true }; btnClear.ButtonDown += delegate { _scroller.Visible = false; _dataProvider.RemoveAll(); btnLoad.Text = "Load data"; }; toolbar.AddContentChild(btnClear); #endregion #region Lower group Group group = new Group { PercentWidth = 100, PercentHeight = 100 }; AddChild(group); #endregion #region Title label Label label = new TitleLabel { HorizontalCenter = 0, VerticalCenter = 0, StyleName = "title" }; group.AddChild(label); new TextRotator { Delay = 5, // 5 seconds delay Lines = new[] { "Load Data Demo", "Created with eDriven.Gui", "Loads images from Flickr"/*, "Author: Danko Kozar"*/ }, Callback = delegate(string line) { label.Text = line; } } .Start(); #endregion #region Scroller / viewport _scroller = new Scroller { SkinClass = typeof (ScrollerSkin2), PercentWidth = 100, PercentHeight = 100, Visible = false }; _scroller.SetStyle("showEffect", _scrollerShow); group.AddChild(_scroller); Group viewport = new Group { /*MouseEnabled = true, Layout = new VerticalLayout { HorizontalAlign = HorizontalAlign.Left, PaddingLeft = 10, PaddingRight = 10, PaddingTop = 10, PaddingBottom = 10, Gap = 10 }*/ }; _scroller.Viewport = viewport; #endregion #region Data controls List<object> source = new List<object>(); _dataProvider = new ArrayList(source); /* LISTS */ #region HGroup #endregion #region List _list = new List { Left = 10, Right = 10, Top = 10, Bottom = 10, Layout = new TileLayout { HorizontalGap = 0, VerticalGap = 0/*, RequestedRowCount = 4, RequestedColumnCount = 3*/ }, DataProvider = _dataProvider, SkinClass = typeof(ListSkin2), ItemRenderer = new ItemRendererFactory<ThumbnailItemRenderer>(), LabelFunction = LabelFunction // extracting the title }; viewport.AddChild(_list); #endregion #endregion // bubbling event listener AddEventListener("showImage", ShowImageHandler); }
//private void RemoveHandler(Event e) //{ // DisplayObject popup = e.Target as DisplayObject; // if (null != popup) // { // popup.RemoveEventListener(MouseEvent.MOUSE_DOWN_OUTSIDE, RemoveHandler); // popup.RemoveEventListener(MouseEvent.MOUSE_WHEEL_OUTSIDE, RemoveHandler); // TerminatePopup(popup); // } // if (_popups.Count == 0 && SystemManager.Instance.HasEventListener(ResizeEvent.RESIZE)) // SystemManager.Instance.RemoveEventListener(ResizeEvent.RESIZE, RemoveHandler); //} //private static void TerminatePopup(DisplayObject popup) //{ // //Debug.Log("TerminatePopup"); // var dlm = popup as DisplayListMember; // if (null != dlm) // { // Instance.RemovePopup(dlm); // // TODO: SystemManager.Instance.RemoveEventListener(ResizeEvent.RESIZE, ...); // dlm.Dispose(); // } //} #endregion #region Add /// <summary> /// Adds a popup to popup stage /// </summary> /// <param name="popup">A popup to add</param> /// <param name="options">Popup options</param> public void AddPopup(DisplayListMember popup, params PopupOption[] options) { Event e = new Event(OPENING, popup, false, true); // cancelable DispatchEvent(e); if (e.Canceled) return; if (IsDefaultPrevented(OPENING)) return; if (_popups.Contains(popup)) return; #if DEBUG if (DebugMode) { Debug.Log("AddPopup"); } #endif DisplayObjectContainer parent = null; bool modal = true; bool centered = true; bool keepCenter = false; bool removeOnMouseDownOutside = false; bool removeOnMouseWheelOutside = false; bool removeOnScreenResize = false; bool autoFocus = true; bool focusPreviousOnHide = true; Stage stage = _stage; bool visibleFlag = popup.Visible; popup.Visible = false; int len = options.Length; for (int i = 0; i < len; i++) { PopupOption option = options[i]; switch (option.Type) { case PopupOptionType.Parent: parent = (DisplayObjectContainer)option.Value; break; case PopupOptionType.Modal: modal = (bool)option.Value; break; case PopupOptionType.Centered: centered = (bool)option.Value; break; case PopupOptionType.KeepCenter: keepCenter = (bool)option.Value; break; case PopupOptionType.RemoveOnMouseDownOutside: removeOnMouseDownOutside = (bool)option.Value; break; case PopupOptionType.RemoveOnMouseWheelOutside: removeOnMouseWheelOutside = (bool)option.Value; break; case PopupOptionType.RemoveOnScreenResize: removeOnScreenResize = (bool)option.Value; break; case PopupOptionType.AutoFocus: autoFocus = (bool)option.Value; break; case PopupOptionType.FocusPreviousOnHide: focusPreviousOnHide = (bool)option.Value; break; case PopupOptionType.Stage: //Debug.Log("Exotic stage: " + option.Value); stage = (Stage)option.Value; break; default: throw new Exception("Unknown option"); } } _popups.Add(popup); if (null == parent) parent = stage; DisplayListMember overlay = null; Group popupRoot = null; InvalidationManagerClient imc = popup as InvalidationManagerClient; Component comp = popup as Component; if (null != comp) comp.IsPopUp = true; if (modal) { overlay = (DisplayListMember)Activator.CreateInstance(ModalOverlayType); overlay.AddEventListener(MouseEvent.MOUSE_DOWN, OnOverlayMouseDown); // we are packing both the overlay and the popup to into an aditional container popupRoot = new Group(); stage.AddChild(popupRoot); // BUG BUG BUG! If we do _stage.AddChild(popupRoot); AFTER the children are added, we get a null exception // this is the major problem when adding children, started appearing since 10.1.2012 // solved. This had to to with the creationcomplete method, which has to be run after the complete invalidation pass popupRoot.AddChild(overlay); popupRoot.AddChild(popup); // popup has been added to popup stage // invalidation methods have been called upon the addition // now we want to run measure (to validate dimensions) // because we want to center the popup // now, the absolute layout won't do it on his own //overlay.Bounds = (Rectangle)parent.Bounds.Clone(); overlay.Width = PopupManagerStage.Instance.Width; overlay.Height = PopupManagerStage.Instance.Height; /*var client = overlay as InvalidationManagerClient; if (client != null) { /*var imc2 = client; imc2.SetActualSize( PopupManagerStage.Instance.Width, PopupManagerStage.Instance.Height/*, Math.Max(imc2.GetExplicitOrMeasuredWidth(), imc2.MinWidth), Math.Max(imc2.GetExplicitOrMeasuredHeight(), imc2.MinHeight)#2# );#1# client.Width = PopupManagerStage.Instance.Width; client.Height = PopupManagerStage.Instance.Height; //imc2.InvalidateTransform(); } else { overlay.X = parent.X; overlay.Y = parent.Y; /*overlay.X = parent.X; overlay.Y = parent.Y;#1# }*/ } else { stage.AddChild(popup); } if (null != imc) { //InvalidationManager.Instance.ValidateClient(imc, true); imc.ValidateNow(); //Debug.Log(string.Format("imc.Width:{0}, imc.Height:{1}", imc.Width, imc.Height)); //Debug.Log(string.Format("imc.GetExplicitOrMeasuredWidth():{0}, imc.GetExplicitOrMeasuredHeight():{1}", imc.GetExplicitOrMeasuredWidth(), imc.GetExplicitOrMeasuredHeight())); //imc.SetActualSize(imc.GetExplicitOrMeasuredWidth(), imc.GetExplicitOrMeasuredHeight()); imc.SetActualSize( Math.Min(Math.Max(imc.GetExplicitOrMeasuredWidth(), imc.MinWidth), imc.MaxWidth), Math.Min(Math.Max(imc.GetExplicitOrMeasuredHeight(), imc.MinHeight), imc.MaxHeight) ); } var descriptor = new PopupDescriptor(parent, overlay, popupRoot) { Popup = popup, PopupRoot = modal ? popupRoot : popup, Owner = parent, Modal = modal, Centered = centered, KeepCenter = keepCenter, RemoveOnMouseDownOutside = removeOnMouseDownOutside, RemoveOnMouseWheelOutside = removeOnMouseWheelOutside, RemoveOnScreenResize = removeOnScreenResize, FocusPreviousOnHide = focusPreviousOnHide, Stage = stage }; _descriptors.Add(popup, descriptor); if (centered) { CenterPopUp(popup); } InteractiveComponent ic = popup as InteractiveComponent; if (autoFocus && null != ic) { ic.SetFocus(); // TEMP disabled, 2.1.2012. //FocusManager.Instance.SetFocus(ic); /*ic.Defer(delegate { //ic.SetFocus(); FocusManager.Instance.SetFocus(ic); }, 1);*/ } // connect if not connected if (_descriptors.Count > 0) { SystemManager.Instance.ResizeSignal.Connect(ResizeSlot); SystemManager.Instance.MouseDownSignal.Connect(MouseDownSlot); SystemManager.Instance.RightMouseDownSignal.Connect(MouseDownSlot); SystemManager.Instance.MiddleMouseDownSignal.Connect(MouseDownSlot); SystemManager.Instance.MouseWheelSignal.Connect(MouseWheelSlot); // subscribe to stage to see if some component has been mouse-downed // NOTE: some components (i.e. window close button) could cancel the event, this is by design // note: it is safe ta call it multiple times, it is checked internally stage.AddEventListener(MouseEvent.MOUSE_DOWN, MouseDownHandler); } else { SystemManager.Instance.ResizeSignal.Disconnect(ResizeSlot); SystemManager.Instance.MouseDownSignal.Disconnect(MouseDownSlot); SystemManager.Instance.RightMouseDownSignal.Disconnect(MouseDownSlot); SystemManager.Instance.MiddleMouseDownSignal.Disconnect(MouseDownSlot); SystemManager.Instance.MouseWheelSignal.Disconnect(MouseWheelSlot); //MouseEventDispatcher.Instance.RemoveEventListener(MouseEvent.MOUSE_DOWN, MouseDownHandler); stage.RemoveEventListener(MouseEvent.MOUSE_DOWN, MouseDownHandler); } // NOTE: This is needed when having effects because of the flicker (?): //descriptor.PopupRoot.SkipRender(100); // bring the popup root to front descriptor.PopupRoot.BringToFront(); popup.Visible = visibleFlag; DispatchEvent(new Event(OPEN, popup)); }
protected override void CreateChildren() { base.CreateChildren(); #region Popup anchor _anchor = new PopUpAnchor { Id = "pop_up", Left = 0, Right = 0, Top = 0, Bottom = 0, PopupPosition = PopupPosition.Below, PopupWidthMatchesAnchorWidth = true }; AddChild(_anchor); #endregion #region DropDown DropDown = new Group { Id = "drop_down", MaxHeight = 134, MinHeight = 22, Width = 150 }; //AddChild(DropDown); _anchor.Popup = DropDown; #endregion #region Background _background = new RectShape { Id = "background", Left = 0, Right = 0, Top = 0, Bottom = 0 }; DropDown.AddChild(_background); #endregion #region Scroller _scroller = new Scroller { Id = "scroller", SkinClass = EvaluateSkinClassFromStyle("scrollerSkin"), Left = 0, Right = 0, Top = 0, Bottom = 0, MinViewportInset = 1, HasFocusableChildren = false, Height = 100 }; DropDown.AddChild(_scroller); #endregion #region Data group DataGroup = new DataGroup { Id = "data_group", ItemRenderer = new ItemRendererFactory<DefaultItemRenderer>(), Layout = new VerticalLayout { Gap = 0, HorizontalAlign = HorizontalAlign.ContentJustify, RequestedMinRowCount = 5 } }; _scroller.Viewport = DataGroup; #endregion #region Border _border = new RectShape { Id = "border", Left = 0, Right = 0, Top = 0, Bottom = 0, MouseEnabled = false }; DropDown.AddChild(_border); #endregion #region OpenButton OpenButton = new Button { Left = 0, Right = 0, Top = 0, Bottom = 0, FocusEnabled = false, SkinClass = typeof(DropDownListButtonSkin) }; AddChild(OpenButton); #endregion #region Label LabelDisplay = new Label { VerticalCenter = 0, Left = 7, Right = 32, Top = 2, Bottom = 2, Width = 75, MouseEnabled = false, Color = Color.black }; //LabelDisplay.SetStyle("color", GetStyle("textColor")); AddChild(LabelDisplay); #endregion }
// ReSharper restore MemberCanBePrivate.Global #endregion protected override void CreateChildren() { base.CreateChildren(); #region Background _background = new RectShape { Id = "background", Color = Color.white, Left = 0, Right = 0, Top = 0, Bottom = 0 }; AddChild(_background); _backgroundImage = new Image { //Id = "background_image", Left = 0, Right = 0, Top = 0, Bottom = 0, Visible = false, //Rotation = 30, //AspectRatio = 4, ScaleMode = ImageScaleMode.ScaleToFill }; AddChild(_backgroundImage); #endregion #region Header background _headerBackground = new RectShape { Id = "headerBackground", //Color = RgbColor.FromHex(0x000fff).ToColor(), BackgroundColor = (Color) GetStyle("headerBackgroundColor"), Left = 0, Right = 0, Top = 0, Height = 80 }; AddChild(_headerBackground); #endregion #region Header group HeaderGroup = new Group { Id = "headerGroup", Layout = new AbsoluteLayout(), Left = 0, Right = 0, Top = 0, Height = 80 }; AddChild(HeaderGroup); #endregion #region Title label TitleDisplay = new Label { Id = "titleLabel", Left = 10, VerticalCenter = 0 }; //TitleLabel.SetStyle("textColor", UnityEngine.Color.white); HeaderGroup.AddChild(TitleDisplay); #endregion #region Tools ToolGroup = new Group { Id = "toolGroup", Layout = new HorizontalLayout { HorizontalAlign = HorizontalAlign.Right, VerticalAlign = VerticalAlign.Middle, Gap = 4 }, Right = 6, VerticalCenter = 0, MouseEnabled = true // not draggable when clicking space between buttons --- false // to be draggable on possible tools label click }; HeaderGroup.AddChild(ToolGroup); #endregion #region Scroller _scroller = new Scroller { SkinClass = EvaluateSkinClassFromStyle("scrollerSkin"), Left = 0, Right = 0, Top = 80, Bottom = 50 }; AddChild(_scroller); #endregion #region Content group ContentGroup = new Group { Id = "contentGroup" }; //AddChild(ContentGroup); _scroller.Viewport = ContentGroup; #endregion #region Control bar background _controlBarBackground = new RectShape { Id = "controlBarBackground", BackgroundColor = ColorMixer.FromHex(0x000fff).ToColor(), Left = 0, Right = 0, Bottom = 0, Height = 50, //Alpha = 0.5f }; AddChild(_controlBarBackground); #endregion #region Control bar ControlBarGroup = new Group { Id = "controlBar", Layout = new HorizontalLayout { HorizontalAlign = HorizontalAlign.Right, VerticalAlign = VerticalAlign.Middle, Gap = 4, PaddingLeft = 10, PaddingRight = 10, PaddingTop = 10, PaddingBottom = 10 }, Left = 0, Right = 0, Bottom = 0, Height = 50, MouseEnabled = true // not draggable when clicking space between buttons --- false // to be draggable on possible tools label click }; AddChild(ControlBarGroup); #endregion #region Border _border = new RectShape { Id = "border", Left = 0, Right = 0, Top = 0, Bottom = 0, MouseEnabled = false }; AddChild(_border); #endregion }
protected override void CreateChildren() { base.CreateChildren(); #region Dec _btnDec = new Button { Text = "<", FocusEnabled = FocusEnabled, ResizeWithContent = true, ResizeWithStyleBackground = true, Styles = _buttonStyles, //Padding = 0 }; _btnDec.SetStyle("paddingLeft", 0); _btnDec.SetStyle("paddingRight", 0); _btnDec.SetStyle("paddingTop", 0); _btnDec.SetStyle("paddingBottom", 0); _btnDec.SetStyle("buttonStyle", GetStyle("decButtonStyle")); _btnDec.Press += delegate { Browse(-1); }; AddChild(_btnDec); #endregion _placeholder = new Group { Layout = new HorizontalLayout { Gap = 2, VerticalAlign = VerticalAlign.Middle } }; _placeholder.AddEventListener(ButtonEvent.PRESS, delegate(Event e) { if (e.Target is Button) { CurrentPageIndex = _placeholder.GetChildIndex((DisplayListMember)e.Target); } }); AddChild(_placeholder); for (int i = 0; i < MaxButtons; i++) { _placeholder.AddChild(CreateButton(i)); } //CreateButton(0); #region Text Field - old // _txtPage = new TextField // { // FocusEnabled = true, // Width = 35, // Text = (CurrentPage + 1).ToString(), // //Styles = buttonStyles // }; // _txtPage.Change += delegate // { // Debug.Log("_txtPage.Text: " + _txtPage.Text); // int i = CurrentPage; // try { // i = Convert.ToInt32(_txtPage.Text); // } //// ReSharper disable EmptyGeneralCatchClause // catch { /* silent fail */ } //// ReSharper restore EmptyGeneralCatchClause // Debug.Log("i: " + i); // CurrentPage = Mathf.Clamp(i, 0, TotalPages); // Debug.Log("Change: " + CurrentPage); // _txtPage.Text = CurrentPage.ToString(); // }; // AddChild(_txtPage); #endregion #region Inc _btnInc = new Button { Text = ">", FocusEnabled = FocusEnabled, ResizeWithContent = true, ResizeWithStyleBackground = true, Styles = _buttonStyles, //Padding = 0 }; _btnInc.SetStyle("paddingLeft", 0); _btnInc.SetStyle("paddingRight", 0); _btnInc.SetStyle("paddingTop", 0); _btnInc.SetStyle("paddingBottom", 0); _btnInc.SetStyle("buttonStyle", GetStyle("incButtonStyle")); _btnInc.Press += delegate { Browse(1); }; AddChild(_btnInc); #endregion }
protected override void CreateChildren() { base.CreateChildren(); /*#region Background _background = new RectShape { Id = "background", Left = 0, Right = 0, Top = 0, Bottom = 0 }; AddChild(_background); #endregion*/ #region Background image _backgroundImage = new Image { //Id = "background_image", Left = 0, Right = 0, Top = 0, Bottom = 0, Visible = false, Mode = ImageMode.Tiled }; AddChild(_backgroundImage); #endregion #region Border _border = new RectShape { Id = "overlay", Left = 0, Right = 0, Top = 0, Bottom = 0, MouseEnabled = false }; AddChild(_border); #endregion #region Header background _headerBackground = new RectShape { Id = "headerBackground", Left = 1, Right = 1, Top = 1, Height = 50 }; AddChild(_headerBackground); #endregion #region Header group HeaderGroup = new Group { Id = "headerGroup", Layout = new AbsoluteLayout(), Left = 1, Right = 1, Top = 1, Height = 50, MouseEnabled = true }; AddChild(HeaderGroup); #endregion #region Icon + label group _labelGroup = new HGroup { Left = 10, VerticalCenter = 0, Gap = 6, VerticalAlign = VerticalAlign.Middle, ClipAndEnableScrolling = true }; HeaderGroup.AddChild(_labelGroup); #endregion #region Icon display HeaderIconDisplay = new Image(); _labelGroup.AddChild(HeaderIconDisplay); #endregion #region Label display TitleDisplay = new Label(); _labelGroup.AddChild(TitleDisplay); #endregion #region Move area MoveArea = new Group { Id = "move_area", Layout = new AbsoluteLayout(), Left = 0, Right = 0, Top = 0, Bottom = 0, MouseEnabled = true }; HeaderGroup.AddChild(MoveArea); #endregion #region Tools ToolGroup = new Group { Id = "toolGroup", Layout = new HorizontalLayout { HorizontalAlign = HorizontalAlign.Right, VerticalAlign = VerticalAlign.Middle, Gap = 4 }, Right = 6, VerticalCenter = 0, MouseEnabled = true // not draggable when clicking space between buttons --- false // to be draggable on possible tools label click }; HeaderGroup.AddChild(ToolGroup); #endregion #region Content background _contentGroupBackground = new RectShape { Id = "contentGroupBackground", //Color = Color.white, Left = 6, Right = 6, Top = 50, Bottom = 50 }; AddChild(_contentGroupBackground); #endregion #region Scroller _scroller = new Scroller { Left = 6, Right = 6, Top = 50, Bottom = 50 }; AddChild(_scroller); #endregion #region Content group ContentGroup = new Group { Id = "contentGroup", //Left = 6, //Right = 6, //Top = 50, //Bottom = 50 }; AddChild(ContentGroup); _scroller.Viewport = ContentGroup; #endregion #region Control bar background _controlBarBackground = new RectShape { Id = "controlBarBackground", Left = 1, Right = 1, Bottom = 1, Height = 50, Alpha = 0.5f, MouseEnabled = false }; AddChild(_controlBarBackground); #endregion #region Control bar ControlBarGroup = new Group { Id = "controlBar", ClipAndEnableScrolling = true, Layout = new HorizontalLayout { HorizontalAlign = HorizontalAlign.Right, VerticalAlign = VerticalAlign.Bottom, Gap = 4, PaddingLeft = 6, PaddingRight = 6, PaddingTop = 6, PaddingBottom = 6 }, Left = 1, Right = 1, Bottom = 1, Height = 50, MouseEnabled = true }; AddChild(ControlBarGroup); #endregion }
override protected void CreateChildren() { base.CreateChildren(); Button button; #region View + vertical scrollbar _view = new VGroup { Id = "view", ClipAndEnableScrolling = true, Left = 0, /*Right = 16, */Top = 0, Bottom = 0, PaddingLeft = 10, PaddingRight = 10, PaddingTop = 10, PaddingBottom = 10, Gap = 6, StopMouseWheelPropagation = true }; AddContentChild(_view); _vScrollBar = new VScrollBar { Left = null, Right = 0, Top = 0, Bottom = 0, Viewport = _view, SkinClass = typeof(VScrollBarSkin3) }; AddContentChild(_vScrollBar); //_vScrollBar.ValidateNow(); //_view.Right = _vScrollBar.MeasuredWidth; #endregion for (int i = 0; i < 14; i++) { button = new Button { Text = "Button " + (i + 1), SkinClass = typeof(ImageButtonSkin), FocusEnabled = false, Icon = ImageLoader.Instance.Load("Icons/shape_square_add") }; //button.Click += delegate { AddButton(); }; _view.AddChild(button); } List<string> icons = new List<string> { "maximize", "cancel" }; for (int i = 0; i < icons.Count; i++) { button = new Button { FocusEnabled = false, SkinClass = typeof(ImageButtonSkin), Icon = ImageLoader.Instance.Load("Icons/" + icons[i]) }; button.Click += delegate(Event e) { Debug.Log("Clicked: " + e.Target); }; ToolGroup.AddChild(button); } button = new Button { Text = "Clip", SkinClass = typeof(ImageButtonSkin), Icon = ImageLoader.Instance.Load("Icons/color_swatch"), ToggleMode = true, FocusEnabled = false, Selected = true }; button.Change += delegate(Event e) { Button btn = (Button) e.Target; //Debug.Log("Selected: " + btn.Selected); _view.ClipAndEnableScrolling = btn.Selected; }; ControlBarGroup.AddChild(button); icons = new List<string> { "lock", "star", "accept" }; for (int i = 0; i < 3; i++) { button = new Button { Text = UppercaseFirst(icons[i]), SkinClass = typeof(ImageButtonSkin), FocusEnabled = false, Icon = ImageLoader.Instance.Load("Icons/" + icons[i]) }; //button.Click += delegate { AddButton(); }; ControlBarGroup.AddChild(button); } }
protected override void CreateChildren() { base.CreateChildren(); #region Background _background = new RectShape { Left = 0, Right = 0, Top = 0, Bottom = 0 }; _background.SetStyle("backgroundStyle", GetStyle("backgroundStyle")); AddChild(_background); #endregion _group = new Group { Left = 0, Right = 0, Top = 0, Bottom = 0, Layout = GetLayout((bool)GetStyle("vertical")) }; AddChild(_group); #region Icon IconDisplay = new Image { MouseEnabled = false }; _group.AddChild(IconDisplay); #endregion #region Label LabelDisplay = new Label(); _group.AddChild(LabelDisplay); #endregion }
/// <summary> /// Adds the component to a form<br/> /// Registers th efield using the supplied ID /// </summary> /// <param name="id"></param> /// <param name="label"></param> /// <param name="control"></param> /// <param name="itemLayout"></param> /// <exception cref="Exception"></exception> public void AddField(string id, string label, Component control, LayoutBase itemLayout = null) { if (_dictFields.ContainsKey(id)) throw new Exception("Duplicated form element ID: " + id); _dictFields.Add(id, control); Group itemGroup = new Group { PercentWidth = 100, Layout = itemLayout ?? new VerticalLayout() // TODO: different item layouts }; /*_fieldGroup.*/AddChild(itemGroup); if (_dictItems.ContainsKey(id)) throw new Exception("Duplicated form element ID: " + id); _dictItems.Add(id, itemGroup); // 1) label Label lbl = new Label { Text = label, Width = LabelWidth }; lbl.SetStyle("labelStyle", GetStyle("itemLabelStyle")); itemGroup.AddChild(lbl); // 2) control if (null != control) { itemGroup.AddChild(control); } else lbl.PercentWidth = 100; }
protected override void CreateChildren() { base.CreateChildren(); #region Popup anchor _anchor = new PopUpAnchor { Id = "pop_up", Left = 0, Right = 0, Top = 0, Bottom = 0, PopupPosition = PopupPosition.Below, PopupWidthMatchesAnchorWidth = true }; AddChild(_anchor); #endregion #region DropDown DropDown = new Group { Id = "drop_down", MaxHeight = 134, MinHeight = 22, Width = 150, Height = 200 }; //AddChild(DropDown); _anchor.Popup = DropDown; #endregion #region Background _background = new RectShape { Id = "background", Left = 0, Right = 0, Top = 0, Bottom = 0 }; DropDown.AddChild(_background); #endregion #region Scroller _scroller = new Scroller { Id = "scroller", SkinClass = EvaluateSkinClassFromStyle("scrollerSkin"), Left = 0, Right = 0, Top = 0, Bottom = 0, MinViewportInset = 1, HasFocusableChildren = false, Height = 200 //Visible = IncludeInLayout = false }; _scroller.SetStyle("horizontalScrollPolicy", ScrollPolicy.Off); DropDown.AddChild(_scroller); #endregion #region Data group DataGroup = new DataGroup { Id = "data_group", ItemRenderer = new ItemRendererFactory <DefaultItemRenderer>(), Layout = new VerticalLayout { Gap = 0, HorizontalAlign = HorizontalAlign.ContentJustify, RequestedMinRowCount = 5 } }; _scroller.Viewport = DataGroup; #endregion #region Border _border = new RectShape { Id = "border", Left = 0, Right = 0, Top = 0, Bottom = 0, MouseEnabled = false, BackgroundColor = Color.gray }; DropDown.AddChild(_border); #endregion #region OpenButton OpenButton = new Button { Left = 0, Right = 0, Top = 0, Bottom = 0, FocusEnabled = false, SkinClass = typeof(DropDownListButtonSkin) }; AddChild(OpenButton); #endregion #region Label TextInput = new TextField { VerticalCenter = 0, Left = 0, Right = 25, Top = 0, Bottom = 0, Height = 25 /*, * Width = 75,*/ //MouseEnabled = false, //Color = Color.black }; //LabelDisplay.SetStyle("color", GetStyle("textColor")); AddChild(TextInput); #endregion }
protected override void CreateChildren() { base.CreateChildren(); #region Dec _btnDec = new Button { Text = "<", FocusEnabled = FocusEnabled, ResizeWithContent = true, ResizeWithStyleBackground = true, Styles = _buttonStyles, //Padding = 0 }; _btnDec.SetStyle("paddingLeft", 0); _btnDec.SetStyle("paddingRight", 0); _btnDec.SetStyle("paddingTop", 0); _btnDec.SetStyle("paddingBottom", 0); _btnDec.SetStyle("buttonStyle", GetStyle("decButtonStyle")); _btnDec.Press += delegate { Browse(-1); }; AddChild(_btnDec); #endregion _placeholder = new Group { Layout = new HorizontalLayout { Gap = 2, VerticalAlign = VerticalAlign.Middle } }; _placeholder.AddEventListener(ButtonEvent.PRESS, delegate(Event e) { if (e.Target is Button) { CurrentPageIndex = _placeholder.GetChildIndex((DisplayListMember) e.Target); } }); AddChild(_placeholder); for (int i = 0; i < MaxButtons; i++) { _placeholder.AddChild(CreateButton(i)); } //CreateButton(0); #region Text Field - old // _txtPage = new TextField // { // FocusEnabled = true, // Width = 35, // Text = (CurrentPage + 1).ToString(), // //Styles = buttonStyles // }; // _txtPage.Change += delegate // { // Debug.Log("_txtPage.Text: " + _txtPage.Text); // int i = CurrentPage; // try { // i = Convert.ToInt32(_txtPage.Text); // } //// ReSharper disable EmptyGeneralCatchClause // catch { /* silent fail */ } //// ReSharper restore EmptyGeneralCatchClause // Debug.Log("i: " + i); // CurrentPage = Mathf.Clamp(i, 0, TotalPages); // Debug.Log("Change: " + CurrentPage); // _txtPage.Text = CurrentPage.ToString(); // }; // AddChild(_txtPage); #endregion #region Inc _btnInc = new Button { Text = ">", FocusEnabled = FocusEnabled, ResizeWithContent = true, ResizeWithStyleBackground = true, Styles = _buttonStyles, //Padding = 0 }; _btnInc.SetStyle("paddingLeft", 0); _btnInc.SetStyle("paddingRight", 0); _btnInc.SetStyle("paddingTop", 0); _btnInc.SetStyle("paddingBottom", 0); _btnInc.SetStyle("buttonStyle", GetStyle("incButtonStyle")); _btnInc.Press += delegate { Browse(1); }; AddChild(_btnInc); #endregion }
// ReSharper restore MemberCanBePrivate.Global #endregion protected override void CreateChildren() { //Debug.Log("Button skin creating children"); base.CreateChildren(); #region Background _background = new RectShape { Left = 0, Right = 0, Top = 0, Bottom = 0, Alpha = 0.5f }; //_background.SetStyle("backgroundStyle", ButtonStyle.Instance); AddChild(_background); #endregion #region Box Group box = new Group { HorizontalCenter = 0, VerticalCenter = 0 }; AddChild(box); _boxBg = new RectShape { Left = 0, Right = 0, Top = 0, Bottom = 0, HorizontalCenter = 0, VerticalCenter = 0, /*MinWidth = 300, * MinHeight = 100*/ }; //_background.SetStyle("backgroundStyle", ButtonStyle.Instance); _background.SetStyle("backgroundColor", Color.blue); box.AddChild(_boxBg); #endregion HGroup hGroup = new HGroup { Left = 10, Right = 10, Top = 10, Bottom = 10, HorizontalCenter = 0, VerticalCenter = 0, VerticalAlign = VerticalAlign.Middle }; box.AddChild(hGroup); #region Icon IconDisplay = new Image { MouseEnabled = false }; hGroup.AddChild(IconDisplay); #endregion #region Label LabelDisplay = new Label { Text = "miki", MouseEnabled = false, //Width = 100 }; hGroup.AddChild(LabelDisplay); #endregion }
// ReSharper restore MemberCanBePrivate.Global #endregion protected override void CreateChildren() { base.CreateChildren(); #region Background _background = new RectShape { Id = "background", Left = 0, Right = 0, Top = 0, Bottom = 0 }; AddChild(_background); #endregion #region Border _border = new RectShape { Id = "overlay", Left = 0, Right = 0, Top = 0, Bottom = 0, MouseEnabled = false }; AddChild(_border); #region Header background _headerBackground = new RectShape { Id = "headerBackground", Left = 1, Right = 1, Top = 1, Height = 50 }; AddChild(_headerBackground); #endregion #region Header group HeaderGroup = new Group { Id = "headerGroup", Layout = new AbsoluteLayout(), Left = 1, Right = 1, Top = 1, Height = 50, MouseEnabled = true }; AddChild(HeaderGroup); #endregion #region Icon + label group _labelGroup = new HGroup { Left = 10, VerticalCenter = 0, Gap = 6, VerticalAlign = VerticalAlign.Middle, ClipAndEnableScrolling = true }; HeaderGroup.AddChild(_labelGroup); #endregion #region Icon display HeaderIconDisplay = new Image { /*Left = 10, VerticalCenter = 0*/ }; _labelGroup.AddChild(HeaderIconDisplay); #endregion #region Label display TitleDisplay = new Label { //Id = "titleLabel", //Left = 10, //VerticalCenter = 0 }; //TitleLabel.SetStyle("textColor", UnityEngine.Color.white); _labelGroup.AddChild(TitleDisplay); #endregion #region Move area MoveArea = new Group { Id = "move_area", Layout = new AbsoluteLayout(), Left = 0, Right = 0, Top = 0, Bottom = 0, MouseEnabled = true }; HeaderGroup.AddChild(MoveArea); #endregion #region Tools ToolGroup = new Group { Id = "toolGroup", Layout = new HorizontalLayout { HorizontalAlign = HorizontalAlign.Right, VerticalAlign = VerticalAlign.Middle, Gap = 4 }, Right = 6, VerticalCenter = 0, MouseEnabled = true // not draggable when clicking space between buttons --- false // to be draggable on possible tools label click }; HeaderGroup.AddChild(ToolGroup); #endregion #region Content background _contentGroupBackground = new RectShape { Id = "contentGroupBackground", Left = 6, Right = 6, Top = 50, Bottom = 50 }; AddChild(_contentGroupBackground); #endregion #region Scroller _scroller = new Scroller { Left = 6, Right = 6, Top = 50, Bottom = 50 }; AddChild(_scroller); #endregion #region Content group ContentGroup = new Group { Id = "contentGroup", //Left = 6, //Right = 6, //Top = 50, //Bottom = 50 }; /** * Panel: in designer, children not focusable (textarea) * Problem je bio u WindowSkinu: * ContentGroup = new Group{ Id = "contentGroup" }; * AddChild(ContentGroup); // -> ova linija radi problem (ako se izbaci, sve je ok) * _scroller.Viewport = ContentGroup; * */ // AddChild(ContentGroup); _scroller.Viewport = ContentGroup; #endregion #region Control bar background _controlBarBackground = new RectShape { Id = "controlBarBackground", Left = 1, Right = 1, Bottom = 1, Height = 50, Alpha = 0.5f, MouseEnabled = false }; AddChild(_controlBarBackground); #endregion #region Control bar ControlBarGroup = new Group { Id = "controlBar", ClipAndEnableScrolling = true, Layout = new HorizontalLayout { HorizontalAlign = HorizontalAlign.Right, VerticalAlign = VerticalAlign.Middle, Gap = 4, PaddingLeft = 6, PaddingRight = 6, PaddingTop = 6, PaddingBottom = 6 }, Left = 1, Right = 1, Bottom = 1, Height = 50, MouseEnabled = true }; AddChild(ControlBarGroup); #endregion #endregion }