void Blitter_32bppSimple::DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) { uint32 *udst = (uint32 *)dst; if (pal == PALETTE_TO_TRANSPARENT) { do { for (int i = 0; i != width; i++) { *udst = MakeTransparent(*udst, 154); udst++; } udst = udst - width + _screen.pitch; } while (--height); return; } if (pal == PALETTE_TO_STRUCT_GREY) { do { for (int i = 0; i != width; i++) { *udst = MakeGrey(*udst); udst++; } udst = udst - width + _screen.pitch; } while (--height); return; } DEBUG(misc, 0, "32bpp blitter doesn't know how to draw this colour table ('%d')", pal); }
void Blitter_32bppAnim::DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) { if (_screen_disable_anim) { /* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawColourMappingRect() */ Blitter_32bppOptimized::DrawColourMappingRect(dst, width, height, pal); return; } Colour *udst = (Colour *)dst; uint16 *anim; anim = this->anim_buf + ((uint32 *)dst - (uint32 *)_screen.dst_ptr); if (pal == PALETTE_TO_TRANSPARENT) { do { for (int i = 0; i != width; i++) { *udst = MakeTransparent(*udst, 154); *anim = 0; udst++; anim++; } udst = udst - width + _screen.pitch; anim = anim - width + this->anim_buf_width; } while (--height); return; } if (pal == PALETTE_NEWSPAPER) { do { for (int i = 0; i != width; i++) { *udst = MakeGrey(*udst); *anim = 0; udst++; anim++; } udst = udst - width + _screen.pitch; anim = anim - width + this->anim_buf_width; } while (--height); return; } DEBUG(misc, 0, "32bpp blitter doesn't know how to draw this colour table ('%d')", pal); }
void BamKeysKeyView::DrawTo(BView *view, BRect bounds, int32 key, bool pressed, const char* keyLabel = NULL, uint8 alpha = 255) { drawing_mode origMode = view->DrawingMode(); view->SetDrawingMode(B_OP_ALPHA); rgb_color origHigh = view->HighColor(); BRect outterBounds = bounds; BRect r = outterBounds; r.InsetBy(3, 3); rgb_color pen; MakeGrey(&pen, 0, alpha); view->SetHighColor(pen); view->StrokeRect(r, B_SOLID_HIGH); r.InsetBy(1, 1); if (! pressed) { view->BeginLineArray(19); MakeGrey(&pen, 64, alpha); view->SetHighColor(pen); view->AddLine(r.LeftBottom(), r.RightBottom(), pen); view->AddLine(r.RightBottom(), r.RightTop(), pen); view->AddLine(r.RightBottom(), r.RightBottom() - BPoint(1, 1), pen); // 200 level greys r.InsetBy(0.5, 0.5); r.OffsetBy(-0.5, -0.5); MakeGrey(&pen, 200, alpha); BPoint start = r.LeftTop(); BPoint end = r.LeftBottom(); view->AddLine(start, end, pen); end = start; end.x += 2; view->AddLine(start, end, pen); start = end; start.x += 1; start.y = r.LeftBottom().y - 1; end = r.RightBottom(); end.x -= 2; end.y -= 1; view->AddLine(start, end, pen); start = end; start.x += 1; start.y -= 1; end = r.RightTop(); end.y += 2; end.x -= 1; view->AddLine(start, end, pen); // 160 level greys (3 points) MakeGrey(&pen, 160, alpha); start = r.LeftBottom(); start.x += 1; end = start; view->AddLine(start, end, pen); start = r.RightBottom(); start.x -= 1; start.y -= 1; end = start; view->AddLine(start, end, pen); start = r.RightTop(); start.y += 1; end = start; view->AddLine(start, end, pen); // 96 level greys MakeGrey(&pen, 96, alpha); start = r.LeftBottom(); start.x += 2; end = r.RightBottom(); end.x -= 1; view->AddLine(start, end, pen); start = r.RightBottom(); start.y -= 1; end = r.RightTop(); end.y += 2; view->AddLine(start, end, pen); // 184 level greys MakeGrey(&pen, 184, alpha); start = r.LeftTop(); start.x += 3; end = start; end.x += 2; view->AddLine(start, end, pen); // 168 level greys MakeGrey(&pen, 168, alpha); start = end; start.x += 1; end = start; end.x += 2; view->AddLine(start, end, pen); // 152 MakeGrey(&pen, 152, alpha); start = end; start.x += 1; end = r.RightTop(); view->AddLine(start, end, pen); start = end; end.y += 1; view->AddLine(start, end, pen); // 255 (white) MakeGrey(&pen, 255, alpha); start = r.LeftTop(); start.x += 1; start.y += 1; end.x -= 1; view->AddLine(start, end, pen); end = r.LeftBottom(); end.y -= 1; end.x += 1; view->AddLine(start, end, pen); start = end; end.x += 1; view->AddLine(start, end, pen); view->EndLineArray(); // Key fillings // 152 MakeGrey(&pen, 152, alpha); view->SetHighColor(pen); BRect fillZone(r); fillZone.InsetBy(2, 2); end = r.LeftBottom(); end.y -= 2; end.x += 7; fillZone.SetRightBottom(end); view->FillRect(fillZone); MakeGrey(&pen, 168, alpha); view->SetHighColor(pen); fillZone.OffsetBy(fillZone.Width(), 0); view->FillRect(fillZone); MakeGrey(&pen, 184, alpha); view->SetHighColor(pen); fillZone.OffsetBy(fillZone.Width(), 0); end = r.RightBottom(); end.x -= 2; end.y -= 2; fillZone.SetRightBottom(end); view->FillRect(fillZone); MakeGrey(&pen, 0, alpha); view->SetHighColor(pen); } else { // PRESSED MakeGrey(&pen, 48, alpha); view->BeginLineArray(8); BPoint start = r.LeftBottom(); BPoint end = r.LeftTop(); view->AddLine(start, end, pen); start = end; end = r.RightTop(); view->AddLine(start, end, pen); MakeGrey(&pen, 136, alpha); start = end + BPoint(0, 1); end = r.RightBottom(); view->AddLine(start, end, pen); start = end; end = r.LeftBottom() + BPoint(1, 0); view->AddLine(start, end, pen); r.InsetBy(1, 1); MakeGrey(&pen, 72, alpha); start = r.LeftBottom(); end = r.LeftTop(); view->AddLine(start, end, pen); start = end; end = r.RightTop(); view->AddLine(start, end, pen); MakeGrey(&pen, 152, alpha); start = end + BPoint(0, 1); end = r.RightBottom(); view->AddLine(start, end, pen); start = end; end = r.LeftBottom() + BPoint(1, 0); view->AddLine(start, end, pen); view->EndLineArray(); // Fill r.InsetBy(1, 1); MakeGrey(&pen, 112, alpha); view->FillRect(r); MakeGrey(&pen, 216, alpha); view->SetHighColor(pen); } if (keyLabel != NULL) { font_height fnt; be_fixed_font->GetHeight(&fnt); float stringHeight = fnt.ascent - fnt.descent; float stringWidth = view->StringWidth(keyLabel); r = outterBounds; BPoint strLoc((r.Width() / 2) - (stringWidth / 2), r.Height() - ((r.Height() / 2) - (stringHeight / 2))); strLoc += r.LeftTop(); view->DrawString(keyLabel, strLoc); } view->SetDrawingMode(origMode); view->SetHighColor(origHigh); }