Exemplo n.º 1
0
        public override void OnLayout(UIRenderContext rctx, ref UIElementLayout elementLayout)
        {
            base.OnLayout(rctx, ref elementLayout);

            List<UIDialogManager.DialogInstance> dlgs = UIDialogManager.GetDialogs();
            foreach (UIDialogManager.DialogInstance d in dlgs)
            {
                LayoutDialog(rctx, ref elementLayout, d);
            }
        }
Exemplo n.º 2
0
        public virtual void Render(UIRenderContext rctx, ref UIElementLayout layout)
        {
            DoLiveUpdate(rctx, ref layout);

            for (int i = 0; i < m_rtData.Length; i++)
            {
                if (m_rtData[i].element != null)
                {
                    RenderSubElement(rctx, ref layout, m_rtData[i].element, m_rtData[i].renderer, ref m_rtData[i].layout);
                }
            }
        }
Exemplo n.º 3
0
        public void DoLiveUpdate(UIRenderContext rctx, ref UIElementLayout layout)
        {
            // Live update
            bool change = Putki.LiveUpdate.Update(ref m_data);
            for (int i = 0; i < m_rtData.Length; i++)
                change |= Putki.LiveUpdate.IsOld(m_rtData[i].element);

            // reload if changed.
            if (change)
            {
                Setup(m_data, m_handler);
                OnLayout(rctx, ref layout);
            }
        }
Exemplo n.º 4
0
        public override void Render(UIRenderContext rctx, ref UIElementLayout layout)
        {
            List<UIDialogManager.DialogInstance> dlgs = UIDialogManager.GetDialogs();

            float fadeTarget = 0;
            if (dlgs.Count > 0)
                fadeTarget = 1;

            if (m_plateFade == -1)
            {
                m_plateFade = fadeTarget;
            }
            else
            {
                m_plateFade += rctx.FrameDelta * 5.0f * (fadeTarget - m_plateFade);
                if (fadeTarget == 1 && m_plateFade > 0.98f)
                    m_plateFade = 1.0f;
                else if (fadeTarget == 0 && m_plateFade < 0.02f)
                    m_plateFade = 0.0f;
            }

            outki.UIColor plate = new outki.UIColor();
            plate.r = 0;
            plate.g = 0;
            plate.b = 0;
            plate.a = (byte)(128 * m_plateFade);

            UIRenderer.DrawSolidRect(layout.x0, layout.y0, layout.x1, layout.y1, plate);

            base.Render(rctx, ref layout);

            foreach (UIDialogManager.DialogInstance d in dlgs)
            {
                // Reinitialize if have no renderer, or handled by wrong widget..
                if (d.Renderer == null || d.DialogContainerTag != (object)this)
                {
                    d.DialogContainerTag = (object)this;
                    d.Renderer = m_handler.CreateWidgetRenderer(d.Template);
                    LayoutDialog(rctx, ref layout, d);
                }

                d.Renderer.Render(rctx, ref layout);
            }
        }
Exemplo n.º 5
0
 private void LayoutDialog(UIRenderContext rctx, ref UIElementLayout layout, UIDialogManager.DialogInstance dlg)
 {
     if (dlg.Renderer != null)
         dlg.Renderer.OnLayout(rctx, ref layout);
 }
