reorganize jtk into src/jtk

This commit is contained in:
Josh Holtrop 2019-12-30 22:21:10 -05:00
parent e4e280da4f
commit daf14dc4fc
6 changed files with 79 additions and 76 deletions

View File

@ -1,74 +0,0 @@
private extern(C) bool jtk_init();
private extern(C) void * jtk_window_create();
private extern(C) void jtk_window_swap_buffers(void * window);
private extern(C) void jtk_window_close(void * window);
private extern(C) void jtk_window_set_title(void * window, const char * title);
private extern(C) void jtk_window_set_icon(void * window, const ubyte * data,
size_t width, size_t height);
struct Jtk
{
struct Event
{
enum Type : ubyte
{
WINDOW_CLOSE,
WINDOW_EXPOSE,
KEY_PRESS,
KEY_RELEASE,
BUTTON_PRESS,
BUTTON_RELEASE,
TIMER,
WINDOW_RESIZE,
};
struct KeyEvent
{
bool repeat;
uint key;
uint x_keycode;
};
struct ButtonEvent
{
uint mods;
ubyte button;
};
struct TimerEvent
{
uint timer_id;
void * user1;
void * user2;
};
struct WindowResizeEvent
{
uint width;
uint height;
};
Type type;
union
{
KeyEvent key;
ButtonEvent button;
TimerEvent timer;
WindowResizeEvent resize;
};
}
class Window
{
}
static bool init()
{
if (!jtk_init())
{
return false;
}
return true;
}
}

51
src/jtk/event.d Normal file
View File

@ -0,0 +1,51 @@
module jtk.event;
struct Event
{
enum Type : ubyte
{
WINDOW_CLOSE,
WINDOW_EXPOSE,
KEY_PRESS,
KEY_RELEASE,
BUTTON_PRESS,
BUTTON_RELEASE,
TIMER,
WINDOW_RESIZE,
};
struct KeyEvent
{
bool repeat;
uint key;
uint x_keycode;
};
struct ButtonEvent
{
uint mods;
ubyte button;
};
struct TimerEvent
{
uint timer_id;
void * user1;
void * user2;
};
struct WindowResizeEvent
{
uint width;
uint height;
};
Type type;
union
{
KeyEvent key;
ButtonEvent button;
TimerEvent timer;
WindowResizeEvent resize;
};
}

13
src/jtk/init.d Normal file
View File

@ -0,0 +1,13 @@
module jtk.init;
private extern(C) bool jtk_init();
bool init()
{
if (!jtk_init())
{
return false;
}
return true;
}

12
src/jtk/window.d Normal file
View File

@ -0,0 +1,12 @@
module jtk.window;
private extern(C) void * jtk_window_create();
private extern(C) void jtk_window_swap_buffers(void * window);
private extern(C) void jtk_window_close(void * window);
private extern(C) void jtk_window_set_title(void * window, const char * title);
private extern(C) void jtk_window_set_icon(void * window, const ubyte * data,
size_t width, size_t height);
class Window
{
}

View File

@ -1,7 +1,8 @@
import jes.gui.jtk;
static import jtk.init;
import std.stdio;
int main(string[] args)
{
Jtk.init();
jtk.init.init();
return 0;
}