From a476af50f1ce53e50b9930cdd4e76573691098d3 Mon Sep 17 00:00:00 2001 From: Yourself Date: Fri, 7 Dec 2018 21:59:00 +0100 Subject: [PATCH] yab 1.7.6 - fix Draw Command with transparency error - fix Treebox error, Treebox add wasn't correct --- src/YabInterface.cpp | 84 +++++++++++++++++++++++++++++++++++--------- src/YabView.cpp | 9 ++--- src/config.h | 2 +- src/main.c | 4 +-- 4 files changed, 75 insertions(+), 24 deletions(-) diff --git a/src/YabInterface.cpp b/src/YabInterface.cpp index e06ff7a..fd0bad8 100644 --- a/src/YabInterface.cpp +++ b/src/YabInterface.cpp @@ -1622,7 +1622,9 @@ void YabInterface::DrawText(BPoint coordinates, const char* text, const char* wi if(bview) { b->Lock(); - bview->DrawString(text, coordinates); + bview->SetDrawingMode(B_OP_ALPHA); + bview->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE); + bview->DrawString(text, coordinates); bview->Sync(); b->Unlock(); return; @@ -1640,6 +1642,8 @@ void YabInterface::DrawText(BPoint coordinates, const char* text, const char* wi BBitmap *b = myView->GetBitmap(); BView *bView = myView->GetBitmapView(); b->Lock(); + bView->SetDrawingMode(B_OP_ALPHA); + bView->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE); bView->DrawString(text, coordinates); bView->Sync(); b->Unlock(); @@ -1697,9 +1701,11 @@ void YabInterface::DrawRect(BRect frame, const char* window) if(bview) { b->Lock(); - if(drawStroking) + bview->SetDrawingMode(B_OP_ALPHA); + bview->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE); + if(drawStroking) bview->StrokeRect(frame, yabPattern); - else + else bview->FillRect(frame, yabPattern); bview->Sync(); b->Unlock(); @@ -1718,6 +1724,8 @@ void YabInterface::DrawRect(BRect frame, const char* window) BBitmap *b = myView->GetBitmap(); BView *bView = myView->GetBitmapView(); b->Lock(); + // bView->SetDrawingMode(B_OP_ALPHA); + //bView->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE); if(drawStroking) bView->StrokeRect(frame, yabPattern); else @@ -1812,6 +1820,8 @@ void YabInterface::DrawDot(double x, double y, const char* window) if(bview) { b->Lock(); + bview->SetDrawingMode(B_OP_ALPHA); + bview->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE); bview->StrokeLine(BPoint(x,y), BPoint(x,y), yabPattern); bview->Sync(); b->Unlock(); @@ -1830,6 +1840,8 @@ void YabInterface::DrawDot(double x, double y, const char* window) BBitmap *b = myView->GetBitmap(); BView *bView = myView->GetBitmapView(); b->Lock(); + // bView->SetDrawingMode(B_OP_ALPHA); + // bView->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE); bView->StrokeLine(BPoint(x,y), BPoint(x,y), yabPattern); bView->Sync(); b->Unlock(); @@ -1878,6 +1890,8 @@ void YabInterface::DrawLine(double x1, double y1, double x2, double y2, const ch if(bview) { b->Lock(); + bview->SetDrawingMode(B_OP_ALPHA); + bview->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE); bview->StrokeLine(BPoint(x1,y1), BPoint(x2,y2), yabPattern); bview->Sync(); b->Unlock(); @@ -1896,6 +1910,8 @@ void YabInterface::DrawLine(double x1, double y1, double x2, double y2, const ch BBitmap *b = myView->GetBitmap(); BView *bView = myView->GetBitmapView(); b->Lock(); + //bView->SetDrawingMode(B_OP_ALPHA); + //bView->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE); bView->StrokeLine(BPoint(x1,y1), BPoint(x2,y2), yabPattern); bView->Sync(); b->Unlock(); @@ -1948,6 +1964,10 @@ void YabInterface::DrawCircle(double x, double y, double r, const char* window) if(bview) { b->Lock(); + + bview->SetDrawingMode(B_OP_ALPHA); + bview->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE); + if(drawStroking) bview->StrokeEllipse(BPoint(x,y), r, r, yabPattern); else @@ -1968,7 +1988,11 @@ void YabInterface::DrawCircle(double x, double y, double r, const char* window) w->Lock(); BBitmap *b = myView->GetBitmap(); BView *bView = myView->GetBitmapView(); + b->Lock(); + // bView->SetDrawingMode(B_OP_ALPHA); + // bView->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE); + // bView->SetDrawingMode(B_OP_OVER); if(drawStroking) bView->StrokeEllipse(BPoint(x,y), r, r, yabPattern); else @@ -2021,6 +2045,8 @@ void YabInterface::DrawEllipse(double x, double y, double r1, double r2, const c if(bview) { b->Lock(); + bview->SetDrawingMode(B_OP_ALPHA); + bview->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE); if(drawStroking) bview->StrokeEllipse(BPoint(x,y), r1, r2, yabPattern); else @@ -2042,6 +2068,8 @@ void YabInterface::DrawEllipse(double x, double y, double r1, double r2, const c BBitmap *b = myView->GetBitmap(); BView *bView = myView->GetBitmapView(); b->Lock(); + // bView->SetDrawingMode(B_OP_ALPHA); + // bView->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE); if(drawStroking) bView->StrokeEllipse(BPoint(x,y), r1, r2, yabPattern); else @@ -2101,6 +2129,8 @@ void YabInterface::DrawCurve(double x1, double y1, double x2, double y2, double if(bview) { b->Lock(); + bview->SetDrawingMode(B_OP_ALPHA); + bview->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE); BPoint p[4]; p[0].Set(x1,y1); p[1].Set(x2,y2); @@ -2132,6 +2162,8 @@ void YabInterface::DrawCurve(double x1, double y1, double x2, double y2, double BBitmap *b = myView->GetBitmap(); BView *bView = myView->GetBitmapView(); b->Lock(); + // bView->SetDrawingMode(B_OP_ALPHA); + // bView->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE); BPoint p[4]; p[0].Set(x1,y1); p[1].Set(x2,y2); @@ -2148,7 +2180,7 @@ void YabInterface::DrawCurve(double x1, double y1, double x2, double y2, double bView->FillBezier(p, yabPattern); bView->Sync(); b->Unlock(); - + myView->Draw(BRect(invx1,invy1,invx2,invy2)); w->Unlock(); return; @@ -4485,7 +4517,7 @@ void YabInterface::TreeBox2(const char* id, const char* item) } Error(id, "TREEBOX"); } - +//Correction of Subitem by Stephan Aßmus on BeGeistert 2018 void YabInterface::TreeBox3(const char* id, const char* head, const char* item, int isExpanded) { YabView *myView = NULL; @@ -4507,10 +4539,17 @@ void YabInterface::TreeBox3(const char* id, const char* head, const char* item, BStringItem *stritem = (BStringItem*)myTree->FullListItemAt(i); if(!strcmp(stritem->Text(), head)) { - BStringItem *tmp = new BStringItem(item); - myTree->AddUnder(tmp,stritem); + int32 level = stritem->OutlineLevel() + 1; + BStringItem *tmp = new BStringItem(item, level); + //myTree->AddUnder(tmp,stritem); + int32 fullSubItemCount = myTree->CountItemsUnder(stritem, false); + //printf("found item '%s' at %ld with level %ld, number of sub-items: %ld\n", + // head, i, level - 1, fullSubItemCount); + myTree->AddItem(tmp, i + fullSubItemCount + 1); + if(isExpanded<1) myTree->Collapse(stritem); + w->Unlock(); return; } @@ -4804,7 +4843,7 @@ const char* YabInterface::TreeboxGet(const char* treebox, int pos) pos--; YabView *myView = NULL; BOutlineListView *myTree = NULL; - for(int i=0; iCountItems(); i++) + for(int i=0; iCountItems(); i++) //CountItems() { myView = cast_as((BView*)viewList->ItemAt(i), YabView); if(myView) @@ -4820,6 +4859,7 @@ const char* YabInterface::TreeboxGet(const char* treebox, int pos) if(t) { const char* txt = t->Text(); + //printf(txt); w->Unlock(); return txt; } @@ -8149,19 +8189,24 @@ int YabInterface::ThreadGet(const char* option, const char* appname) return ret; } - +//Correction of Subitem by Stephan Aßmus on BeGeistert 2018 void YabInterface::Bitmap(double w, double h, const char* id) { char *t; BBitmap *b = new BBitmap(BRect(0,0,w-1,h-1), B_RGBA32, true); BView *bview = new BView(BRect(0,0,w-1,h-1), id, B_FOLLOW_NONE, 0); + + //bview->SetDrawingMode(B_OP_ALPHA); + //bview->SetViewColor(255,255,255,255); b->AddChild(bview); - t = (char*)b->Bits(); - for(int i=0; iBits(), 0, b->BitsLength()); +// t = (char*)b->Bits(); +// for(int i=0; iAddItem(b); } @@ -8420,11 +8465,15 @@ void YabInterface::BitmapGet(BRect frame, const char* id, const char* bitmap) { BBitmap *b = (BBitmap*)yabbitmaps->ItemAt(i); BView *bview = b->FindView(bitmap); + + if(bview) { char *oldbits, *newbits; - BBitmap *newbmp = new BBitmap(BRect(0,0, frame.Width(), frame.Height()), B_RGBA32, true); + + BBitmap *newbmp = new BBitmap(BRect(0,0, frame.Width(), frame.Height()), B_RGBA32, true); BView *newbview = new BView(BRect(0,0, frame.Width(), frame.Height()), id, B_FOLLOW_NONE, 0); + newbmp->AddChild(newbview); newbits = (char*)newbmp->Bits(); for(int i=0; iCountItems(); i++) { YabDrawing *e = (YabDrawing*)drawList->ItemAt(i); @@ -129,7 +130,7 @@ void YabView::Draw(BRect updateRect) break; case 6: { if(e->alpha == 255) - SetDrawingMode(B_OP_COPY); + SetDrawingMode(B_OP_OVER); else SetDrawingMode(B_OP_ALPHA); SetHighColor(e->r,e->g,e->b,e->alpha); @@ -137,7 +138,7 @@ void YabView::Draw(BRect updateRect) break; case 7: { if(e->alpha == 255) - SetDrawingMode(B_OP_COPY); + SetDrawingMode(B_OP_OVER); else SetDrawingMode(B_OP_ALPHA); SetLowColor(e->r,e->g,e->b,e->alpha); @@ -168,7 +169,7 @@ void YabView::Draw(BRect updateRect) case 10: { drawing_mode mode = DrawingMode(); if(IsPrinting()) - SetDrawingMode(B_OP_COPY); + SetDrawingMode(B_OP_OVER); else SetDrawingMode(B_OP_ALPHA); DrawBitmap(e->bitmap, BPoint(e->x1, e->y1)); @@ -178,7 +179,7 @@ void YabView::Draw(BRect updateRect) case 11: { drawing_mode mode = DrawingMode(); if(IsPrinting()) - SetDrawingMode(B_OP_COPY); + SetDrawingMode(B_OP_OVER); else SetDrawingMode(B_OP_ALPHA); DrawBitmap(e->bitmap, BRect(e->x1, e->y1, e->x2, e->y2)); diff --git a/src/config.h b/src/config.h index 67e7ece..b914423 100644 --- a/src/config.h +++ b/src/config.h @@ -5,7 +5,7 @@ // #define LIBBSVG #define BUILD_TIME __DATE__ /* Version number of package */ -#define VERSION "1.7.5.6" +#define VERSION "1.7.6.0" /* architecture of build machine */ #define UNIX_ARCHITECTURE "BePC-Haiku" diff --git a/src/main.c b/src/main.c index 5bf0d67..658ec1b 100644 --- a/src/main.c +++ b/src/main.c @@ -26,9 +26,9 @@ can be found at www.yabasic.de /* ------------- defines ---------------- */ #define DONE {current=current->next;break;} /* reduces type-work */ -#define COPYRIGHT " Original yabasic Copyright 1995-2006 by Marc-Oliver Ihm\n\tyab improvements Copyright 2006-2014 by Jan Bungeroth\n\tyab improvements Copyright 2013-2018 by Jim Saxton\n" +#define COPYRIGHT " Original yabasic Copyright 1995-2006 by Marc-Oliver Ihm\n\tyab improvements Copyright 2006-2014 by Jan Bungeroth\n\tyab improvements Copyright 2013-2018 by Jim Saxton\n\tyab improvements Copyright 2018 by BeSly Software Solutions (Thanks to Stephan Aßmus for Correction of Code)\n" #define BANNER \ -"\n yab is yabasic, a BASIC programming language for Haiku.\n This is version " VERSION ",\n built on "\ +"\n yab is yabasic, a BASIC programming language for Haiku.\n This is version " VERSION ", built on "\ ARCHITECTURE " on " BUILD_TIME "\n\n " COPYRIGHT "\n\n" #define BANNER_VERSION \ "yab " VERSION ", built on " ARCHITECTURE "\n" COPYRIGHT