From 5979ab2eb2a9a66ceb1d51c921691874f6372296 Mon Sep 17 00:00:00 2001
From: StapleButter <thetotalworm@gmail.com>
Date: Tue, 19 Sep 2017 00:36:25 +0200
Subject: libui: fix bug with filepicker filters under GTK. add skeleton for
 bitmaps. add the right cmake shit.

---
 src/libui_sdl/libui/unix/draw.c       | 53 +++++++++++++++++++++++++++++++++++
 src/libui_sdl/libui/unix/draw.h       |  8 ++++++
 src/libui_sdl/libui/unix/stddialogs.c |  3 +-
 3 files changed, 63 insertions(+), 1 deletion(-)

(limited to 'src/libui_sdl/libui/unix')

diff --git a/src/libui_sdl/libui/unix/draw.c b/src/libui_sdl/libui/unix/draw.c
index 2d7a636..16ff986 100644
--- a/src/libui_sdl/libui/unix/draw.c
+++ b/src/libui_sdl/libui/unix/draw.c
@@ -139,3 +139,56 @@ void uiDrawRestore(uiDrawContext *c)
 {
 	cairo_restore(c->cr);
 }
+
+
+// bitmap API
+
+uiDrawBitmap* uiDrawNewBitmap(uiDrawContext* c, int width, int height)
+{
+    /*uiDrawBitmap* bmp;
+    HRESULT hr;
+
+    bmp = uiNew(uiDrawBitmap);
+
+    D2D1_BITMAP_PROPERTIES bp2 = D2D1::BitmapProperties();
+    bp2.dpiX = 0;
+    bp2.dpiY = 0;
+    bp2.pixelFormat = D2D1::PixelFormat(DXGI_FORMAT_R8G8B8A8_UNORM, D2D1_ALPHA_MODE_IGNORE);
+    //bp2.pixelFormat = D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE);
+    // TODO: fallback: convert to BGRA if needed (RGBA only works in hardware mode)
+
+    c->rt->BeginDraw();
+
+    hr = c->rt->CreateBitmap(D2D1::SizeU(width,height), NULL, 0, &bp2, &bmp->bmp);
+    if (hr != S_OK)
+		logHRESULT(L"error creating bitmap", hr);
+
+    c->rt->EndDraw();
+
+    bmp->Width = width;
+    bmp->Height = height;
+    bmp->Stride = width*4;
+
+    return bmp;*/
+    return NULL;
+}
+
+void uiDrawBitmapUpdate(uiDrawBitmap* bmp, const void* data)
+{
+    //D2D1_RECT_U rekt = D2D1::RectU(0, 0, bmp->Width, bmp->Height);
+    //bmp->bmp->CopyFromMemory(&rekt, data, bmp->Stride);
+}
+
+void uiDrawBitmapDraw(uiDrawContext* c, uiDrawBitmap* bmp, uiRect* srcrect, uiRect* dstrect)
+{
+    /*D2D_RECT_F _srcrect = D2D1::RectF(srcrect->X, srcrect->Y, srcrect->X+srcrect->Width, srcrect->Y+srcrect->Height);
+    D2D_RECT_F _dstrect = D2D1::RectF(dstrect->X, dstrect->Y, dstrect->X+dstrect->Width, dstrect->Y+dstrect->Height);
+
+    c->rt->DrawBitmap(bmp->bmp, &_dstrect, 1.0f, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, &_srcrect);*/
+}
+
+void uiDrawFreeBitmap(uiDrawBitmap* bmp)
+{
+    //bmp->bmp->Release();
+    //uiFree(bmp);
+}
diff --git a/src/libui_sdl/libui/unix/draw.h b/src/libui_sdl/libui/unix/draw.h
index dbd82ff..db4612c 100644
--- a/src/libui_sdl/libui/unix/draw.h
+++ b/src/libui_sdl/libui/unix/draw.h
@@ -5,6 +5,14 @@ struct uiDrawContext {
 	cairo_t *cr;
 };
 
+struct uiDrawBitmap {
+    int Width;
+    int Height;
+    int Stride;
+
+    // add cairo shit here
+};
+
 // drawpath.c
 extern void runPath(uiDrawPath *p, cairo_t *cr);
 extern uiDrawFillMode pathFillMode(uiDrawPath *path);
diff --git a/src/libui_sdl/libui/unix/stddialogs.c b/src/libui_sdl/libui/unix/stddialogs.c
index edce773..9d7b62a 100644
--- a/src/libui_sdl/libui/unix/stddialogs.c
+++ b/src/libui_sdl/libui/unix/stddialogs.c
@@ -38,6 +38,7 @@ static char *filedialog(GtkWindow *parent, GtkFileChooserAction mode, const gcha
 					{
 						if (*j == ';')
 						{
+						    *j = '\0';
 							gtk_file_filter_add_pattern(filter, fp);
 							fp = j+1;
 						}
@@ -47,7 +48,7 @@ static char *filedialog(GtkWindow *parent, GtkFileChooserAction mode, const gcha
 							break;
 						}
 					}
-					
+					printf("add filter\n");
 					gtk_file_chooser_add_filter(fc, filter);
                 }
                 else
-- 
cgit v1.2.3