// 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 }
////---------------------------------- //// canScrollHorizontally ////---------------------------------- ///** // * // */ //private bool _canScrollHorizontally; ///** // * // * Helper function to determine whether the Viewport scrolls horizontally. // * // * <p>This is used for touch scrolling purposes to // * determine if one can scroll horizontally.</p> // * // * <p>The value is set in updateDisplayList()</p> // */ //internal bool canScrollHorizontally //{ // get // { // return _canScrollHorizontally; // } //} ////---------------------------------- //// canScrollVertically ////---------------------------------- ///** // * // */ //private bool _canScrollVertically; ///** // * // * Helper function to determine whether the Viewport scrolls vertically. // * // * <p>This is used for touch scrolling purposes to // * determine if one can scroll vertically.</p> // * // * <p>The value is set in updateDisplayList()</p> // */ //internal bool canScrollVertically //{ // get // { // return _canScrollVertically; // } //} //-------------------------------------------------------------------------- // // Overidden Methods // //-------------------------------------------------------------------------- /** * * Computes the union of the preferred size of the visible scrollbars * and the Viewport if target.measuredSizeIncludesScrollbars=true, otherwise * it's just the preferred size of the Viewport. * * This becomes the ScrollerSkin's measuredWidth,Height. * * The Viewport does not contribute to the minimum size unless its * explicit size has been set. */ override internal void Measure() { Scroller scroller = GetScroller(); if (null == scroller) { return; } float minViewportInset = scroller.MinViewportInset; // var mode = scroller.GetStyle("interactionMode"); // bool isMouseMode = null == mode || (InteractionMode)mode == InteractionMode.Mouse; bool measuredSizeIncludesScrollBars = scroller.MeasuredSizeIncludesScrollBars; // && isMouseMode; float measuredW = minViewportInset; float measuredH = minViewportInset; ScrollBarBase hsb = scroller.HorizontalScrollBar; bool showHsb = false; bool hAuto = false; if (measuredSizeIncludesScrollBars) { switch ((ScrollPolicy)scroller.GetStyle("horizontalScrollPolicy")) { case ScrollPolicy.On: if (null != hsb) { showHsb = true; } break; case ScrollPolicy.Auto: if (null != hsb) { showHsb = hsb.Visible; } hAuto = true; break; } } ScrollBarBase vsb = scroller.VerticalScrollBar; bool showVsb = false; bool vAuto = false; if (measuredSizeIncludesScrollBars) { switch ((ScrollPolicy)scroller.GetStyle("verticalScrollPolicy")) { case ScrollPolicy.On: if (null != vsb) { showVsb = true; } break; case ScrollPolicy.Auto: if (null != vsb) { showVsb = vsb.Visible; } vAuto = true; break; } } measuredH += (showHsb) ? HsbRequiredHeight() : minViewportInset; measuredW += (showVsb) ? VsbRequiredWidth() : minViewportInset; // The measured size of the Viewport is just its preferredBounds, except: // don't give up space if doing so would make an auto scrollbar visible. // In other words, if an auto scrollbar isn't already showing, and using // the preferred size would force it to show, and the current size would not, // then use its current size as the measured size. Note that a scrollbar // is only shown if the content size is greater than the Viewport size // by at least SDT. IViewport viewport = scroller.Viewport; if (null != viewport) { if (measuredSizeIncludesScrollBars) { Point contentSize = GetLayoutContentSize(viewport); float viewportPreferredW = LayoutUtil.GetPreferredBoundsWidth((InvalidationManagerClient)viewport); float viewportContentW = contentSize.X; float viewportW = LayoutUtil.GetLayoutBoundsWidth((InvalidationManagerClient)viewport); // "current" size bool currentSizeNoHsb = null != viewportW && ((viewportW + SDT) > viewportContentW); if (hAuto && !showHsb && ((viewportPreferredW + SDT) <= viewportContentW) && currentSizeNoHsb) { measuredW += viewportW; } else { measuredW += Math.Max(viewportPreferredW, (showHsb) ? LayoutUtil.GetMinBoundsWidth(hsb) : 0); } float viewportPreferredH = LayoutUtil.GetPreferredBoundsHeight((InvalidationManagerClient)viewport); float viewportContentH = contentSize.Y; float viewportH = LayoutUtil.GetLayoutBoundsHeight((InvalidationManagerClient)viewport); // "current" size bool currentSizeNoVsb = null != viewportH && ((viewportH + SDT) > viewportContentH); if (vAuto && !showVsb && ((viewportPreferredH + SDT) <= viewportContentH) && currentSizeNoVsb) { measuredH += viewportH; } else { measuredH += Math.Max(viewportPreferredH, (showVsb) ? LayoutUtil.GetMinBoundsHeight(vsb) : 0); } } else { measuredW += LayoutUtil.GetPreferredBoundsWidth((InvalidationManagerClient)viewport); measuredH += LayoutUtil.GetPreferredBoundsHeight((InvalidationManagerClient)viewport); } } float minW = minViewportInset * 2; float minH = minViewportInset * 2; // If the Viewport's explicit size is set, then // include that in the scroller's minimum size Component component = viewport as Component; float? explicitViewportW = (null != component) ? component.ExplicitWidth : null; float? explicitViewportH = (null != component) ? component.ExplicitHeight : null; if (null != explicitViewportW) { minW += (float)explicitViewportW; } if (null != explicitViewportH) { minH += (float)explicitViewportH; } GroupBase g = Target; g.MeasuredWidth = Mathf.Ceil(measuredW); g.MeasuredHeight = Mathf.Ceil(measuredH); g.MeasuredMinWidth = Mathf.Ceil(minW); g.MeasuredMinHeight = Mathf.Ceil(minH); }
/** * * Arrange the Viewport and scrollbars conventionally within * the specified width and height: vertical scrollbar on the * right, horizontal scrollbar along the bottom. * * Scrollbars for which the corresponding scrollPolicy=auto * are made visible if the Viewport's content size is bigger * than the actual size. This introduces the possibility of * validateSize,DisplayList() looping because the measure() * method computes the size of the Viewport and the currently * visible scrollbars. * */ override internal void UpdateDisplayList(float w, float h) { //Debug.Log("UpdateDisplayList: " + w + ", " + h); Scroller scroller = GetScroller(); if (null == scroller) { return; } IViewport viewport = scroller.Viewport; ScrollBarBase hsb = scroller.HorizontalScrollBar; ScrollBarBase vsb = scroller.VerticalScrollBar; float minViewportInset = scroller.MinViewportInset; float contentW = 0; float contentH = 0; if (null != viewport) { Point contentSize = GetLayoutContentSize(viewport); contentW = contentSize.X; contentH = contentSize.Y; } // If the Viewport's size has been explicitly set (not typical) then use it // The initial values for viewportW,H are only used to decide if auto scrollbars // should be shown. Component viewportUIC = viewport as Component; //Debug.Log("viewportUIC: " + viewportUIC); //Debug.Log("viewportUIC.ExplicitWidth: " + viewportUIC.ExplicitWidth); float?explicitViewportW = null != viewportUIC ? viewportUIC.ExplicitWidth : null; float?explicitViewportH = null != viewportUIC ? viewportUIC.ExplicitHeight : null; //Debug.Log("explicitViewportW: " + explicitViewportW + "; explicitViewportH: " + explicitViewportH); float?viewportW = (null == explicitViewportW) ? (w - (minViewportInset * 2)) : explicitViewportW; // TODO: 0? float?viewportH = (null == explicitViewportH) ? (h - (minViewportInset * 2)) : explicitViewportH; // TODO: 0? //Debug.Log("viewportW: " + viewportW + "; viewportH: " + viewportH); // Decide which scrollbars will be visible based on the Viewport's content size // and the scroller's scroll policies. A scrollbar is shown if the content size // greater than the Viewport's size by at least SDT. bool oldShowHSB = HsbVisible; bool oldShowVSB = VsbVisible; bool hAuto = false; //bool hsbTakeUpSpace = true; // if visible switch ((ScrollPolicy)scroller.GetStyle("horizontalScrollPolicy")) { case ScrollPolicy.On: //_canScrollHorizontally = true; HsbVisible = true; break; case ScrollPolicy.Auto: if (null != hsb && null != viewport) { hAuto = true; // = (contentW >= (viewportW + SDT)); //HsbVisible = (null != hsb && _canScrollHorizontally); HsbVisible = (contentW >= (viewportW + SDT)); } break; default: //_canScrollHorizontally = false; HsbVisible = false; break; } bool vAuto = false; //bool vsbTakeUpSpace = true; // if visible switch ((ScrollPolicy)scroller.GetStyle("verticalScrollPolicy")) { case ScrollPolicy.On: //_canScrollVertically = true; VsbVisible = true; break; case ScrollPolicy.Auto: if (null != vsb && null != viewport) { vAuto = true; //_canScrollVertically = (contentH >= (viewportH + SDT)); //VsbVisible = (null != vsb && _canScrollVertically); VsbVisible = (contentH >= (viewportH + SDT)); } break; default: //_canScrollVertically = false; VsbVisible = false; break; } // // if in touch mode, only show scrollbars if a scroll is currently in progress // if ((InteractionMode)scroller.GetStyle("interactionMode") == InteractionMode.Touch) // { // hsbTakeUpSpace = false; // HsbVisible = scroller.horizontalScrollInProgress; // // vsbTakeUpSpace = false; // VsbVisible = scroller.verticalScrollInProgress; // } // Reset the Viewport's width,height to account for the visible scrollbars, unless // the Viewport's size was explicitly set, then we just use that. if (null == explicitViewportW) // || 0 == explicitViewportW) // TODO: 0? // if (null == explicitViewportW) { viewportW = w - ((VsbVisible) ? (minViewportInset + VsbRequiredWidth()) : (minViewportInset * 2)); } else { viewportW = explicitViewportW; } //Debug.Log("w: " + w); //Debug.Log("viewportW: " + viewportW); if (null == explicitViewportH) // || 0 == explicitViewportH) // TODO: 0? // if (null == explicitViewportH) { viewportH = h - ((HsbVisible) ? (minViewportInset + HsbRequiredHeight()) : (minViewportInset * 2)); } else { viewportH = explicitViewportH; } //Debug.Log("h: " + h); //Debug.Log("viewportH: " + viewportH); // If the scrollBarPolicy is auto, and we're only showing one scrollbar, // the Viewport may have shrunk enough to require showing the other one. bool hsbIsDependent = false; bool vsbIsDependent = false; if (VsbVisible && !HsbVisible && hAuto && (contentW >= (viewportW + SDT))) { HsbVisible = hsbIsDependent = true; } else if (!VsbVisible && HsbVisible && vAuto && (contentH >= (viewportH + SDT))) { VsbVisible = vsbIsDependent = true; } // If the HSB doesn't fit, hide it and give the space back. Likewise for VSB. // If both scrollbars are supposed to be visible but they don't both fit, // then prefer to show the "non-dependent" auto scrollbar if we added the second // "dependent" auto scrollbar because of the space consumed by the first. if (HsbVisible && VsbVisible) { if (HsbFits(w, h, true) && VsbFits(w, h, true)) { // Both scrollbars fit, we're done. } else if (!HsbFits(w, h, false) && !VsbFits(w, h, false)) { // Neither scrollbar would fit, even if the other scrollbar wasn't visible. HsbVisible = false; VsbVisible = false; } else { // Only one of the scrollbars will fit. If we're showing a second "dependent" // auto scrollbar because the first scrollbar consumed enough space to // require it, if the first scrollbar doesn't fit, don't show either of them. if (hsbIsDependent) { if (VsbFits(w, h, false)) // VSB will fit if HSB isn't shown { HsbVisible = false; } else { VsbVisible = HsbVisible = false; } } else if (vsbIsDependent) { if (HsbFits(w, h, false)) // HSB will fit if VSB isn't shown { VsbVisible = false; } else { HsbVisible = VsbVisible = false; } } else if (VsbFits(w, h, false)) // VSB will fit if HSB isn't shown { HsbVisible = false; } else // HsbFits(w, h, false) // HSB will fit if VSB isn't shown { VsbVisible = false; } } } else if (HsbVisible && !HsbFits(w, h, true)) // just trying to show HSB, but it doesn't fit { HsbVisible = false; } else if (VsbVisible && !VsbFits(w, h, true)) // just trying to show VSB, but it doesn't fit { VsbVisible = false; } // Reset the Viewport's width,height to account for the visible scrollbars, unless // the Viewport's size was explicitly set, then we just use that. if (null == explicitViewportW) // || 0 == explicitViewportW) // TODO: 0? // if (null == explicitViewportW) { viewportW = w - ((VsbVisible) ? (minViewportInset + VsbRequiredWidth()) : (minViewportInset * 2)); } else { viewportW = explicitViewportW; } if (null == explicitViewportH) // || 0 == explicitViewportH) // TODO: 0? // if (null == explicitViewportH) { viewportH = h - ((HsbVisible) ? (minViewportInset + HsbRequiredHeight()) : (minViewportInset * 2)); } else { viewportH = explicitViewportH; } // Layout the Viewport and scrollbars. if (null != viewport) { //Debug.Log("Setting Viewport size: " + viewportW + ", " + viewportH); LayoutUtil.SetLayoutBoundsSize((InvalidationManagerClient)viewport, viewportW, viewportH); //null, null); // 20131026 //Debug.Log("Setting Viewport position: " + minViewportInset + ", " + minViewportInset); LayoutUtil.SetLayoutBoundsPosition((InvalidationManagerClient)viewport, minViewportInset, minViewportInset); // TODO: examine why this doesn't work without going explicit! //((Component)viewport).Width = (float)viewportW; //TEMP //((Component) viewport).Height = (float) viewportH; //TEMP //((Component)viewport).Transform.Apply(); } if (HsbVisible) { float hsbW = (VsbVisible) ? w - LayoutUtil.GetPreferredBoundsWidth(vsb) : w; float hsbH = LayoutUtil.GetPreferredBoundsHeight(hsb); LayoutUtil.SetLayoutBoundsSize(hsb, Math.Max(LayoutUtil.GetMinBoundsWidth(hsb), hsbW), hsbH); LayoutUtil.SetLayoutBoundsPosition(hsb, 0, h - hsbH); } if (VsbVisible) { float vsbW = LayoutUtil.GetPreferredBoundsWidth(vsb); float vsbH = (HsbVisible) ? h - LayoutUtil.GetPreferredBoundsHeight(hsb) : h; LayoutUtil.SetLayoutBoundsSize(vsb, vsbW, Math.Max(LayoutUtil.GetMinBoundsHeight(vsb), vsbH)); LayoutUtil.SetLayoutBoundsPosition(vsb, w - vsbW, 0); } // If we've added an auto scrollbar, then the measured size is likely to have been wrong. // There's a risk of looping here, so we count. if ((_invalidationCount < 2) && (((VsbVisible != oldShowVSB) && vAuto) || ((HsbVisible != oldShowHSB) && hAuto))) { Target.InvalidateSize(); // If the Viewport's layout is virtual, it's possible that its // measured size changed as a consequence of laying it out, // so we invalidate its size as well. GroupBase viewportGroup = viewport as GroupBase; //if (null != viewportGroup && null != viewportGroup.Layout && viewportGroup.Layout.UseVirtualLayout) // viewportGroup.InvalidateSize(); _invalidationCount += 1; } else { _invalidationCount = 0; } Target.SetContentSize(w, h); }
// 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 Scroller _scroller = new Scroller { Id = "scroller", SkinClass = EvaluateSkinClassFromStyle("scrollerSkin"), Left = 0, Right = 0, Top = 0, Bottom = 0, MinViewportInset = 1, HasFocusableChildren = false }; 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 } }; //AddChild(DataGroup); _scroller.Viewport = DataGroup; #region Border _border = new RectShape { Id = "border", Left = 0, Right = 0, Top = 0, Bottom = 0, MouseEnabled = false }; _border.SetStyle("backgroundStyle", OnePxBorderStyle.Instance); _border.SetStyle("backgroundColor", Color.gray); AddChild(_border); #endregion #endregion }
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 }
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); }
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() { 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 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 }
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 }
// 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 Scroller _scroller = new Scroller { Id = "scroller", SkinClass = EvaluateSkinClassFromStyle("scrollerSkin"), Left = 0, Right = 0, Top = 0, Bottom = 0, MinViewportInset = 1, HasFocusableChildren = false }; 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 } }; //AddChild(DataGroup); _scroller.Viewport = DataGroup; #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 }