This commit is contained in:
parent
6a5ad2cd8c
commit
f2f901dc05
8 changed files with 97 additions and 59 deletions
2
configure
vendored
2
configure
vendored
|
|
@ -273,7 +273,7 @@ foreach my $l (@library_targets) {
|
||||||
$s =~ s/$o$/.m/;
|
$s =~ s/$o$/.m/;
|
||||||
}
|
}
|
||||||
elsif ($l =~ /haiku/) {
|
elsif ($l =~ /haiku/) {
|
||||||
$s =~ s/$o$/.cxx/;
|
$s =~ s/$o$/.cc/;
|
||||||
$compiler = "CXX";
|
$compiler = "CXX";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -264,8 +264,8 @@ void vulkan_setup(MwWidget handle) {
|
||||||
swapchainCreateInfo.imageExtent = (VkExtent2D){.width = ow, .height = oh},
|
swapchainCreateInfo.imageExtent = (VkExtent2D){.width = ow, .height = oh},
|
||||||
swapchainCreateInfo.imageArrayLayers = 1,
|
swapchainCreateInfo.imageArrayLayers = 1,
|
||||||
swapchainCreateInfo.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
|
swapchainCreateInfo.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
|
||||||
VK_IMAGE_USAGE_TRANSFER_DST_BIT |
|
VK_IMAGE_USAGE_TRANSFER_DST_BIT |
|
||||||
VK_IMAGE_USAGE_SAMPLED_BIT;
|
VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||||
// th is how we specify no transformation.
|
// th is how we specify no transformation.
|
||||||
swapchainCreateInfo.preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
|
swapchainCreateInfo.preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
|
||||||
swapchainCreateInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
|
swapchainCreateInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
|
||||||
|
|
|
||||||
|
|
@ -16,35 +16,36 @@ extern "C" {
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
class MwApplication : public BApplication {
|
class MwApplication : public BApplication {
|
||||||
private:
|
public:
|
||||||
void ReadyToRun();
|
BWindow* window;
|
||||||
|
BLocker* locker;
|
||||||
|
|
||||||
public:
|
MwApplication(BRect rc, MwLL handle);
|
||||||
BWindow* window;
|
~MwApplication();
|
||||||
int ready;
|
|
||||||
BLocker* locker;
|
|
||||||
|
|
||||||
MwApplication(BRect rc, MwLL handle);
|
void MessageReceived(BMessage* message);
|
||||||
~MwApplication();
|
|
||||||
|
|
||||||
void Pulse();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class MwView : public BView {
|
class MwView : public BView {
|
||||||
public:
|
public:
|
||||||
MwView(MwApplication* app, BRect rc, uint32 resizing, uint32 flags);
|
MwView(BRect rc, uint32 resizing, uint32 flags);
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
typedef void MwApplication;
|
typedef void MwApplication;
|
||||||
typedef void MwView;
|
typedef void MwView;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
enum B_MW_WHAT {
|
||||||
|
B_MW_DESTROY = 0
|
||||||
|
};
|
||||||
|
|
||||||
struct _MwLLHaiku {
|
struct _MwLLHaiku {
|
||||||
struct _MwLLCommon common;
|
struct _MwLLCommon common;
|
||||||
|
|
||||||
MwLL parent;
|
MwLL parent;
|
||||||
MwApplication* app;
|
MwApplication* app;
|
||||||
MwView* view;
|
MwView* view;
|
||||||
|
thread_id app_thread;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MwLLHaikuColor {
|
struct _MwLLHaikuColor {
|
||||||
|
|
@ -55,7 +56,7 @@ struct _MwLLHaikuPixmap {
|
||||||
struct _MwLLCommonPixmap common;
|
struct _MwLLCommonPixmap common;
|
||||||
};
|
};
|
||||||
|
|
||||||
MWDECL int MwLLHaikuCallInit(void);
|
MWDECL int MwLLHaikuCallInit(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@
|
||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
|
#include <OS.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ if (grep(/^cocoa$/, @backends) || param_get("gnustep")) {
|
||||||
|
|
||||||
if (grep(/^haiku$/, @backends)) {
|
if (grep(/^haiku$/, @backends)) {
|
||||||
add_cflags("-DUSE_HAIKU");
|
add_cflags("-DUSE_HAIKU");
|
||||||
new_object("src/backend/haiku.cxx");
|
new_object("src/backend/haiku.cc");
|
||||||
add_libs("-lbe");
|
add_libs("-lbe");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,12 @@
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
MwView::MwView(MwApplication* app, BRect rc, uint32 resizing, uint32 flags) : BView(rc, NULL, resizing, flags) {
|
MwView::MwView(BRect rc, uint32 resizing, uint32 flags) : BView(rc, NULL, resizing, flags) {
|
||||||
app->PostMessage(new BMessage(B_PULSE));
|
|
||||||
|
|
||||||
this->SetViewColor(rand() % 256, 0, 0);
|
|
||||||
printf("?\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void MwApplication::ReadyToRun(){
|
|
||||||
this->ready = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MwApplication::Pulse(){
|
|
||||||
printf("!\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MwApplication::MwApplication(BRect rc, MwLL handle) : BApplication("application/milsko-generic") {
|
MwApplication::MwApplication(BRect rc, MwLL handle) : BApplication("application/milsko-generic") {
|
||||||
BScreen* scr = new BScreen();
|
BScreen* scr = new BScreen();
|
||||||
float left = rc.left;
|
float left = rc.left;
|
||||||
float top = rc.top;
|
float top = rc.top;
|
||||||
|
|
||||||
if(rc.left == MwDEFAULT) left = (scr->Frame().Width() - rc.Width()) / 2;
|
if(rc.left == MwDEFAULT) left = (scr->Frame().Width() - rc.Width()) / 2;
|
||||||
if(rc.top == MwDEFAULT) top = (scr->Frame().Height() - rc.Height()) / 2;
|
if(rc.top == MwDEFAULT) top = (scr->Frame().Height() - rc.Height()) / 2;
|
||||||
|
|
@ -27,23 +15,51 @@ MwApplication::MwApplication(BRect rc, MwLL handle) : BApplication("application/
|
||||||
this->window = new BWindow(rc, "Milsko", B_TITLED_WINDOW, 0);
|
this->window = new BWindow(rc, "Milsko", B_TITLED_WINDOW, 0);
|
||||||
this->window->Show();
|
this->window->Show();
|
||||||
|
|
||||||
handle->haiku.view = new MwView(this, this->window->Bounds(), B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
|
handle->haiku.view = new MwView(this->window->Bounds(), B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
|
||||||
|
|
||||||
this->window->AddChild(handle->haiku.view);
|
this->window->AddChild(handle->haiku.view);
|
||||||
|
|
||||||
this->ready = 0;
|
|
||||||
this->locker = new BLocker();
|
this->locker = new BLocker();
|
||||||
|
|
||||||
delete scr;
|
delete scr;
|
||||||
}
|
}
|
||||||
|
|
||||||
MwApplication::~MwApplication(){
|
MwApplication::~MwApplication() {
|
||||||
delete this->window;
|
delete this->window;
|
||||||
delete this->locker;
|
delete this->locker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MwApplication::MessageReceived(BMessage* message) {
|
||||||
|
switch(message->what) {
|
||||||
|
case B_MW_DESTROY: {
|
||||||
|
this->Quit();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
BLooper::MessageReceived(message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct app_param {
|
||||||
|
BRect rc;
|
||||||
|
MwLL handle;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int32 app_thread(void* data) {
|
||||||
|
struct app_param* r = (struct app_param*)data;
|
||||||
|
|
||||||
|
r->handle->haiku.app = new MwApplication(r->rc, r->handle);
|
||||||
|
r->handle->haiku.app->Run();
|
||||||
|
|
||||||
|
free(r);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
||||||
MwLL r = (MwLL)malloc(sizeof(*r));
|
MwLL r = (MwLL)malloc(sizeof(*r));
|
||||||
BRect rc(BPoint(x, y), BSize(width, height));
|
BRect rc(BPoint(x, y), BSize(width, height));
|
||||||
|
|
||||||
MwLLCreateCommon(r);
|
MwLLCreateCommon(r);
|
||||||
|
|
@ -53,18 +69,26 @@ MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
||||||
|
|
||||||
r->haiku.parent = parent;
|
r->haiku.parent = parent;
|
||||||
|
|
||||||
if(parent == NULL){
|
if(parent == NULL) {
|
||||||
r->haiku.app = new MwApplication(rc, r);
|
struct app_param* p = (struct app_param*)malloc(sizeof(*p));
|
||||||
|
|
||||||
//r->haiku.app->Run();
|
r->haiku.app = NULL;
|
||||||
}else{
|
|
||||||
|
p->rc = rc;
|
||||||
|
p->handle = r;
|
||||||
|
|
||||||
|
r->haiku.app_thread = spawn_thread(app_thread, NULL, B_NORMAL_PRIORITY, p);
|
||||||
|
resume_thread(r->haiku.app_thread);
|
||||||
|
|
||||||
|
while(r->haiku.app == NULL) MwTimeSleep(10);
|
||||||
|
} else {
|
||||||
MwLL top = r;
|
MwLL top = r;
|
||||||
while(top->haiku.parent != NULL){
|
while(top->haiku.parent != NULL) {
|
||||||
top = top->haiku.parent;
|
top = top->haiku.parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
r->haiku.app = NULL;
|
r->haiku.app = NULL;
|
||||||
r->haiku.view = new MwView(top->haiku.app, rc, B_FOLLOW_NONE, B_WILL_DRAW);
|
r->haiku.view = new MwView(rc, B_FOLLOW_NONE, B_WILL_DRAW);
|
||||||
|
|
||||||
parent->haiku.view->AddChild(r->haiku.view);
|
parent->haiku.view->AddChild(r->haiku.view);
|
||||||
}
|
}
|
||||||
|
|
@ -75,14 +99,24 @@ MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
||||||
void MwLLDestroyImpl(MwLL handle) {
|
void MwLLDestroyImpl(MwLL handle) {
|
||||||
MwLLDestroyCommon(handle);
|
MwLLDestroyCommon(handle);
|
||||||
|
|
||||||
|
if(handle->haiku.app != NULL) {
|
||||||
|
status_t exit_value;
|
||||||
|
|
||||||
|
handle->haiku.app->PostMessage(B_MW_DESTROY);
|
||||||
|
wait_for_thread(handle->haiku.app_thread, &exit_value);
|
||||||
|
|
||||||
|
delete handle->haiku.app;
|
||||||
|
}
|
||||||
|
delete handle->haiku.view;
|
||||||
|
|
||||||
free(handle);
|
free(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
|
void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
|
||||||
BPoint* p = (BPoint*)malloc(sizeof(*p) * points_count);
|
BPoint* p = (BPoint*)malloc(sizeof(*p) * points_count);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < points_count; i++){
|
for(i = 0; i < points_count; i++) {
|
||||||
p[i] = BPoint(points[i].x, points[i].y);
|
p[i] = BPoint(points[i].x, points[i].y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,9 +129,7 @@ void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {}
|
||||||
|
|
||||||
void MwLLBeginDrawImpl(MwLL handle) {}
|
void MwLLBeginDrawImpl(MwLL handle) {}
|
||||||
|
|
||||||
void MwLLEndDrawImpl(MwLL handle) {
|
void MwLLEndDrawImpl(MwLL handle) {}
|
||||||
new BMessage(B_PULSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) {
|
MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) {
|
||||||
MwLLColor c = (MwLLColor)malloc(sizeof(*c));
|
MwLLColor c = (MwLLColor)malloc(sizeof(*c));
|
||||||
|
|
@ -119,7 +151,11 @@ void MwLLSetXYImpl(MwLL handle, int x, int y) {}
|
||||||
|
|
||||||
void MwLLSetWHImpl(MwLL handle, int w, int h) {}
|
void MwLLSetWHImpl(MwLL handle, int w, int h) {}
|
||||||
|
|
||||||
void MwLLSetTitleImpl(MwLL handle, const char* title) {}
|
void MwLLSetTitleImpl(MwLL handle, const char* title) {
|
||||||
|
if(handle->haiku.app == NULL) return;
|
||||||
|
|
||||||
|
handle->haiku.app->window->SetTitle(title);
|
||||||
|
}
|
||||||
|
|
||||||
int MwLLPendingImpl(MwLL handle) {
|
int MwLLPendingImpl(MwLL handle) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -128,7 +164,7 @@ int MwLLPendingImpl(MwLL handle) {
|
||||||
void MwLLNextEventImpl(MwLL handle) {}
|
void MwLLNextEventImpl(MwLL handle) {}
|
||||||
|
|
||||||
MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int width, int height) {
|
MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int width, int height) {
|
||||||
MwLLPixmap r = (MwLLPixmap)malloc(sizeof(*r));
|
MwLLPixmap r = (MwLLPixmap)malloc(sizeof(*r));
|
||||||
r->common.raw = (unsigned char*)malloc(4 * width * height);
|
r->common.raw = (unsigned char*)malloc(4 * width * height);
|
||||||
memcpy(r->common.raw, data, 4 * width * height);
|
memcpy(r->common.raw, data, 4 * width * height);
|
||||||
|
|
||||||
|
|
@ -420,8 +420,8 @@ static void redrawIfNeeded(MwWidget handle, int row) {
|
||||||
static int mwListBoxSetImpl(MwWidget handle, int row, int col, const char* text) {
|
static int mwListBoxSetImpl(MwWidget handle, int row, int col, const char* text) {
|
||||||
MwListBox lb = handle->internal;
|
MwListBox lb = handle->internal;
|
||||||
MwListBoxEntry entry;
|
MwListBoxEntry entry;
|
||||||
char* t = text == NULL ? NULL : MwStringDuplicate(text);
|
char* t = text == NULL ? NULL : MwStringDuplicate(text);
|
||||||
int new = 0;
|
int new = 0;
|
||||||
if(row == -1) row = arrlen(lb->list);
|
if(row == -1) row = arrlen(lb->list);
|
||||||
|
|
||||||
entry.name = NULL;
|
entry.name = NULL;
|
||||||
|
|
@ -449,7 +449,7 @@ static int mwListBoxSetImpl(MwWidget handle, int row, int col, const char* text)
|
||||||
static void mwListBoxSetIconImpl(MwWidget handle, int index, MwLLPixmap icon) {
|
static void mwListBoxSetIconImpl(MwWidget handle, int index, MwLLPixmap icon) {
|
||||||
MwListBox lb = handle->internal;
|
MwListBox lb = handle->internal;
|
||||||
MwListBoxEntry entry;
|
MwListBoxEntry entry;
|
||||||
int new = 0;
|
int new = 0;
|
||||||
if(index == -1) index = arrlen(lb->list);
|
if(index == -1) index = arrlen(lb->list);
|
||||||
|
|
||||||
entry.name = NULL;
|
entry.name = NULL;
|
||||||
|
|
|
||||||
|
|
@ -58,9 +58,9 @@ static void draw(MwWidget handle) {
|
||||||
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
||||||
MwLLColor dark = MwLightenColor(handle, base, -64, -64, -64);
|
MwLLColor dark = MwLightenColor(handle, base, -64, -64, -64);
|
||||||
MwScrollBar scr = handle->internal;
|
MwScrollBar scr = handle->internal;
|
||||||
int or ;
|
int or;
|
||||||
int uy, dy, ux, dx;
|
int uy, dy, ux, dx;
|
||||||
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
|
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
|
||||||
|
|
||||||
r.x = 0;
|
r.x = 0;
|
||||||
r.y = 0;
|
r.y = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue