libui: fix bug with filepicker filters under GTK. add skeleton for bitmaps. add the right cmake shit.

This commit is contained in:
StapleButter 2017-09-19 00:36:25 +02:00
parent f30e19a2ec
commit 5979ab2eb2
4 changed files with 130 additions and 13 deletions

View File

@ -6,10 +6,8 @@ SET(PROJECT_WX melonDS)
PROJECT(${PROJECT_WX}) PROJECT(${PROJECT_WX})
SET(SOURCES SET(SOURCES
src/wx/main.cpp src/libui_sdl/main.cpp
src/wx/EmuConfig.cpp src/libui_sdl/Platform.cpp
src/wx/InputConfig.cpp
src/wx/Platform.cpp
src/ARM.cpp src/ARM.cpp
src/ARMInterpreter.cpp src/ARMInterpreter.cpp
src/ARMInterpreter_ALU.cpp src/ARMInterpreter_ALU.cpp
@ -27,16 +25,64 @@ SET(SOURCES
src/RTC.cpp src/RTC.cpp
src/SPI.cpp src/SPI.cpp
src/SPU.cpp src/SPU.cpp
src/Wifi.cpp) src/Wifi.cpp
src/libui_sdl/libui/common/areaevents.c
src/libui_sdl/libui/common/control.c
src/libui_sdl/libui/common/debug.c
src/libui_sdl/libui/common/matrix.c
src/libui_sdl/libui/common/shouldquit.c
src/libui_sdl/libui/common/userbugs.c
src/libui_sdl/libui/unix/alloc.c
src/libui_sdl/libui/unix/area.c
src/libui_sdl/libui/unix/box.c
src/libui_sdl/libui/unix/button.c
src/libui_sdl/libui/unix/cellrendererbutton.c
src/libui_sdl/libui/unix/checkbox.c
src/libui_sdl/libui/unix/child.c
src/libui_sdl/libui/unix/colorbutton.c
src/libui_sdl/libui/unix/combobox.c
src/libui_sdl/libui/unix/control.c
src/libui_sdl/libui/unix/datetimepicker.c
src/libui_sdl/libui/unix/debug.c
src/libui_sdl/libui/unix/draw.c
src/libui_sdl/libui/unix/drawmatrix.c
src/libui_sdl/libui/unix/drawpath.c
src/libui_sdl/libui/unix/drawtext.c
src/libui_sdl/libui/unix/editablecombo.c
src/libui_sdl/libui/unix/entry.c
src/libui_sdl/libui/unix/fontbutton.c
src/libui_sdl/libui/unix/form.c
src/libui_sdl/libui/unix/future.c
src/libui_sdl/libui/unix/graphemes.c
src/libui_sdl/libui/unix/grid.c
src/libui_sdl/libui/unix/group.c
src/libui_sdl/libui/unix/image.c
src/libui_sdl/libui/unix/label.c
src/libui_sdl/libui/unix/main.c
src/libui_sdl/libui/unix/menu.c
src/libui_sdl/libui/unix/multilineentry.c
src/libui_sdl/libui/unix/progressbar.c
src/libui_sdl/libui/unix/radiobuttons.c
src/libui_sdl/libui/unix/separator.c
src/libui_sdl/libui/unix/slider.c
src/libui_sdl/libui/unix/spinbox.c
src/libui_sdl/libui/unix/stddialogs.c
src/libui_sdl/libui/unix/tab.c
src/libui_sdl/libui/unix/text.c
src/libui_sdl/libui/unix/util.c
src/libui_sdl/libui/unix/window.c)
if (UNIX) if (UNIX)
find_package(GTK2 2.0 REQUIRED) FIND_PACKAGE(PkgConfig REQUIRED)
include_directories(${GTK2_INCLUDE_DIRS}) PKG_CHECK_MODULES(GTK3 REQUIRED gtk+-3.0)
endif (UNIX)
find_package(wxWidgets REQUIRED) INCLUDE_DIRECTORIES(${GTK3_INCLUDE_DIRS})
include(${wxWidgets_USE_FILE}) LINK_LIBRARIES(${GTK3_LIBRARIES})
link_libraries(${wxWidgets_LIBRARIES})
ADD_DEFINITIONS(${GTK3_CFLAGS_OTHER})
LINK_LIBRARIES("dl")
endif (UNIX)
find_package(SDL2 REQUIRED) find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIR}) include_directories(${SDL2_INCLUDE_DIR})
@ -45,6 +91,15 @@ link_libraries(${SDL2_LIBRARIES})
add_executable(${PROJECT_WX} ${SOURCES}) add_executable(${PROJECT_WX} ${SOURCES})
target_link_libraries(${PROJECT_WX}) target_link_libraries(${PROJECT_WX})
set(CMAKE_BUILD_TYPE Release) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
if(CMAKE_BUILD_TYPE EQUAL Debug)
set(CMAKE_CXX_FLAGS "-g")
endif()
if(CMAKE_BUILD_TYPE EQUAL Release)
set(CMAKE_CXX_FLAGS "-O3 -flto")
endif()
install(TARGETS ${PROJECT_WX} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) install(TARGETS ${PROJECT_WX} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)

View File

@ -139,3 +139,56 @@ void uiDrawRestore(uiDrawContext *c)
{ {
cairo_restore(c->cr); 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);
}

View File

@ -5,6 +5,14 @@ struct uiDrawContext {
cairo_t *cr; cairo_t *cr;
}; };
struct uiDrawBitmap {
int Width;
int Height;
int Stride;
// add cairo shit here
};
// drawpath.c // drawpath.c
extern void runPath(uiDrawPath *p, cairo_t *cr); extern void runPath(uiDrawPath *p, cairo_t *cr);
extern uiDrawFillMode pathFillMode(uiDrawPath *path); extern uiDrawFillMode pathFillMode(uiDrawPath *path);

View File

@ -38,6 +38,7 @@ static char *filedialog(GtkWindow *parent, GtkFileChooserAction mode, const gcha
{ {
if (*j == ';') if (*j == ';')
{ {
*j = '\0';
gtk_file_filter_add_pattern(filter, fp); gtk_file_filter_add_pattern(filter, fp);
fp = j+1; fp = j+1;
} }
@ -47,7 +48,7 @@ static char *filedialog(GtkWindow *parent, GtkFileChooserAction mode, const gcha
break; break;
} }
} }
printf("add filter\n");
gtk_file_chooser_add_filter(fc, filter); gtk_file_chooser_add_filter(fc, filter);
} }
else else