[gtkmm] Add Gdk::DrawContext



commit 02eb713e451c94953aee8484c55227babb8df51b
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Mon Dec 12 18:19:31 2016 +0100

    Add Gdk::DrawContext
    
    * .gitignore: Add drawcontext.cc, drawcontext.h.
    * gdk/src/filelist.am: Add drawcontext.hg.
    * gdk/src/gdk_extra_objects.defs: Add DrawContext.
    * tools/m4/convert_gdk.m4: Add conversions for DrawContext.
    * gdk/src/drawcontext.[ccg|hg]: New files.
    * gdk/src/drawingcontext.[ccg|hg]: Add get_paint_context() and
    property_paint_context().
    * gdk/src/glcontext.hg: Derive from Gdk::DrawContext. Add get_damage().
    Remove property_display() and property_window(), which are moved to
    DrawContext.
    * gdk/src/window.[ccg|hg]: Fix begin_draw_frame().

 .gitignore                     |    2 +
 gdk/src/drawcontext.ccg        |   18 ++++++++++++
 gdk/src/drawcontext.hg         |   58 ++++++++++++++++++++++++++++++++++++++++
 gdk/src/drawingcontext.ccg     |    1 +
 gdk/src/drawingcontext.hg      |    5 +++
 gdk/src/filelist.am            |    1 +
 gdk/src/gdk_extra_objects.defs |    6 ++++
 gdk/src/glcontext.hg           |   17 +++++++----
 gdk/src/window.ccg             |    1 +
 gdk/src/window.hg              |    3 +-
 tools/m4/convert_gdk.m4        |    3 ++
 11 files changed, 108 insertions(+), 7 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 926f457..188a29d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -62,6 +62,8 @@ gdk/gdkmm/displaymanager.cc
 gdk/gdkmm/displaymanager.h
 gdk/gdkmm/dragcontext.cc
 gdk/gdkmm/dragcontext.h
+gdk/gdkmm/drawcontext.cc
+gdk/gdkmm/drawcontext.h
 gdk/gdkmm/drawingcontext.cc
 gdk/gdkmm/drawingcontext.h
 gdk/gdkmm/event.cc
diff --git a/gdk/src/drawcontext.ccg b/gdk/src/drawcontext.ccg
new file mode 100644
index 0000000..2364a3b
--- /dev/null
+++ b/gdk/src/drawcontext.ccg
@@ -0,0 +1,18 @@
+/* Copyright (C) 2016 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gdkmm/display.h>
+#include <gdkmm/window.h>
diff --git a/gdk/src/drawcontext.hg b/gdk/src/drawcontext.hg
new file mode 100644
index 0000000..fe82f7f
--- /dev/null
+++ b/gdk/src/drawcontext.hg
@@ -0,0 +1,58 @@
+
+/* Copyright (C) 2016 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glibmm/object.h>
+
+_DEFS(gdkmm,gdk)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gdk
+{
+class Display;
+class Window;
+
+/** Drawing context base class.
+ *
+ * %Gdk::DrawContext is the base object used by contexts implementing different
+ * rendering methods, such as GLContext or VulkanContext. It provides
+ * shared functionality between those contexts.
+ *
+ * You will always interact with one of those subclasses.
+ *
+ * @newin{3,90}
+ */
+class DrawContext : public Glib::Object
+{
+  _CLASS_GOBJECT(DrawContext, GdkDrawContext, GDK_DRAW_CONTEXT, Glib::Object, GObject)
+
+protected:
+  /// This constructor is protected because only derived classes shall be instantiated.
+  _CTOR_DEFAULT()
+
+public:
+  _WRAP_METHOD(Glib::RefPtr<Display> get_display(), gdk_draw_context_get_display, refreturn)
+  _WRAP_METHOD(Glib::RefPtr<const Display> get_display() const, gdk_draw_context_get_display, refreturn, 
constversion)
+  _WRAP_METHOD(Glib::RefPtr<Window> get_window(), gdk_draw_context_get_window, refreturn)
+  _WRAP_METHOD(Glib::RefPtr<const Window> get_window() const, gdk_draw_context_get_window, refreturn, 
constversion)
+
+  _WRAP_PROPERTY("display", Glib::RefPtr<Display>)
+  _WRAP_PROPERTY("window", Glib::RefPtr<Window>)
+
+  // There are no signals or vfuncs.
+};
+
+} // namespace Gdk
diff --git a/gdk/src/drawingcontext.ccg b/gdk/src/drawingcontext.ccg
index 6c73b72..a7e6c4c 100644
--- a/gdk/src/drawingcontext.ccg
+++ b/gdk/src/drawingcontext.ccg
@@ -14,4 +14,5 @@
  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <gdkmm/drawcontext.h>
 #include <gdkmm/window.h>
