public MinMaxSlider(float minValue, float maxValue, float minLimit, float maxLimit)
        {
            m_DragState = DragState.NoThumb;

            Add(new VisualElement() { name = "TrackElement" });

            dragElement = new VisualElement() { name = "DragElement" };
            dragElement.RegisterCallback<GeometryChangedEvent>(UpdateDragElementPosition);
            Add(dragElement);

            // For a better handling of the cursor style, children elements are created so that the style is automatic with the uss.
            dragMinThumb = new VisualElement();
            dragMaxThumb = new VisualElement();
            dragMinThumb.AddToClassList("thumbelement");
            dragMaxThumb.AddToClassList("thumbelement");
            dragElement.Add(dragMinThumb);
            dragElement.Add(dragMaxThumb);

            clampedDragger = new ClampedDragger<float>(null, SetSliderValueFromClick, SetSliderValueFromDrag);
            this.AddManipulator(clampedDragger);


            m_MinLimit = minLimit;
            m_MaxLimit = maxLimit;
            m_Value = ClampValues(new Vector2(minValue, maxValue));
            UpdateDragElementPosition();
        }
Exemplo n.º 2
0
        public Slider(float start, float end, System.Action <float> valueChanged,
                      Direction direction = Direction.Horizontal, float pageSize = 10f)
        {
            this.valueChanged = valueChanged;
            this.direction    = direction;
            this.pageSize     = pageSize;
            lowValue          = start;
            highValue         = end;

            Add(new VisualElement()
            {
                name = "TrackElement"
            });

            dragElement = new VisualElement()
            {
                name = "DragElement"
            };
            dragElement.RegisterCallback <PostLayoutEvent>(UpdateDragElementPosition);

            Add(dragElement);

            clampedDragger = new ClampedDragger(this, SetSliderValueFromClick, SetSliderValueFromDrag);
            this.AddManipulator(clampedDragger);
        }
Exemplo n.º 3
0
        public Slider(float start, float end, System.Action <float> valueChanged,
                      Direction direction = Direction.Horizontal, float pageSize = kDefaultPageSize)
        {
            this.direction = direction;
            this.pageSize  = pageSize;
            lowValue       = start;
            highValue      = end;

            Add(new VisualElement()
            {
                name = "TrackElement"
            });

            dragElement = new VisualElement()
            {
                name = "DragElement"
            };
            dragElement.RegisterCallback <GeometryChangedEvent>(UpdateDragElementPosition);

            Add(dragElement);

            clampedDragger = new ClampedDragger(this, SetSliderValueFromClick, SetSliderValueFromDrag);
            this.AddManipulator(clampedDragger);

            // We set this event last, so that the construction does not call it.
            this.valueChanged = valueChanged;
        }
Exemplo n.º 4
0
        public BaseSlider(T start, T end, SliderDirection direction, float pageSize = kDefaultPageSize)
        {
            this.direction = direction;
            this.pageSize  = pageSize;
            lowValue       = start;
            highValue      = end;

            Add(new VisualElement()
            {
                name = "TrackElement"
            });

            dragElement = new VisualElement()
            {
                name = "DragElement"
            };
            dragElement.RegisterCallback <GeometryChangedEvent>(UpdateDragElementPosition);

            Add(dragElement);

            clampedDragger = new ClampedDragger <T>(this, SetSliderValueFromClick, SetSliderValueFromDrag);
            this.AddManipulator(clampedDragger);
        }