Ejemplo n.º 1
0
        public void SetItems(List <string> items)
        {
            this.Items     = items;
            selectionIndex = -1;

            for (int i = 0; i < itemElements.Count; i++)             // destroy all the item elements
            {
                NukeOverlayElement(itemElements[i]);
            }
            itemElements.Clear();

            itemsShown = System.Math.Max((uint)2, System.Math.Min(maxItemsShown, (uint)this.Items.Count));

            for (int i = 0; i < itemsShown; i++)             // create all the item elements
            {
                Mogre.BorderPanelOverlayElement e = (Mogre.BorderPanelOverlayElement)Mogre.OverlayManager.Singleton.CreateOverlayElementFromTemplate("SdkTrays/SelectMenuItem", "BorderPanel", expandedBoxElement.Name + "/Item" + (i + 1).ToString());

                e.Top   = (6 + i * (smallBoxElement.Height - 8));
                e.Width = (expandedBoxElement.Width - 32);

                expandedBoxElement.AddChild(e);
                itemElements.Add(e);
            }

            if (items.Count > 0)
            {
                SelectItem(0, false);
            }
            else
            {
                smallTextAreaElement.Caption = string.Empty;
            }
        }
Ejemplo n.º 2
0
        public Slider(string name, string caption, float width, float trackWidth, float valueBoxWidth, float minValue, float maxValue, uint snaps)
        {
            mDragOffset    = 0.0f;
            mValue         = 0.0f;
            mMinValue      = 0.0f;
            mMaxValue      = 0.0f;
            mInterval      = 0.0f;
            mDragging      = false;
            mFitToContents = false;
            element        = Mogre.OverlayManager.Singleton.CreateOverlayElementFromTemplate("SdkTrays/Slider", "BorderPanel", name);
            element.Width  = (width);
            Mogre.OverlayContainer c = (Mogre.OverlayContainer)element;
            mTextArea = (Mogre.TextAreaOverlayElement)c.GetChild(Name + "/SliderCaption");
            Mogre.OverlayContainer valueBox = (Mogre.OverlayContainer)c.GetChild(Name + "/SliderValueBox");
            valueBox.Width = (valueBoxWidth);
            valueBox.Left  = (-(valueBoxWidth + 5));
            mValueTextArea = (Mogre.TextAreaOverlayElement)valueBox.GetChild(valueBox.Name + "/SliderValueText");
            mTrack         = (Mogre.BorderPanelOverlayElement)c.GetChild(Name + "/SliderTrack");
            mHandle        = (Mogre.PanelOverlayElement)mTrack.GetChild(mTrack.Name + "/SliderHandle");

            if (trackWidth <= 0f)             // tall style
            {
                mTrack.Width = (width - 16f);
            }
            else             // long style
            {
                if (width <= 0f)
                {
                    mFitToContents = true;
                }
                element.Height             = (34f);
                mTextArea.Top              = (10f);
                valueBox.Top               = (2f);
                mTrack.Top                 = (-23f);
                mTrack.Width               = (trackWidth);
                mTrack.HorizontalAlignment = (GuiHorizontalAlignment.GHA_RIGHT);
                mTrack.Left                = (-(trackWidth + valueBoxWidth + 5f));
            }

            setCaption(caption);
            setRange(minValue, maxValue, snaps, false);
        }