Exemplo n.º 6
0
        public void Draw(float x0, float y0, float x1, float y1, float frameDelta, UIInputManager inputManager, EventHandler eventHandler)
        {
            bool mod = false;
            mod |= Putki.LiveUpdate.Update(ref m_screen);
            mod |= Putki.LiveUpdate.Update(ref m_screen.Root);
            if (mod)
            {
                CreateAndInit();
            }

            // calculate the scale
            bool preserveLayoutAspect = m_screen.Config.PreserveLayoutAspect;
            bool useLayoutScaling = (m_screen.Config.ScaleMode == outki.UIScaleMode.ScaleMode_Prop_Layout);
            bool useMatrixScaling = (m_screen.Config.ScaleMode == outki.UIScaleMode.ScaleMode_Prop_Transform);

            UIElementLayout el = new UIElementLayout();

            // Compute the actual screen pixels (first iteration), to figure out where on
            // the display this screen should be layouted.
            if (preserveLayoutAspect)
            {
                float cutW = m_screen.Root.width - m_screen.Config.CutL - m_screen.Config.CutR;
                float cutH = m_screen.Root.height - m_screen.Config.CutT - m_screen.Config.CutB;

                // when layouting here,
                float sWidth = (x1 - x0) / cutW;
                float sHeight = (y1 - y0) / cutH;

                // use the lowest size.
                float sScale = sWidth < sHeight ? sWidth : sHeight;

                float tgtWidth = (float)Math.Floor(m_screen.Root.width * sScale);
                float tgtHeight = (float)Math.Floor(m_screen.Root.height * sScale);

                el.x0 = (float)Math.Floor((x0 + x1 - tgtWidth) / 2);
                el.y0 = (float)Math.Floor((y0 + y1 - tgtHeight) / 2);
                el.x1 = el.x0 + tgtWidth;
                el.y1 = el.y0 + tgtHeight;
            }
            else
            {
                el.x0 = x0;
                el.y0 = y0;
                el.x1 = x1;
                el.y1 = y1;
            }

            // Compute the (uniform) scale factor to use for layout/matrix scaling.
            UIRenderContext rctx = new UIRenderContext();
            rctx.InputManager = inputManager;
            rctx.TextureManager = m_textureManager;
            rctx.EventHandler = eventHandler;
            rctx.FrameDelta = frameDelta;

            if (rctx.EventHandler == null)
                rctx.EventHandler = new NullEventHandler();

            if (useLayoutScaling || useMatrixScaling)
            {
                float sWidth = (el.x1 - el.x0) / m_screen.Root.width;
                float sHeight = (el.y1 - el.y0) / m_screen.Root.height;
                float sScale = sWidth < sHeight ? sWidth : sHeight;

                if (m_screen.Config.SnapScale)
                {
                    for (int i=0;i<m_screen.ScalingForSnapping.Length;i++)
                    {
                        if (sScale > m_screen.ScalingForSnapping[i])
                        {
                            sScale = m_screen.ScalingForSnapping[i];
                            break;
                        }
                    }
                }

                rctx.LayoutScale = sScale;
                rctx.LayoutOffsetX = -(float)Math.Floor(el.x0 * (rctx.LayoutScale - 1));
                rctx.LayoutOffsetY = -(float)Math.Floor(el.y0 * (rctx.LayoutScale - 1));
            }
            else
            {
                rctx.LayoutScale = 1;
                rctx.LayoutOffsetX = 0;
                rctx.LayoutOffsetY = 0;
            }

            // the non scaled, layout rect.
            el.nsx0 = el.x0;
            el.nsy0 = el.y0;
            el.nsx1 = el.x0 + (float) Math.Floor((el.x1 - el.x0) / rctx.LayoutScale);
            el.nsy1 = el.y0 + (float) Math.Floor((el.y1 - el.y0) / rctx.LayoutScale);

            m_rootRenderer.OnLayout(rctx, ref el);
            m_rootRenderer.Render(rctx, ref el);
        }
Exemplo n.º 7
0
 // This can be overriden for custom drawing.
 public virtual void RenderSubElement(UIRenderContext rctx, ref UIElementLayout myLayout, outki.UIElement element, UIElementRenderer renderer, ref UIElementLayout layout)
 {
     renderer.Render(rctx, ref layout);
 }
Exemplo n.º 8
0
 public virtual void OnLayout(UIRenderContext rctx, ref UIElementLayout elementLayout)
 {
     LayoutElements(rctx, elementLayout.nsx0, elementLayout.nsy0, elementLayout.nsx1, elementLayout.nsy1);
 }