Exemplo n.º 1
0
        private static void RemoveSubscription(GtkWidget widget)
        {
            var impl = windowStack.FirstOrDefault(wbi => wbi.GtkWidget.Equals(widget));

            if (impl == null)
            {
                Logger.Warning("EventManager", widget, "Can't remove subscription for window");
                return;
            }

            if (modalStack.Remove(impl))
            {
                var lastModal = modalStack.LastOrDefault();
                if (lastModal == null)
                {
                    lastModal = windowStack.FirstOrDefault();
                    modalStack.Add(lastModal);
                }

                var windowEnum = windowStack.GetEnumerator();

                while (windowEnum.MoveNext() && windowEnum.Current != lastModal)
                {
                    ; // just skip all before the top modal window
                }
                while (windowEnum.MoveNext())
                {
                    Native.GtkWindowSetTransientFor(windowEnum.Current.GtkWidget, lastModal.GtkWidget);
                }
            }

            windowStack.Remove(impl);
        }
 public RenderOp(GtkWidget widget, CairoSurface _surface, double factor, int width, int height)
 {
     _widget       = widget;
     this._surface = _surface;
     _factor       = factor;
     _width        = width;
     _height       = height;
 }
Exemplo n.º 3
0
 public RenderOp(GtkWidget widget, ManagedCairoSurface surface, double factor, int width, int height)
 {
     _widget  = widget;
     _surface = surface ?? throw new ArgumentNullException();
     _factor  = factor;
     _width   = width;
     _height  = height;
 }
Exemplo n.º 4
0
        static void clicked(GtkWidget app, Void *userdata)
        {
            var dialog = (GtkDialog *)gtk_message_dialog_new(null,
                                                             GtkDialogFlags.GTK_DIALOG_DESTROY_WITH_PARENT,
                                                             GtkMessageType.GTK_MESSAGE_INFO,
                                                             GtkButtonsType.GTK_BUTTONS_OK,
                                                             "Hello World!");

            gtk_dialog_run(dialog);
            gtk_widget_destroy(dialog);
        }
Exemplo n.º 5
0
        public ImageSurfaceFramebuffer(WindowBaseImpl impl, int width, int height, int factor)
        {
            _impl    = impl;
            _widget  = impl.GtkWidget;
            _factor  = factor;
            width   *= _factor;
            height  *= _factor;
            _surface = new ManagedCairoSurface(width, height);

            Size     = new PixelSize(width, height);
            Address  = _surface.Buffer;
            RowBytes = _surface.Stride;
            Native.CairoSurfaceFlush(_surface.Surface);
        }
Exemplo n.º 6
0
        public ImageSurfaceFramebuffer(IntPtr context, GtkWidget widget, int width, int height)
        {
            _context = context;
            _widget  = widget;
            _factor  = (int)(Native.GtkWidgetGetScaleFactor?.Invoke(_widget) ?? 1u);
            width   *= _factor;
            height  *= _factor;
            _surface = Native.CairoImageSurfaceCreate(1, width, height);

            Width    = width;
            Height   = height;
            Address  = Native.CairoImageSurfaceGetData(_surface);
            RowBytes = Native.CairoImageSurfaceGetStride(_surface);
            Native.CairoSurfaceFlush(_surface);
        }
        public ImageSurfaceFramebuffer(WindowBaseImpl impl, int width, int height, int factor)
        {
            _impl    = impl;
            _widget  = impl.GtkWidget;
            _factor  = factor;
            width   *= _factor;
            height  *= _factor;
            _surface = Native.CairoImageSurfaceCreate(1, width, height);

            Width    = width;
            Height   = height;
            Address  = Native.CairoImageSurfaceGetData(_surface);
            RowBytes = Native.CairoImageSurfaceGetStride(_surface);
            Native.CairoSurfaceFlush(_surface);
        }
        /*
         * static Stopwatch St =Stopwatch.StartNew();
         * private static int _frames;
         * private static int _fps;*/
        static void DrawToWidget(GtkWidget widget, CairoSurface surface, int width, int height, double factor)
        {
            if (surface == null || widget.IsClosed)
            {
                return;
            }
            var window = Native.GtkWidgetGetWindow(widget);

            if (window == IntPtr.Zero)
            {
                return;
            }
            var rc = new GdkRectangle {
                Width = width, Height = height
            };

            Native.GdkWindowBeginPaintRect(window, ref rc);
            var context = Native.GdkCairoCreate(window);

            Draw(context, surface, factor);

            /*
             * _frames++;
             * var el = St.Elapsed;
             * if (el.TotalSeconds > 1)
             * {
             *  _fps = (int) (_frames / el.TotalSeconds);
             *  _frames = 0;
             *  St = Stopwatch.StartNew();
             * }
             *
             * Native.CairoSetSourceRgba(context, 1, 0, 0, 1);
             * Native.CairoMoveTo(context, 20, 20);
             * Native.CairoSetFontSize(context, 30);
             * using (var txt = new Utf8Buffer("FPS: " + _fps))
             *  Native.CairoShowText(context, txt);
             */

            Native.CairoDestroy(context);
            Native.GdkWindowEndPaint(window);
        }
Exemplo n.º 9
0
 public EventSubscription(GtkWidget gtkWidget)
 {
     GtkWidget = gtkWidget;
 }