Exemplo n.º 1
0
 protected override void OnDrag(UserAction action)
 {
     a++;
     if (a < 2)
     {
         return;
     }
     a = 0;
     if (Pressed)
     {
         if (TextCom != null)
         {
             if (entry)
             {
                 if (action.Motion != Vector2.zero)
                 {
                     textInfo.CaretStyle = 2;
                     int end = textInfo.endSelect;
                     textInfo.endSelect = GetPressIndex(textInfo, this, action, ref textInfo.endDock);
                     if (end != textInfo.endSelect)
                     {
                         Selected();
                         if (OnSelectChanged != null)
                         {
                             OnSelectChanged(this, action);
                         }
                         ThreadMission.InvokeToMain((o) => { InputCaret.ChangeCaret(textInfo); }, null);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 void Delete(int dir)
 {
     if (DeleteSelected(textInfo))
     {
         goto label;
     }
     if (dir < 0)
     {
         int index = textInfo.startSelect;
         if (index > 0)
         {
             index--;
             textInfo.buffer.Remove(index, 1);
             textInfo.startSelect = index;
         }
     }
     else
     {
         int index = textInfo.startSelect;
         if (index < textInfo.buffer.Length)
         {
             textInfo.buffer.Remove(index, 1);
         }
     }
     label :;
     textInfo.text       = textInfo.buffer.FullString;
     textInfo.CaretStyle = 1;
     ThreadMission.InvokeToMain(TextChanged, textInfo, ChangeApplyed);
 }
Exemplo n.º 3
0
 void ChangeApplyed(object obj)
 {
     ChangePoint(textInfo);
     ThreadMission.InvokeToMain((o) => {
         InputCaret.ChangeCaret(textInfo);
     }, null);
 }
Exemplo n.º 4
0
        public override void Initial(ModelElement mod)
        {
            palette               = new Palette();
            callBackR             = EventCallBack.RegEvent <EventCallBack>(mod);
            callBackR.IsCircular  = true;
            callBackR.Drag        = callBackR.DragEnd = DragingR;
            callBackR.PointerDown = PointDownR;
            NobA                  = mod.Find("NobA");
            NobB                  = mod.Find("NobB");
            hc                    = mod.Find("HTemplate");
            template              = hc.GetComponent <RawImageElement>();
            callBackC             = EventCallBack.RegEvent <EventCallBack>(hc);
            callBackC.Drag        = callBackC.DragEnd = DragingC;
            callBackC.PointerDown = PointDownC;
            htemp                 = mod.GetComponent <RawImageElement>();
            ThreadMission.InvokeToMain((o) => {
                htemp.Context.texture    = Palette.LoadCTemplateAsync();
                template.Context.texture = palette.texture;
                slider.Context.texture   = Palette.AlphaTemplate();
            }, null);
            palette.LoadHSVTAsync(1);
            SelectColor.a = 1;
            var son = mod.Find("Slider");

            slider   = son.GetComponent <RawImageElement>();
            uISlider = new UISlider();
            uISlider.Initial(son);
            uISlider.OnValueChanged = AlphaChanged;
            uISlider.Percentage     = 1;
        }
Exemplo n.º 5
0
        internal override void OnDragEnd(UserAction action)
        {
            long r = action.EventTicks - pressTime;

            if (r <= ClickTime)
            {
                float x = action.CanPosition.x;
                float y = action.CanPosition.y;
                x -= RawPosition.x;
                x *= x;
                y -= RawPosition.y;
                y *= y;
                x += y;
                if (x < ClickArea)
                {
                    return;
                }
            }
            textInfo.endSelect = GetPressIndex(textInfo, this, action, ref textInfo.endDock);
            Selected();
            if (OnSelectEnd != null)
            {
                OnSelectEnd(this, action);
            }
            ThreadMission.InvokeToMain((o) => { InputCaret.ChangeCaret(textInfo); }, null);
        }
Exemplo n.º 6
0
    static void Decode(object mis)
    {
        Mission m = mis as Mission;

        m.gifdata = parseGifData(m.dat);
        ThreadMission.InvokeToMain(DataToTexture, m);
    }
 public void LoadAsync <T>(object dat) where T : ScenePage, new ()
 {
     ThreadMission.InvokeToMain((o) => {
         base.Apply();
         ApplyScene();
         Scene.ChangeScene <T>(dat);
     }, null);
 }
 /// <summary>
 /// 热更新使用此方法
 /// </summary>
 /// <param name="func"></param>
 /// <param name="dat"></param>
 public void LoadAsync(Func <ScenePage> func, object dat)
 {
     ThreadMission.InvokeToMain((o) => {
         base.Apply();
         ApplyScene();
         Scene.ChangeScene(func(), dat);
     }, null);
 }
 public override void Initial(ModelElement parent, object dat = null)
 {
     model = ModelManagerUI.CloneModel("baseUI", "gif");
     base.Initial(parent, dat);
     view = model.ComponentReflection <View>();
     ThreadMission.InvokeToMain(LoadGif, null);
     view.Last.Click = (o, e) => { LoadPage <AniTestPage>(); };
     view.Next.Click = (o, e) => { LoadPage <TestPage>(); };
 }
 public static void FindSpritesAsync(string bundle, string tname, string[][] names, Action <Sprite[][]> callBack)
 {
     Sprite[][] result = null;
     ThreadMission.InvokeToMain(
         (o) => { result = FindSprites(bundle, tname, names); }, null,
         (e) => { if (callBack != null)
                  {
                      callBack(result);
                  }
         });
 }
Exemplo n.º 11
0
 /// <summary>
 /// 多线程使用此函数
 /// </summary>
 /// <returns></returns>
 public void LoadHSVTAsync(float h)
 {
     HSVTemplate(h, buffer);
     ThreadMission.InvokeToMain(
         (o) => {
         if (t2d == null)
         {
             t2d = new Texture2D(256, 256, TextureFormat.ARGB32, false);
         }
         t2d.SetPixels(buffer);
         t2d.Apply();
     }, this);
 }
Exemplo n.º 12
0
    static void Decode(object mis)
    {
        Mission m = mis as Mission;

        m.gifdata = parseGifData(m.dat);
        m.count   = m.gifdata.graphicsControlExtensions.Count;
        while (m.gifdata.DecodeNext())
        {
            //ThreadMission.AddMission();
            ThreadMission.InvokeToMain(DataToTexture, m);
        }
        //CalculColors(m.gifdata);
        //ThreadMission.InvokeToMain(DataToTexture,m);
    }
Exemplo n.º 13
0
        void OnLostFocus(EventCallBack eventCall, UserAction action)
        {
            TextInput text = eventCall as TextInput;

            if (text == InputEvent)
            {
                if (InputEvent.OnSubmit != null)
                {
                    InputEvent.OnSubmit(InputEvent);
                }
                InputEvent = null;
            }
            Editing = false;
            SetShowText();
            ThreadMission.InvokeToMain((o) => { Keyboard.EndInput(); }, null);
        }
Exemplo n.º 14
0
        string OnInputChanged(string input)
        {
            if (input == "")
            {
                return("");
            }
            EmojiString es  = new EmojiString(input);
            string      str = textInfo.buffer.FilterString;

            if (CharacterLimit > 0)
            {
                string fs = es.FilterString;
                if (fs.Length + str.Length > CharacterLimit)
                {
                    int len = CharacterLimit - str.Length;
                    if (len <= 0)
                    {
                        return("");
                    }
                    es.Remove(fs.Length - len, len);
                }
            }
            str = es.FullString;
            if (Validate(characterValidation, textInfo.text, textInfo.startSelect, str[0]) == 0)
            {
                return("");
            }
            if (ValidateChar != null)
            {
                if (ValidateChar(this, textInfo.startSelect, str[0]) == 0)
                {
                    return("");
                }
            }
            DeleteSelected(textInfo);
            textInfo.buffer.Insert(textInfo.startSelect, es);
            textInfo.startSelect += es.FilterString.Length;
            if (OnValueChanged != null)
            {
                OnValueChanged(this);
            }
            textInfo.text = textInfo.buffer.FullString;
            SetShowText();
            textInfo.CaretStyle = 1;
            ThreadMission.InvokeToMain(TextChanged, textInfo, ChangeApplyed);
            return(input);
        }
Exemplo n.º 15
0
 void Drag(EventCallBack callBack, UserAction action, Vector2 v)
 {
     if (drawModel == DrawModel.Brush)
     {
         CurPos = callBack.ScreenToLocal(action.CanPosition);
         float hx = Width * 0.5f;
         float hy = Height * 0.5f;
         if (LastPos.x <= hx & LastPos.x >= -hx)
         {
             if (LastPos.y <= hy & LastPos.y >= -hy)
             {
                 DrawLine(LastPos, CurPos);
                 ThreadMission.InvokeToMain(Apply, null);
                 LastPos = CurPos;
             }
         }
     }
 }
        public static void AsyncGetSizeY(string fontName, Vector2 designSize, int fontSize, EmojiString txt, FontStyle style, Action <Vector2> callback)
        {
            string  str = txt.FilterString;
            Vector2 v   = Vector2.zero;

            ThreadMission.InvokeToMain((o) => {
                var font = FindFont(fontName);
                if (font != null)
                {
                    TextGenerationSettings settings = new TextGenerationSettings();
                    settings.resizeTextMinSize      = 2;
                    settings.resizeTextMaxSize      = 40;
                    settings.scaleFactor            = 1;
                    settings.textAnchor             = TextAnchor.UpperLeft;
                    settings.color             = Color.red;
                    settings.generationExtents = new Vector2(designSize.x, 0);
                    settings.pivot             = new Vector2(0.5f, 0.5f);
                    settings.richText          = true;
                    settings.font               = font;
                    settings.fontSize           = fontSize;
                    settings.fontStyle          = FontStyle.Normal;
                    settings.alignByGeometry    = false;
                    settings.updateBounds       = false;
                    settings.lineSpacing        = 1;
                    settings.horizontalOverflow = HorizontalWrapMode.Wrap;
                    settings.verticalOverflow   = VerticalWrapMode.Overflow;
                    TextGenerator generator     = new TextGenerator();
                    v.y = generator.GetPreferredHeight(str, settings);
                    v.x = designSize.x;
                    if (generator.lineCount == 1)
                    {
                        v.x = generator.verts[generator.vertexCount - 1].position.x - generator.verts[0].position.x + 0.1f;//加0.1增加容错率
                    }
                }
            },
                                       null,
                                       (o) => {
                if (callback != null)
                {
                    callback(v);
                }
            });
        }
Exemplo n.º 17
0
 void SetSelectPoint(int index)
 {
     if (index != 0)
     {
         index += textInfo.startSelect;
         if (index < 0)
         {
             index = 0;
         }
         if (index > textInfo.text.Length)
         {
             index = textInfo.text.Length;
         }
     }
     textInfo.startSelect = index;
     textInfo.endSelect   = -1;
     textInfo.CaretStyle  = 1;
     ChangePoint(textInfo);
     ThreadMission.InvokeToMain((o) => { InputCaret.ChangeCaret(textInfo); }, null);
 }
Exemplo n.º 18
0
        public override void Initial(ModelElement mod)
        {
            base.Initial(mod);
            model = mod;
            raw   = model.GetComponent <RawImageElement>();
            var size = model.data.sizeDelta;

            Width                 = (int)size.x;
            Height                = (int)size.y;
            HalfW                 = Width / 2;
            HalfH                 = Height / 2;
            buffer                = new Color[Width * Height];
            gesture               = EventCallBack.RegEvent <GestureEvent>(model);
            gesture.PointerDown   = PointDown;
            gesture.Drag          = Drag;
            gesture.DragEnd       = DragEnd;
            gesture.AutoColor     = false;
            gesture.TowFingerMove = TowFingerMove;
            ThreadMission.InvokeToMain(Apply, null);
        }
Exemplo n.º 19
0
        void OnClick(EventCallBack eventCall, UserAction action)
        {
            TextInput input = eventCall as TextInput;

            if (input == null)
            {
                return;
            }
            InputEvent           = input;
            textInfo.startSelect = GetPressIndex(textInfo, this, action, ref textInfo.startDock);
            textInfo.endSelect   = -1;
            textInfo.CaretStyle  = 1;
            ChangePoint(textInfo);
            ThreadMission.InvokeToMain((o) => {
                bool pass = InputEvent.contentType == ContentType.Password ? true : false;
                Keyboard.OnInput(textInfo.text, InputEvent.touchType, InputEvent.multiLine, pass, CharacterLimit);
                InputCaret.SetParent(Context.Context);
                InputCaret.ChangeCaret(textInfo);
            }, null);
        }
 public void Invoke(Action <RenderImageElement, object> action, object data)
 {
     ThreadMission.InvokeToMain((o) => { action(this, data); }, null);
 }
Exemplo n.º 21
0
 public void InvokeDispose()
 {
     ThreadMission.InvokeToMain((o) => { Dispose(); }, null);
 }
 public void InvokePage <T, U>(Action <T, U> action, U data) where T : ScenePage, new()
 {
     ThreadMission.InvokeToMain((o) => { action(Scene.CurrentPage as T, data); }, null);
 }
Exemplo n.º 23
0
 static EditState KeyPressed()
 {
     KeyPressTime -= UserAction.TimeSlice;
     if (Keyboard.GetKey(KeyCode.Backspace))
     {
         if (KeyPressTime <= 0)
         {
             if (InputEvent != null)
             {
                 InputEvent.Delete(-1);
             }
             KeySpeed *= 0.8f;
             if (KeySpeed < MaxSpeed)
             {
                 KeySpeed = MaxSpeed;
             }
             KeyPressTime = KeySpeed;
         }
         return(EditState.Done);
     }
     if (Keyboard.GetKey(KeyCode.Delete))
     {
         if (KeyPressTime <= 0)
         {
             if (InputEvent != null)
             {
                 InputEvent.Delete(1);
             }
             KeySpeed *= 0.7f;
             if (KeySpeed < MaxSpeed)
             {
                 KeySpeed = MaxSpeed;
             }
             KeyPressTime = KeySpeed;
         }
         return(EditState.Done);
     }
     if (Keyboard.GetKey(KeyCode.LeftArrow))
     {
         if (KeyPressTime <= 0)
         {
             if (InputEvent != null)
             {
                 InputEvent.SetSelectPoint(-1);
             }
             KeySpeed *= 0.7f;
             if (KeySpeed < MaxSpeed)
             {
                 KeySpeed = MaxSpeed;
             }
             KeyPressTime = KeySpeed;
         }
         return(EditState.Done);
     }
     if (Keyboard.GetKey(KeyCode.RightArrow))
     {
         if (KeyPressTime <= 0)
         {
             if (InputEvent != null)
             {
                 InputEvent.SetSelectPoint(1);
             }
             KeySpeed *= 0.7f;
             if (KeySpeed < MaxSpeed)
             {
                 KeySpeed = MaxSpeed;
             }
             KeyPressTime = KeySpeed;
         }
         return(EditState.Done);
     }
     if (Keyboard.GetKey(KeyCode.UpArrow))
     {
         if (KeyPressTime <= 0)
         {
             if (InputEvent != null)
             {
                 InputEvent.MoveUp();
             }
             KeySpeed *= 0.7f;
             if (KeySpeed < MaxSpeed)
             {
                 KeySpeed = MaxSpeed;
             }
             KeyPressTime = KeySpeed;
         }
         return(EditState.Done);
     }
     if (Keyboard.GetKey(KeyCode.DownArrow))
     {
         if (KeyPressTime <= 0)
         {
             if (InputEvent != null)
             {
                 InputEvent.MoveDown();
             }
             KeySpeed *= 0.7f;
             if (KeySpeed < MaxSpeed)
             {
                 KeySpeed = MaxSpeed;
             }
             KeyPressTime = KeySpeed;
         }
         return(EditState.Done);
     }
     KeySpeed = 220f;
     if (Keyboard.GetKeyDown(KeyCode.Home))
     {
         InputEvent.SetSelectPoint(0);
         return(EditState.Done);
     }
     if (Keyboard.GetKeyDown(KeyCode.End))
     {
         InputEvent.SetSelectPoint(10000000);
         return(EditState.Done);
     }
     if (Keyboard.GetKeyDown(KeyCode.A))
     {
         if (Keyboard.GetKey(KeyCode.LeftControl) | Keyboard.GetKey(KeyCode.RightControl))
         {
             if (InputEvent != null)
             {
                 InputEvent.textInfo.startSelect = 0;
                 InputEvent.textInfo.endSelect   = InputEvent.textInfo.text.Length;
                 InputEvent.Selected();
             }
             return(EditState.Done);
         }
     }
     if (Keyboard.GetKeyDown(KeyCode.X))//剪切
     {
         if (Keyboard.GetKey(KeyCode.LeftControl) | Keyboard.GetKey(KeyCode.RightControl))
         {
             if (InputEvent != null)
             {
                 string str = InputEvent.SelectString;
                 InputEvent.Delete(-1);
                 ThreadMission.InvokeToMain((o) => { GUIUtility.systemCopyBuffer = str; }, null);
             }
             return(EditState.Done);
         }
     }
     if (Keyboard.GetKeyDown(KeyCode.C))//复制
     {
         if (Keyboard.GetKey(KeyCode.LeftControl) | Keyboard.GetKey(KeyCode.RightControl))
         {
             if (InputEvent != null)
             {
                 string str = InputEvent.SelectString;
                 ThreadMission.InvokeToMain((o) => { GUIUtility.systemCopyBuffer = str; }, null);
             }
             return(EditState.Done);
         }
     }
     if (Keyboard.GetKeyDown(KeyCode.V))//粘贴
     {
         if (Keyboard.GetKey(KeyCode.LeftControl) | Keyboard.GetKey(KeyCode.RightControl))
         {
             if (InputEvent != null)
             {
                 InputEvent.OnInputChanged(Keyboard.systemCopyBuffer);
             }
             return(EditState.Done);
         }
     }
     if (Keyboard.GetKeyDown(KeyCode.Return) | Keyboard.GetKeyDown(KeyCode.KeypadEnter))
     {
         if (InputEvent.lineType == LineType.MultiLineNewline)
         {
             if (Keyboard.GetKey(KeyCode.RightControl))
             {
                 return(EditState.Finish);
             }
             return(EditState.NewLine);
         }
         else
         {
             return(EditState.Finish);
         }
     }
     if (Keyboard.GetKeyDown(KeyCode.Escape))
     {
         return(EditState.Finish);
     }
     return(EditState.Continue);
 }