diff --git a/gdk/src/drawingcontext.hg b/gdk/src/drawingcontext.hg
index 4ef410a..b4c3883 100644
--- a/gdk/src/drawingcontext.hg
+++ b/gdk/src/drawingcontext.hg
@@ -23,6 +23,7 @@ _PINCLUDE(glibmm/private/object_p.h)
 
 namespace Gdk
 {
+class DrawContext;
 class Window;
 
 /** Drawing context for GDK windows.
@@ -49,6 +50,9 @@ public:
   _WRAP_METHOD(Glib::RefPtr<Window> get_window(), gdk_drawing_context_get_window, refreturn)
   _WRAP_METHOD(Glib::RefPtr<const Window> get_window() const, gdk_drawing_context_get_window, refreturn, 
constversion)
 
+  _WRAP_METHOD(Glib::RefPtr<DrawContext> get_paint_context(), gdk_drawing_context_get_paint_context, 
refreturn,)
+  _WRAP_METHOD(Glib::RefPtr<const DrawContext> get_paint_context() const, 
gdk_drawing_context_get_paint_context, refreturn, constversion)
+
 #m4 _CONVERSION(`cairo_region_t*',`::Cairo::RefPtr< ::Cairo::Region>',`::Cairo::make_refptr_for_instance< 
::Cairo::Region>(new ::Cairo::Region($3, true /* do not take ref */))')
   // This is const because it returns a copy.
   _WRAP_METHOD(::Cairo::RefPtr< ::Cairo::Region> get_clip() const, gdk_drawing_context_get_clip)
@@ -66,6 +70,7 @@ public:
   // A wrapped property_clip() would require a template specialization
   // Glib::Value<Cairo::RefPtr<T>>.
   //_WRAP_PROPERTY("clip", ::Cairo::RefPtr< ::Cairo::Region>)
+  _WRAP_PROPERTY("paint-context", Glib::RefPtr<DrawContext>)
 
   // There are no signals or vfuncs.
 };
diff --git a/gdk/src/filelist.am b/gdk/src/filelist.am
index 29d2e3e..b6499bb 100644
--- a/gdk/src/filelist.am
+++ b/gdk/src/filelist.am
@@ -20,6 +20,7 @@ gdkmm_files_any_hg =          \
        display.hg              \
        displaymanager.hg       \
        dragcontext.hg          \
+       drawcontext.hg          \
        drawingcontext.hg               \
        event.hg                \
        glcontext.hg            \
diff --git a/gdk/src/gdk_extra_objects.defs b/gdk/src/gdk_extra_objects.defs
index c8dee38..36d65b2 100644
--- a/gdk/src/gdk_extra_objects.defs
+++ b/gdk/src/gdk_extra_objects.defs
@@ -50,6 +50,12 @@
   (gtype-id "GDK_TYPE_DRAG_CONTEXT")
 )
 
