コード例 #1
0
 internal void WindowDisposed(DefaultWindow window)
 {
     lock (syncRoot)
     {
         windows.Remove(window);
     }
 }
コード例 #2
0
        /// <summary>
        /// Window rendering code.
        /// </summary>
        /// <param name="window"></param>
        void RenderWindow(DefaultWindow window)
        {
            if (!window.IsVisible)
            {
                return;
            }
            if (window.windowState == WindowState.Minimized)
            {
                return;
            }

            // We get bounds.
            Vector2i position = window.Position;
            Vector2i size     = window.Size;

            // We now composite them.
            compositor.Push(window.renderData);
            //compositor.Push(Colour.Blue);
            //compositor.Add();

            // We first resize to match size.
            compositor.Resize((uint)size.X, (uint)size.Y);

            // We apply all affects if necessary.
            foreach (IWindowEffect effect in window.effects)
            {
                // We handle single image effects.

                // Should be some
            }


            // We handle possible compositing effects (only one possible).
            foreach (IWindowEffect effect in window.effects)
            {
                if (effect is WindowBlend)
                {
                    WindowBlend blendEffect = (WindowBlend)effect;

                    if (!blendEffect.UseRenderTargetAlpha)
                    {
                        // We apply it.
                        compositor.BlendTo((uint)position.X, (uint)position.Y, BlendOperation.Add,
                                           BlendOperand.BlendFactorInverse, BlendOperand.BlendFactor, blendEffect.BlendFactor, renderTarget);
                    }
                    else
                    {
                        compositor.BlendTo((uint)position.X, (uint)position.Y, BlendOperation.Add,
                                           BlendOperand.SrcAlphaInverse, BlendOperand.SrcAlpha, blendEffect.BlendFactor, renderTarget);
                    }

                    return;
                }
            }

            // Otherwise, we do normal composition.
            compositor.CopyTo((uint)position.X, (uint)position.Y, renderTarget);
        }
コード例 #3
0
 internal void WindowFullscreened(DefaultWindow window, bool state)
 {
     if (state)
     {
         fullscreenWindow = window;
     }
     else
     {
         fullscreenWindow = null;
     }
 }
コード例 #4
0
        /// <summary>
        /// We render window's title
        /// </summary>
        /// <param name="window"></param>
        void RenderWindowTitleBar(DefaultWindow window)
        {
            if (!window.IsVisible)
            {
                return;
            }
            if (window.windowState == WindowState.Minimized)
            {
                return;
            }

            // TODO:
        }
コード例 #5
0
        public IWindow CreateWindow(Guid resourceId, string title, string windowGroup,
                                    IWindowBackend listener, WindowOptions options, Vector2i position,
                                    Vector2i size, Vector2i?minSize, Vector2i?maxSize, WindowState state,
                                    IWindow parentWindow, bool blockParentInput)
        {
            lock (syncRoot)
            {
                AssertNotDisposed();


                DefaultWindow window = new DefaultWindow(this, resourceId, title, windowGroup,
                                                         listener, options, position, size, minSize.GetValueOrDefault(new Vector2i(0, 0)),
                                                         maxSize.GetValueOrDefault(new Vector2i(int.MaxValue, int.MaxValue)), state,
                                                         parentWindow, blockParentInput);

                windows.Add(window);

                return(window);
            }
        }
コード例 #6
0
        /// <summary>
        /// Rendering code, forces rendering.
        /// </summary>
        public void Render()
        {
            lock (syncRoot)
            {
                // We do not render if everything is synced.
                if (!isDirty)
                {
                    return;
                }

                using (DeviceLock l = device.Lock())
                {
                    // 1) First fire pre-rendering the event.
                    Action <IWindowManager> t = onPreRendering;
                    if (t != null)
                    {
                        t(this);
                    }

                    // 2) Fullscreen rendering or not
                    if (fullscreenWindow != null)
                    {
                        lock (fullscreenWindow.syncRoot)
                        {
                            // We copy the window's target to ours.
                            compositor.Push(fullscreenWindow.renderData);

                            // We resize (a null operation in most cases).
                            compositor.Resize(renderTarget.Width, renderTarget.Height);

                            // We copy fullscreen application.
                            compositor.CopyTo(renderTarget);
                        }
                        return;
                    }
                    else
                    {
                        // 3) We render background (desktop).
                        desktopManager.Render();

                        // 4) We render windows in z-order.
                        for (int i = 0; i < windows.Count; i++)
                        {
                            DefaultWindow window = windows[i] as DefaultWindow;
                            lock (window.syncRoot)
                            {
                                // Renders window by compositing image.
                                RenderWindow(window);

                                // We also render title bar.
                                RenderWindowTitleBar(window);
                            }
                        }
                    }

                    // 5) We fire post-rendering event.
                    t = onPostRendering;
                    if (t != null)
                    {
                        t(this);
                    }
                }
            }
        }
コード例 #7
0
        internal void SetZOrder(DefaultWindow window, IWindow reference, bool after)
        {
            lock (syncRoot)
            {
                int idx = windows.IndexOf(window);

                // We must have found it.
                if (reference == null)
                {
                    windows.RemoveAt(idx);
                    if (after)
                    {
                        windows.Add(window);
                    }
                    else
                    {
                        windows.Insert(0, window);
                    }
                }
                else
                {
                    int refIdx = windows.IndexOf(reference as DefaultWindow);

                    if (refIdx < 0)
                    {
                        throw new InvalidOperationException("Reference window is invalid.");
                    }


                    if (after)
                    {
                        // Special case last.
                        if (refIdx + 1 == windows.Count)
                        {
                            windows.RemoveAt(idx);
                            windows.Add(window);
                        }
                        else
                        {
                            // Removing change indexing of window.
                            windows.RemoveAt(idx);
                            if (refIdx >= idx)
                            {
                                windows.Insert(refIdx, window);
                            }
                            else
                            {
                                windows.Insert(refIdx + 1, window);
                            }
                        }
                    }
                    else
                    {
                        // Removing change indexing of window.
                        windows.RemoveAt(idx);
                        if (refIdx >= idx)
                        {
                            windows.Insert(refIdx - 1 > 0 ? refIdx - 1 : 0, window);
                        }
                        else
                        {
                            windows.Insert(refIdx, window);
                        }
                    }
                }
            }
        }
コード例 #8
0
 internal void SetFocused(DefaultWindow window)
 {
     focused = window;
 }