diff --git a/dlanguilib.dproj b/dlanguilib.dproj index 584b02d1..8e382708 100644 --- a/dlanguilib.dproj +++ b/dlanguilib.dproj @@ -161,11 +161,22 @@ + + + 3rdparty\DerelictFI\freeimage.d + + + 3rdparty\DerelictFI\functions.d + + + 3rdparty\DerelictFI\types.d + + \ No newline at end of file diff --git a/examples/example1/res/btn_default_small_normal.9.png b/examples/example1/res/btn_default_small_normal.9.png new file mode 100644 index 00000000..5dddd464 Binary files /dev/null and b/examples/example1/res/btn_default_small_normal.9.png differ diff --git a/examples/example1/res/btn_default_small_normal_disable.9.png b/examples/example1/res/btn_default_small_normal_disable.9.png new file mode 100644 index 00000000..6ab5c4a2 Binary files /dev/null and b/examples/example1/res/btn_default_small_normal_disable.9.png differ diff --git a/examples/example1/res/btn_default_small_normal_disable_focused.9.png b/examples/example1/res/btn_default_small_normal_disable_focused.9.png new file mode 100644 index 00000000..c65bace3 Binary files /dev/null and b/examples/example1/res/btn_default_small_normal_disable_focused.9.png differ diff --git a/examples/example1/res/btn_default_small_pressed.9.png b/examples/example1/res/btn_default_small_pressed.9.png new file mode 100644 index 00000000..43e82f97 Binary files /dev/null and b/examples/example1/res/btn_default_small_pressed.9.png differ diff --git a/examples/example1/res/btn_default_small_selected.9.png b/examples/example1/res/btn_default_small_selected.9.png new file mode 100644 index 00000000..7a376a97 Binary files /dev/null and b/examples/example1/res/btn_default_small_selected.9.png differ diff --git a/src/dlangui/platforms/x11/x11app.d b/src/dlangui/platforms/x11/x11app.d index b2618933..b31bec03 100644 --- a/src/dlangui/platforms/x11/x11app.d +++ b/src/dlangui/platforms/x11/x11app.d @@ -2,419 +2,430 @@ module src.dlangui.platforms.x11.x11app; version(linux) { -import std.string; -import std.c.linux.X11.xcb.xcb; -import std.c.linux.X11.xcb.shm; -import std.c.linux.X11.xcb.xproto; -import std.c.linux.X11.xcb.image; -import std.c.linux.X11.keysymdef; -import std.c.linux.linux; -import std.c.stdlib; -import std.conv; + import std.string; + import std.c.linux.X11.xcb.xcb; + import std.c.linux.X11.xcb.shm; + import std.c.linux.X11.xcb.xproto; + import std.c.linux.X11.xcb.image; + import std.c.linux.X11.keysymdef; + import std.c.linux.linux; + import std.c.stdlib; + import std.conv; -import dlangui.core.logger; -import dlangui.graphics.drawbuf; -import dlangui.graphics.fonts; -import dlangui.graphics.ftfonts; -import dlangui.platforms.common.platform; + import dlangui.core.logger; + import dlangui.graphics.drawbuf; + import dlangui.graphics.fonts; + import dlangui.graphics.ftfonts; + import dlangui.platforms.common.platform; -class XCBWindow : Window { - xcb_window_t _w; - xcb_gcontext_t _g; - xcb_image_t * _image; - xcb_shm_segment_info_t shminfo; - @property xcb_window_t windowId() { return _w; } - this(string caption, Window parent) { - _caption = caption; - Log.d("Creating XCB window"); - create(); - } - ~this() { - Log.d("Destroying window"); - } - bool create() { - uint mask; - uint values[2]; - - /* create black graphics context */ - _g = xcb_generate_id(_xcbconnection); - _w = _xcbscreen.root; - mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES; - values[0] = _xcbscreen.black_pixel; - values[1] = 0; - xcb_create_gc(_xcbconnection, _g, _w, mask, &values[0]); - - /* create window */ - _w = xcb_generate_id(_xcbconnection); - - Log.d("window=", _w, " gc=", _g); - - mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; - values[0] = _xcbscreen.white_pixel; - values[1] = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE - | XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_BUTTON_MOTION - | XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW - | XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE - | XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_VISIBILITY_CHANGE; - xcb_create_window(_xcbconnection, _xcbscreen.root_depth, _w, _xcbscreen.root, - 50, 50, 500, 400, 1, - XCB_WINDOW_CLASS_INPUT_OUTPUT, _xcbscreen.root_visual, - mask, &values[0]); - xcb_flush(_xcbconnection); - windowCaption = _caption; - return true; - } - - void createImage() { - Log.i("CRXCBScreen::createImage ", _dx, "x", _dy); - if (_image) - xcb_image_destroy(_image); - _image = null; - xcb_shm_query_version_reply_t * rep_shm; - rep_shm = xcb_shm_query_version_reply (_xcbconnection, - xcb_shm_query_version(_xcbconnection), - null); - if(rep_shm) { - xcb_image_format_t format; - int shmctl_status; - - if (rep_shm.shared_pixmaps && - (rep_shm.major_version > 1 || rep_shm.minor_version > 0)) - format = cast(xcb_image_format_t)rep_shm.pixmap_format; - else - format = XCB_IMAGE_FORMAT_Z_PIXMAP; - - _image = xcb_image_create_native (_xcbconnection, cast(short)_dx, cast(short)_dy, - format, _xcbscreendepth, null, ~0, null); - //format, depth, NULL, ~0, NULL); - //format, depth, NULL, ~0, NULL); - assert(_image); - - shminfo.shmid = shmget (IPC_PRIVATE, - _image.stride*_image.height, - IPC_CREAT | octal!777); - assert(shminfo.shmid != cast(uint)-1); - shminfo.shmaddr = cast(ubyte*)shmat (shminfo.shmid, null, 0); - assert(shminfo.shmaddr); - _image.data = shminfo.shmaddr; - Log.d("Created image depth=", _image.depth, " bpp=", _image.bpp, " stride=", _image.stride ); - - shminfo.shmseg = xcb_generate_id (_xcbconnection); - xcb_shm_attach (_xcbconnection, shminfo.shmseg, - shminfo.shmid, 0); - shmctl_status = shmctl(shminfo.shmid, IPC_RMID, null); - assert(shmctl_status != -1); - free(rep_shm); - } else { - Log.e("Can't get shms"); - } - } - - void draw(ColorDrawBuf buf) { - int i; - i = xcb_image_shm_get(_xcbconnection, _w, - _image, shminfo, - 0, 0, - XCB_ALL_PLANES); - if (!i) { - Log.e("cannot get shm image"); - return; - } - Rect rc; - rc.right = buf.width; - rc.bottom = buf.height; - switch ( _image.bpp ) { - case 32: - { - for (int y = rc.top; y 1 || rep_shm.minor_version > 0)) + format = cast(xcb_image_format_t)rep_shm.pixmap_format; + else + format = XCB_IMAGE_FORMAT_Z_PIXMAP; + + _image = xcb_image_create_native (_xcbconnection, cast(short)_dx, cast(short)_dy, + format, _xcbscreendepth, null, ~0, null); + //format, depth, NULL, ~0, NULL); + //format, depth, NULL, ~0, NULL); + assert(_image); + + shminfo.shmid = shmget (IPC_PRIVATE, + _image.stride*_image.height, + IPC_CREAT | octal!777); + assert(shminfo.shmid != cast(uint)-1); + shminfo.shmaddr = cast(ubyte*)shmat (shminfo.shmid, null, 0); + assert(shminfo.shmaddr); + _image.data = shminfo.shmaddr; + Log.d("Created image depth=", _image.depth, " bpp=", _image.bpp, " stride=", _image.stride ); + + shminfo.shmseg = xcb_generate_id (_xcbconnection); + xcb_shm_attach (_xcbconnection, shminfo.shmseg, + shminfo.shmid, 0); + shmctl_status = shmctl(shminfo.shmid, IPC_RMID, null); + assert(shmctl_status != -1); + free(rep_shm); + } else { + Log.e("Can't get shms"); + } + } + + void draw(ColorDrawBuf buf) { + int i; + i = xcb_image_shm_get(_xcbconnection, _w, + _image, shminfo, + 0, 0, + XCB_ALL_PLANES); + if (!i) { + Log.e("cannot get shm image"); + return; + } + Rect rc; + rc.right = buf.width; + rc.bottom = buf.height; + switch ( _image.bpp ) { + case 32: + { + for (int y = rc.top; y