+(define-object DrawContext
+  (in-module "Gdk")
+  (c-name "GdkDrawContext")
+  (gtype-id "GDK_TYPE_DRAW_CONTEXT")
+)
+
 (define-object DrawingContext
   (in-module "Gdk")
   (c-name "GdkDrawingContext")
diff --git a/gdk/src/glcontext.hg b/gdk/src/glcontext.hg
index 7c54ef6..8775989 100644
--- a/gdk/src/glcontext.hg
+++ b/gdk/src/glcontext.hg
@@ -16,24 +16,27 @@
  */
 
 #include <gdkmmconfig.h>
+#include <gdkmm/drawcontext.h>
 #include <gdkmm/display.h>
 #include <gdkmm/window.h>
 
 _DEFS(gdkmm,gdk)
-_PINCLUDE(glibmm/private/object_p.h)
+_PINCLUDE(gdkmm/private/drawcontext_p.h)
 
 namespace Gdk
 {
 
 _WRAP_GERROR(GLError, GdkGLError, GDK_GL_ERROR, newin "3,18")
 
-/** A Gdk::GLContext is an OpenGL context abstraction. It's a low-level object, used to implement high-level 
objects such
+/** A %Gdk::GLContext is an OpenGL context abstraction.
+ *
+ * It's a low-level object, used to implement high-level objects such
  * as Gtk::GLArea on the GTK+ level.
  * @newin{3,18}
  */
-class GLContext : public Glib::Object
+class GLContext : public DrawContext
 {
-  _CLASS_GOBJECT(GLContext,GdkGLContext,GDK_GL_CONTEXT,Glib::Object,GObject)
+  _CLASS_GOBJECT(GLContext, GdkGLContext, GDK_GL_CONTEXT, Gdk::DrawContext, GdkDrawContext)
 
 protected:
   _CTOR_DEFAULT
@@ -56,13 +59,15 @@ public:
   _WRAP_METHOD(void set_use_es(bool use_es = true), gdk_gl_context_set_use_es)
   _WRAP_METHOD(bool get_use_es() const, gdk_gl_context_get_use_es)
   _WRAP_METHOD(bool realize(), gdk_gl_context_realize, errthrow, newin "3,18")
+
+#m4 _CONVERSION(`cairo_region_t*',`::Cairo::RefPtr< ::Cairo::Region>',`::Cairo::make_refptr_for_instance< 
::Cairo::Region>(new ::Cairo::Region($3, true /* do not take ref */))')
+  // This is const because it returns a newly created Cairo::Region (though that is not very clear from the 
C documentation)
+  _WRAP_METHOD(::Cairo::RefPtr< ::Cairo::Region> get_damage() const, gdk_gl_context_get_damage)
   _WRAP_METHOD(void make_current(), gdk_gl_context_make_current, newin "3,18")
   _WRAP_METHOD(static Glib::RefPtr<GLContext> get_current(), gdk_gl_context_get_current, refreturn, newin 
"3,18")
   _WRAP_METHOD(static void clear_current(), gdk_gl_context_clear_current, newin "3,18")
 
-  _WRAP_PROPERTY("display", Glib::RefPtr<Display>, newin "3,18")
   _WRAP_PROPERTY("shared-context", Glib::RefPtr<GLContext>, newin "3,18")
-  _WRAP_PROPERTY("window", Glib::RefPtr<Window>, newin "3,18")
 };
 
 } // namespace Gdk
diff --git a/gdk/src/window.ccg b/gdk/src/window.ccg
index 1f858ab..ad6378d 100644
--- a/gdk/src/window.ccg
+++ b/gdk/src/window.ccg
@@ -20,6 +20,7 @@
 #include <gdkmm/device.h>
 #include <gdkmm/types.h>
 #include <gdkmm/glcontext.h>
+#include <gdkmm/drawcontext.h>
 #include <gdkmm/drawingcontext.h>
 
 namespace Gdk
diff --git a/gdk/src/window.hg b/gdk/src/window.hg
index dc58ffa..61f8167 100644
--- a/gdk/src/window.hg
+++ b/gdk/src/window.hg
@@ -48,6 +48,7 @@ _WRAP_ENUM(FullscreenMode, GdkFullscreenMode)
 class Cursor;
 class Pixbuf;
 class GLContext;
+class DrawContext;
 class DrawingContext;
 
 /** A Gdk::Window is a rectangular region on the screen. It's a low-level object, used to implement 
high-level objects such
@@ -364,7 +365,7 @@ public:
    */
   _WRAP_METHOD(Glib::RefPtr<Gdk::GLContext> create_gl_context(), gdk_window_create_gl_context, errthrow)
 
-  _WRAP_METHOD(Glib::RefPtr<DrawingContext> begin_draw_frame(const Glib::RefPtr<DrawingContext>& context{?}, 
const ::Cairo::RefPtr<const ::Cairo::Region>& region) gdk_window_begin_draw_frame, refreturn)
+  _WRAP_METHOD(Glib::RefPtr<DrawingContext> begin_draw_frame(const Glib::RefPtr<DrawContext>& context{?}, 
const ::Cairo::RefPtr<const ::Cairo::Region>& region), gdk_window_begin_draw_frame, refreturn)
   _WRAP_METHOD(void end_draw_frame(const Glib::RefPtr<DrawingContext>& context), gdk_window_end_draw_frame)
 
   _IGNORE_SIGNAL("moved-to-rect")dnl// Private
diff --git a/tools/m4/convert_gdk.m4 b/tools/m4/convert_gdk.m4
index 256b64e..3ebb25f 100644
--- a/tools/m4/convert_gdk.m4
+++ b/tools/m4/convert_gdk.m4
@@ -112,6 +112,7 @@ _CONVERSION(`const Glib::RefPtr<Gdk::Window>&',`GdkWindow*',__CONVERT_REFPTR_TO_
 _CONVERSION(`const Glib::RefPtr<Window>&',`GdkWindow*',__CONVERT_REFPTR_TO_P)
 _CONVERSION(`const Glib::RefPtr<GLContext>&',`GdkGLContext*',__CONVERT_REFPTR_TO_P)
 _CONVERSION(`const Glib::RefPtr<Gdk::GLContext>&',`GdkGLContext*',__CONVERT_REFPTR_TO_P)
+_CONVERSION(`const Glib::RefPtr<DrawContext>&',`GdkDrawContext*',__CONVERT_REFPTR_TO_P)
 _CONVERSION(`const Glib::RefPtr<DrawingContext>&',`GdkDrawingContext*',__CONVERT_REFPTR_TO_P)
 _CONVERSION(`const Glib::RefPtr<Pixmap>&',`GdkPixmap*',__CONVERT_REFPTR_TO_P)
 _CONVERSION(`const Glib::RefPtr<Gdk::Pixmap>&',`GdkPixmap*',__CONVERT_REFPTR_TO_P)
@@ -190,6 +191,8 @@ _CONVERSION(`GdkGLContext*',`Glib::RefPtr<GLContext>', `Glib::wrap($3)')
 _CONVERSION(`GdkGLContext*',`Glib::RefPtr<const GLContext>', `Glib::wrap($3)')
 _CONVERSION(`GdkGLContext*',`Glib::RefPtr<Gdk::GLContext>', `Glib::wrap($3)')
 _CONVERSION(`GdkGLContext*',`Glib::RefPtr<const Gdk::GLContext>', `Glib::wrap($3)')
+_CONVERSION(`GdkDrawContext*',`Glib::RefPtr<DrawContext>', `Glib::wrap($3)')
+_CONVERSION(`GdkDrawContext*',`Glib::RefPtr<const DrawContext>', `Glib::wrap($3)')
 _CONVERSION(`GdkDrawingContext*',`Glib::RefPtr<DrawingContext>', `Glib::wrap($3)')
 _CONVERSION(`GdkPixmap*',`Glib::RefPtr<Pixmap>', `Glib::wrap((GdkPixmapObject*)($3))')
 _CONVERSION(`GdkPixmap*',`Glib::RefPtr<const Pixmap>', `Glib::wrap((GdkPixmapObject*)($3))')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]