// DrawSlider void PopupSlider::DrawSlider(BRect frame, bool enabled) { rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR); rgb_color lightShadow; rgb_color darkShadow; if (enabled) { lightShadow = tint_color(background, B_DARKEN_2_TINT); darkShadow = tint_color(background, B_DARKEN_4_TINT); } else { lightShadow = tint_color(background, B_DARKEN_1_TINT); darkShadow = tint_color(background, B_DARKEN_2_TINT); } BeginLineArray(4); AddLine(BPoint(frame.left, frame.bottom), BPoint(frame.left, frame.top), lightShadow); AddLine(BPoint(frame.left + 1.0, frame.top), BPoint(frame.right, frame.top), lightShadow); AddLine(BPoint(frame.right, frame.top + 1.0), BPoint(frame.right, frame.bottom), darkShadow); AddLine(BPoint(frame.right - 1.0, frame.bottom), BPoint(frame.left + 1.0, frame.bottom), darkShadow); EndLineArray(); frame.InsetBy(1.0, 1.0); SliderView::DrawSliderButton(this, frame, Value(), FormatString(), enabled); }
void TExpandoMenuBar::DrawBackground(BRect) { if (fVertical) return; BRect bounds(Bounds()); rgb_color menuColor = ViewColor(); rgb_color hilite = tint_color(menuColor, B_DARKEN_1_TINT); rgb_color vlight = tint_color(menuColor, B_LIGHTEN_2_TINT); int32 last = CountItems() - 1; if (last >= 0) bounds.left = ItemAt(last)->Frame().right + 1; else bounds.left = 0; if (be_control_look != NULL) { SetHighColor(tint_color(menuColor, 1.22)); StrokeLine(bounds.LeftTop(), bounds.LeftBottom()); bounds.left++; uint32 borders = BControlLook::B_TOP_BORDER | BControlLook::B_BOTTOM_BORDER | BControlLook::B_RIGHT_BORDER; be_control_look->DrawButtonBackground(this, bounds, bounds, menuColor, 0, borders); } else { SetHighColor(vlight); StrokeLine(bounds.LeftTop(), bounds.RightTop()); StrokeLine(BPoint(bounds.left, bounds.top + 1), bounds.LeftBottom()); SetHighColor(hilite); StrokeLine(BPoint(bounds.left + 1, bounds.bottom), bounds.RightBottom()); } }
void ColorPreview::Draw(BRect update) { rgb_color color; if (is_enabled) color = currentcol; else color = disabledcol; if (is_rect) { if (is_enabled) { rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR); rgb_color shadow = tint_color(background, B_DARKEN_1_TINT); rgb_color darkShadow = tint_color(background, B_DARKEN_3_TINT); rgb_color light = tint_color(background, B_LIGHTEN_MAX_TINT); BRect bounds(Bounds()); BeginLineArray(4); AddLine(BPoint(bounds.left, bounds.bottom), BPoint(bounds.left, bounds.top), shadow); AddLine(BPoint(bounds.left + 1.0, bounds.top), BPoint(bounds.right, bounds.top), shadow); AddLine(BPoint(bounds.right, bounds.top + 1.0), BPoint(bounds.right, bounds.bottom), light); AddLine(BPoint(bounds.right - 1.0, bounds.bottom), BPoint(bounds.left + 1.0, bounds.bottom), light); EndLineArray(); bounds.InsetBy(1.0, 1.0); BeginLineArray(4); AddLine(BPoint(bounds.left, bounds.bottom), BPoint(bounds.left, bounds.top), darkShadow); AddLine(BPoint(bounds.left + 1.0, bounds.top), BPoint(bounds.right, bounds.top), darkShadow); AddLine(BPoint(bounds.right, bounds.top + 1.0), BPoint(bounds.right, bounds.bottom), background); AddLine(BPoint(bounds.right - 1.0, bounds.bottom), BPoint(bounds.left + 1.0, bounds.bottom), background); EndLineArray(); bounds.InsetBy(1.0, 1.0); SetHighColor(color); FillRect(bounds); } else { SetHighColor(color); FillRect(Bounds()); } } else { // fill background SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR)); FillRect(update); SetHighColor(color); FillEllipse(Bounds()); if (is_enabled) StrokeEllipse(Bounds(), B_SOLID_LOW); } }
void AppGroupView::Draw(BRect updateRect) { rgb_color menuColor = ViewColor(); BRect bounds = Bounds(); rgb_color hilite = tint_color(menuColor, B_DARKEN_1_TINT); rgb_color vlight = tint_color(menuColor, B_LIGHTEN_2_TINT); bounds.bottom = bounds.top + kHeaderSize; // Draw the header background SetHighColor(tint_color(menuColor, 1.22)); SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); StrokeLine(bounds.LeftTop(), bounds.LeftBottom()); uint32 borders = BControlLook::B_TOP_BORDER | BControlLook::B_BOTTOM_BORDER | BControlLook::B_RIGHT_BORDER; be_control_look->DrawButtonBackground(this, bounds, bounds, menuColor, 0, borders); // Draw the buttons fCollapseRect.top = (kHeaderSize - kExpandSize) / 2; fCollapseRect.left = kEdgePadding * 2; fCollapseRect.right = fCollapseRect.left + 1.5 * kExpandSize; fCollapseRect.bottom = fCollapseRect.top + kExpandSize; fCloseRect = bounds; fCloseRect.top = (kHeaderSize - kExpandSize) / 2; fCloseRect.right -= kEdgePadding * 2; fCloseRect.left = fCloseRect.right - kCloseSize; fCloseRect.bottom = fCloseRect.top + kCloseSize; uint32 arrowDirection = fCollapsed ? BControlLook::B_DOWN_ARROW : BControlLook::B_UP_ARROW; be_control_look->DrawArrowShape(this, fCollapseRect, fCollapseRect, LowColor(), arrowDirection, 0, B_DARKEN_3_TINT); SetPenSize(kPenSize); // Draw the dismiss widget BRect closeCross = fCloseRect; closeCross.InsetBy(kSmallPadding, kSmallPadding); rgb_color detailCol = ui_color(B_CONTROL_BORDER_COLOR); detailCol = tint_color(detailCol, B_LIGHTEN_2_TINT); StrokeRoundRect(fCloseRect, kSmallPadding, kSmallPadding); StrokeLine(closeCross.LeftTop(), closeCross.RightBottom()); StrokeLine(closeCross.RightTop(), closeCross.LeftBottom()); // Draw the label SetHighColor(ui_color(B_PANEL_TEXT_COLOR)); BString label = fLabel; if (fCollapsed) label << " (" << fInfo.size() << ")"; SetFont(be_bold_font); DrawString(label.String(), BPoint(fCollapseRect.right + 2 * kEdgePadding, fCloseRect.bottom)); }
void AgentDockHeaderString::MouseDown(BPoint where) { SetViewColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_2_TINT)); Parent()->SetViewColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_2_TINT)); Invalidate(); Parent()->Invalidate(); BStringView::MouseDown(where); }
void AppGroupView::Draw(BRect updateRect) { rgb_color menuColor = ViewColor(); BRect bounds = Bounds(); rgb_color hilite = tint_color(menuColor, B_DARKEN_1_TINT); rgb_color vlight = tint_color(menuColor, B_LIGHTEN_2_TINT); bounds.bottom = bounds.top + kHeaderSize; // Draw the header background SetHighColor(tint_color(menuColor, 1.22)); SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); StrokeLine(bounds.LeftTop(), bounds.LeftBottom()); uint32 borders = BControlLook::B_TOP_BORDER | BControlLook::B_BOTTOM_BORDER | BControlLook::B_RIGHT_BORDER; be_control_look->DrawButtonBackground(this, bounds, bounds, menuColor, 0, borders); // Draw the buttons fCollapseRect.top = (kHeaderSize - kExpandSize) / 2; fCollapseRect.left = kEdgePadding * 3; fCollapseRect.right = fCollapseRect.left + 1.5 * kExpandSize; fCollapseRect.bottom = fCollapseRect.top + kExpandSize; fCloseRect = bounds; fCloseRect.top = (kHeaderSize - kCloseSize) / 2; // Take off the 1 to line this up with the close button on the // notification view fCloseRect.right -= kEdgePadding * 3 - 1; fCloseRect.left = fCloseRect.right - kCloseSize; fCloseRect.bottom = fCloseRect.top + kCloseSize; uint32 arrowDirection = fCollapsed ? BControlLook::B_DOWN_ARROW : BControlLook::B_UP_ARROW; be_control_look->DrawArrowShape(this, fCollapseRect, fCollapseRect, LowColor(), arrowDirection, 0, B_DARKEN_3_TINT); SetPenSize(kPenSize); // Draw the dismiss widget _DrawCloseButton(updateRect); // Draw the label SetHighColor(ui_color(B_PANEL_TEXT_COLOR)); BString label = fLabel; if (fCollapsed) label << " (" << fInfo.size() << ")"; SetFont(be_bold_font); font_height fontHeight; GetFontHeight(&fontHeight); float y = (bounds.top + bounds.bottom - ceilf(fontHeight.ascent) - ceilf(fontHeight.descent)) / 2.0 + ceilf(fontHeight.ascent); DrawString(label.String(), BPoint(fCollapseRect.right + 4 * kEdgePadding, y)); }
//****************************************************************************************************** //**** TextEntryAlertBackgroundView //****************************************************************************************************** TextEntryAlertBackgroundView::TextEntryAlertBackgroundView(BRect frame, BRect entry_text_rect) : BView(frame,NULL,B_FOLLOW_ALL_SIDES,B_WILL_DRAW|B_FRAME_EVENTS) { m_entry_text_rect = entry_text_rect; m_cached_bounds = Bounds(); rgb_color background_color = ui_color(B_PANEL_BACKGROUND_COLOR); m_dark_1_color = tint_color(background_color,B_DARKEN_1_TINT); m_dark_2_color = tint_color(background_color,B_DARKEN_4_TINT); SetViewColor(background_color); SetDrawingMode(B_OP_COPY); }
void ControlView::Draw(BRect updateRect) { BRect rect(Bounds()); SetHighColor(tint_color(ViewColor(), B_LIGHTEN_2_TINT)); StrokeLine(rect.LeftTop(), rect.RightTop()); StrokeLine(rect.LeftTop(), rect.LeftBottom()); SetHighColor(tint_color(ViewColor(), B_DARKEN_2_TINT)); StrokeLine(rect.LeftBottom(), rect.RightBottom()); StrokeLine(rect.RightBottom(), rect.RightTop()); }
void ColorField::_DrawBorder() { bool looperLocked = LockLooper(); fBgBitmap[1]->Lock(); rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR); rgb_color shadow = tint_color(background, B_DARKEN_1_TINT); rgb_color darkShadow = tint_color(background, B_DARKEN_3_TINT); rgb_color light = tint_color(background, B_LIGHTEN_MAX_TINT); BRect bounds(fBgView[1]->Bounds()); bounds.OffsetBy(-2.0, -2.0); BRegion region(bounds); fBgView[1]->ConstrainClippingRegion(®ion); bounds = COLOR_FIELD_RECT; bounds.OffsetBy(-2.0, -2.0); fBgView[1]->BeginLineArray(4); fBgView[1]->AddLine(BPoint(bounds.left, bounds.bottom), BPoint(bounds.left, bounds.top), shadow); fBgView[1]->AddLine(BPoint(bounds.left + 1.0, bounds.top), BPoint(bounds.right, bounds.top), shadow); fBgView[1]->AddLine(BPoint(bounds.right, bounds.top + 1.0), BPoint(bounds.right, bounds.bottom), light); fBgView[1]->AddLine(BPoint(bounds.right - 1.0, bounds.bottom), BPoint(bounds.left + 1.0, bounds.bottom), light); fBgView[1]->EndLineArray(); bounds.InsetBy(1.0, 1.0); fBgView[1]->BeginLineArray(4); fBgView[1]->AddLine(BPoint(bounds.left, bounds.bottom), BPoint(bounds.left, bounds.top), darkShadow); fBgView[1]->AddLine(BPoint(bounds.left + 1.0, bounds.top), BPoint(bounds.right, bounds.top), darkShadow); fBgView[1]->AddLine(BPoint(bounds.right, bounds.top + 1.0), BPoint(bounds.right, bounds.bottom), background); fBgView[1]->AddLine(BPoint(bounds.right - 1.0, bounds.bottom), BPoint(bounds.left + 1.0, bounds.bottom), background); fBgView[1]->EndLineArray(); bounds.InsetBy(1.0, 1.0); region.Set(bounds); fBgView[1]->ConstrainClippingRegion(®ion); fBgBitmap[1]->Unlock(); if (looperLocked) UnlockLooper(); }
void SATDecorator::UpdateColors(DesktopSettings& settings) { DefaultDecorator::UpdateColors(settings); // Called during construction, and during any changes fHighlightTabColor = tint_color(fFocusTabColor, B_DARKEN_2_TINT); fHighlightTabColorLight = tint_color(fHighlightTabColor, (B_LIGHTEN_MAX_TINT + B_LIGHTEN_2_TINT) / 2); fHighlightTabColorBevel = tint_color(fHighlightTabColor, B_LIGHTEN_2_TINT); fHighlightTabColorShadow= tint_color(fHighlightTabColor, (B_DARKEN_1_TINT + B_NO_TINT) / 2); }
void DCCConnect::Draw(BRect) { BView* top(Window()->ChildAt(0)); if (this != top) { BeginLineArray(2); AddLine(Bounds().LeftTop(), Bounds().RightTop(), tint_color(ViewColor(), B_DARKEN_2_TINT)); AddLine(Bounds().LeftTop() + BPoint(0.0, 1.0), Bounds().RightTop() + BPoint(0.0, 1.0), tint_color(ViewColor(), B_LIGHTEN_MAX_TINT)); EndLineArray(); } }
// Draw void FontValueView::Draw(BRect updateRect) { BRect b(Bounds()); // focus indication if (IsFocus()) { SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR)); StrokeRect(b); b.InsetBy(1.0, 1.0); BRegion clipping; clipping.Include(b); ConstrainClippingRegion(&clipping); b.left --; } // background FillRect(b, B_SOLID_LOW); rgb_color labelColor = LowColor(); if (fEnabled) labelColor = tint_color(labelColor, B_DARKEN_MAX_TINT); else labelColor = tint_color(labelColor, B_DISABLED_LABEL_TINT); SetHighColor(labelColor); b.InsetBy(2.0, 1.0); float center = floorf(b.top + b.Height() / 2.0); BPoint arrow[3]; arrow[0] = BPoint(b.left, center - 3.0); arrow[1] = BPoint(b.left, center + 3.0); arrow[2] = BPoint(b.left + 3.0, center); FillPolygon(arrow, 3); b.left += 6.0; BFont font; GetFont(&font); font_height fh; font.GetHeight(&fh); BString truncated(fCurrentFont); font.TruncateString(&truncated, B_TRUNCATE_END, b.Width()); DrawString(truncated.String(), BPoint(b.left, floorf(center + fh.ascent / 2.0))); }
void ArpIntControl::DrawControlBackgroundOn(BRect bounds, BView* view) { rgb_color bg, fg; if (IsEnabled() == false) { bg = mViewColor; fg = tint_color(Prefs().GetColor(ARP_INT_FG_C), B_LIGHTEN_1_TINT); if (bgImage != 0) { DrawBitmapBackgroundOn(bounds, view, bgImage); } else { view->SetHighColor(bg); view->FillRect(bounds); } view->SetLowColor(bg); } else if (IsFocus()) { bg = Prefs().GetColor(ARP_INT_BGF_C); fg = Prefs().GetColor(ARP_INT_FGF_C); view->SetHighColor(bg); view->SetLowColor(bg); // Changed this so GratuitousShadeOn() can set the low colour... GratuitousShadeOn(view, bounds, bg, -3); } else { bg = Prefs().GetColor(ARP_INT_BG_C); fg = Prefs().GetColor(ARP_INT_FG_C); view->SetHighColor(bg); view->SetLowColor(bg); // Changed this so GratuitousShadeOn() can set the low colour... GratuitousShadeOn(view, bounds, bg, -3); } BRect r = bounds; if (IsEnabled() == false) { view->SetHighColor( tint_color(bg, B_DARKEN_2_TINT) ); view->StrokeRect(bounds); view->StrokeLine(BPoint(r.left+1, r.top+1), BPoint(r.right-1, r.top+1)); view->StrokeLine(BPoint(r.left+1, r.top+2), BPoint(r.left+1, r.bottom-1)); } else { view->SetHighColor( tint_color( tint_color(bg, B_DARKEN_3_TINT), B_DARKEN_2_TINT ) ); view->StrokeRect(bounds); view->StrokeLine(BPoint(r.left+1, r.bottom-1), BPoint(r.left+1, r.bottom-1)); view->StrokeLine(BPoint(r.right-1, r.top+1), BPoint(r.right-1, r.top+1)); view->SetHighColor(tint_color(bg, B_DARKEN_3_TINT)); view->StrokeLine(BPoint(r.left+2, r.bottom-1), BPoint(r.right-1, r.bottom-1)); view->StrokeLine(BPoint(r.right-1, r.bottom-1), BPoint(r.right-1, r.top+2)); } view->SetHighColor(fg); // view->SetLowColor(bg); }
static void draw_background(BView* view, BRect b, rgb_color bgc, float borderL, float borderR, float bottomIndent) { view->SetHighColor( bgc ); view->FillRect( BRect( b.left + borderL - 1, b.top + 10, b.right - borderR, b.bottom - bottomIndent - 3) ); view->SetLowColor( bgc ); /* Shade the edges - black outline */ view->SetHighColor( 0, 0, 0 ); view->StrokeLine( BPoint(b.left + borderL - 1, b.top + 2), BPoint(b.right - borderR, b.top + 2) ); view->FillRect( BRect( b.left + borderL - 1, b.bottom - bottomIndent + 1, b.right - borderR, b.bottom - bottomIndent + 3) ); /* Shade the edges - lighten the top */ view->SetHighColor( tint_color( view->LowColor(), B_DARKEN_2_TINT ) ); view->StrokeLine( BPoint(b.left + borderL, b.top + 3), BPoint(b.right - borderR, b.top + 3) ); view->SetHighColor( tint_color( view->LowColor(), B_DARKEN_1_TINT ) ); view->StrokeLine( BPoint(b.left + borderL, b.top + 4), BPoint(b.right - borderR, b.top + 4) ); view->SetHighColor( view->LowColor() ); view->StrokeLine( BPoint(b.left + borderL, b.top + 5), BPoint(b.right - borderR, b.top + 5) ); view->SetHighColor( tint_color( view->LowColor(), B_LIGHTEN_1_TINT ) ); view->StrokeLine( BPoint(b.left + borderL, b.top + 6), BPoint(b.right - borderR, b.top + 6) ); view->SetHighColor( tint_color( view->LowColor(), B_LIGHTEN_2_TINT ) ); view->FillRect( BRect( b.left + borderL, b.top + 7, b.right - borderR, b.top + 8) ); view->SetHighColor( tint_color( view->LowColor(), B_LIGHTEN_1_TINT ) ); view->StrokeLine( BPoint(b.left + borderL, b.top + 9), BPoint(b.right - borderR, b.top + 9) ); /* Shade the edges - darken the bottom */ view->SetHighColor( tint_color( view->LowColor(), B_DARKEN_1_TINT ) ); view->StrokeLine( BPoint(b.left + borderL, b.bottom - bottomIndent - 2), BPoint(b.right - borderR, b.bottom - bottomIndent - 2) ); view->SetHighColor( tint_color( view->LowColor(), B_DARKEN_2_TINT ) ); view->StrokeLine( BPoint(b.left + borderL, b.bottom - bottomIndent - 1), BPoint(b.right - borderR, b.bottom - bottomIndent - 1) ); view->SetHighColor( tint_color( view->LowColor(), B_DARKEN_3_TINT ) ); view->StrokeLine( BPoint(b.left + borderL, b.bottom - bottomIndent + 0), BPoint(b.right - borderR, b.bottom - bottomIndent + 0) ); }
void BMenuField::Draw(BRect update) { BRect bounds(Bounds()); bool active = IsFocus() && Window()->IsActive(); DrawLabel(bounds, update); BRect frame(fMenuBar->Frame()); if (be_control_look != NULL) { frame.InsetBy(-kVMargin, -kVMargin); rgb_color base = fMenuBar->LowColor(); rgb_color background = LowColor(); uint32 flags = 0; if (!fMenuBar->IsEnabled()) flags |= BControlLook::B_DISABLED; if (active) flags |= BControlLook::B_FOCUSED; be_control_look->DrawMenuFieldFrame(this, frame, update, base, background, flags); return; } if (frame.InsetByCopy(-kVMargin, -kVMargin).Intersects(update)) { SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_2_TINT)); StrokeLine(BPoint(frame.left - 1.0f, frame.top - 1.0f), BPoint(frame.left - 1.0f, frame.bottom - 1.0f)); StrokeLine(BPoint(frame.left - 1.0f, frame.top - 1.0f), BPoint(frame.right - 1.0f, frame.top - 1.0f)); StrokeLine(BPoint(frame.left + 1.0f, frame.bottom + 1.0f), BPoint(frame.right + 1.0f, frame.bottom + 1.0f)); StrokeLine(BPoint(frame.right + 1.0f, frame.top + 1.0f)); SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_4_TINT)); StrokeLine(BPoint(frame.left - 1.0f, frame.bottom), BPoint(frame.left - 1.0f, frame.bottom)); StrokeLine(BPoint(frame.right, frame.top - 1.0f), BPoint(frame.right, frame.top - 1.0f)); } if (active || fTransition) { SetHighColor(active ? ui_color(B_KEYBOARD_NAVIGATION_COLOR) : ViewColor()); StrokeRect(frame.InsetByCopy(-kVMargin, -kVMargin)); fTransition = false; } }
/*------------------------------------------------------------------------------*\ ( ) - \*------------------------------------------------------------------------------*/ void BmToolbar::Draw( BRect updateRect) { BRect bounds = Bounds(); SetHighColor( tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_1_TINT)); StrokeLine(BPoint(bounds.left, bounds.bottom - 1), BPoint(bounds.left, bounds.top)); StrokeLine(BPoint(bounds.left + 1, bounds.top), BPoint(bounds.right, bounds.top)); SetHighColor( tint_color(HighColor(), B_DARKEN_1_TINT)); StrokeLine(BPoint(bounds.right, bounds.top + 1), BPoint(bounds.right, bounds.bottom - 1)); StrokeLine(BPoint(bounds.left, bounds.bottom), BPoint(bounds.right, bounds.bottom)); }
void TWindowMenuItem::Draw() { if (!fExpanded) { BMenuItem::Draw(); return; } // TODO: Tint this smartly based on the low color, this does // nothing to black. rgb_color menuColor = tint_color(Menu()->LowColor(), 1.07); BRect frame(Frame()); BMenu* menu = Menu(); menu->PushState(); // if not selected or being tracked on, fill with gray TBarView* barview = (static_cast<TBarApp*>(be_app))->BarView(); if ((!IsSelected() && !menu->IsRedrawAfterSticky()) || barview->Dragging() || !IsEnabled()) { rgb_color shadow = tint_color(menuColor, 1.09); menu->SetHighColor(shadow); frame.right = frame.left + kHPad / 2; menu->FillRect(frame); menu->SetHighColor(menuColor); frame.left = frame.right + 1; frame.right = Frame().right; menu->FillRect(frame); } if (IsEnabled() && IsSelected() && !menu->IsRedrawAfterSticky()) { // fill rgb_color backColor = tint_color(menuColor, B_HIGHLIGHT_BACKGROUND_TINT); menu->SetLowColor(backColor); menu->SetHighColor(backColor); menu->FillRect(frame); } else { menu->SetLowColor(menuColor); menu->SetHighColor(menuColor); } DrawContent(); menu->PopState(); }
// _MakeBitmaps void VolumeSlider::_MakeBitmaps() { if (!IsValid()) return; // left side of slider memcpy(fLeftSideBits->Bits(), kVolumeSliderLeftBitmapBits, fLeftSideBits->BitsLength()); // right side of slider memcpy(fRightSideBits->Bits(), kVolumeSliderRightBits, fRightSideBits->BitsLength()); // slider knob int32 length = fKnobBits->BitsLength(); memcpy(fKnobBits->Bits(), kVolumeSliderKnobBits, length); uint8* bits = (uint8*)fKnobBits->Bits(); // black was used in the knob to represent transparency // use screen to get index for the "transarent" color used in the bitmap BScreen screen(B_MAIN_SCREEN_ID); uint8 blackIndex = screen.IndexForColor(kBlack); // replace black index with transparent index for (int32 i = 0; i < length; i++) if (bits[i] == blackIndex) bits[i] = B_TRANSPARENT_MAGIC_CMAP8; if (!IsEnabled()) { // make ghosted versions of the bitmaps dim_bitmap(fLeftSideBits, kBackground, DIM_LEVEL); dim_bitmap(fRightSideBits, kBackground, DIM_LEVEL); dim_bitmap(fKnobBits, kBackground, DIM_LEVEL); } else if (fMuted) { // replace green color (and shadow) in left slider side bits = (uint8*)fLeftSideBits->Bits(); length = fLeftSideBits->BitsLength(); uint8 greenIndex = screen.IndexForColor(kGreen); uint8 greenShadowIndex = screen.IndexForColor(kGreenShadow); rgb_color shadow = tint_color(kBackground, B_DARKEN_3_TINT); rgb_color midShadow = tint_color(kBackground, B_DARKEN_4_TINT); uint8 replaceIndex = screen.IndexForColor(shadow); uint8 replaceShadowIndex = screen.IndexForColor(midShadow); for (int32 i = 0; i < length; i++) { if (bits[i] == greenIndex) bits[i] = replaceIndex; else if (bits[i] == greenShadowIndex) bits[i] = replaceShadowIndex; } } }
// Draw void YBScrollView::Draw(BRect updateRect) { rgb_color keyboardFocus = keyboard_navigation_color(); rgb_color light = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_MAX_TINT); rgb_color shadow = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT); rgb_color darkShadow = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_2_TINT); rgb_color darkerShadow = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT); BRect bounds = Bounds(); if (fWindowActive && Target() && Target()->IsFocus()) { BeginLineArray(4); AddLine(BPoint(bounds.left, bounds.bottom), BPoint(bounds.left, bounds.top), keyboardFocus); AddLine(BPoint(bounds.left + 1.0, bounds.top), BPoint(bounds.right, bounds.top), keyboardFocus); AddLine(BPoint(bounds.right, bounds.top + 1.0), BPoint(bounds.right, bounds.bottom), keyboardFocus); AddLine(BPoint(bounds.right - 1.0, bounds.bottom), BPoint(bounds.left + 1.0, bounds.bottom), keyboardFocus); EndLineArray(); } else { BeginLineArray(4); AddLine(BPoint(bounds.left, bounds.bottom), BPoint(bounds.left, bounds.top), shadow); AddLine(BPoint(bounds.left + 1.0, bounds.top), BPoint(bounds.right, bounds.top), shadow); AddLine(BPoint(bounds.right, bounds.top + 1.0), BPoint(bounds.right, bounds.bottom), light); AddLine(BPoint(bounds.right - 1.0, bounds.bottom), BPoint(bounds.left + 1.0, bounds.bottom), light); EndLineArray(); } bounds.InsetBy(1.0, 1.0); BeginLineArray(4); AddLine(BPoint(bounds.left, bounds.bottom), BPoint(bounds.left, bounds.top), darkerShadow); AddLine(BPoint(bounds.left + 1.0, bounds.top), BPoint(bounds.right, bounds.top), darkShadow); AddLine(BPoint(bounds.right, bounds.top + 1.0), BPoint(bounds.right, bounds.bottom), darkShadow); AddLine(BPoint(bounds.right - 1.0, bounds.bottom), BPoint(bounds.left + 1.0, bounds.bottom), darkShadow); EndLineArray(); }
void TSeparatorItem::Draw() { BMenu* menu = Menu(); if (menu == NULL) return; BRect frame(Frame()); frame.right = frame.left + kSepItemWidth; rgb_color base = ui_color(B_MENU_BACKGROUND_COLOR); menu->PushState(); menu->SetHighColor(tint_color(base, 1.22)); frame.top--; // need to expand the frame for some reason // stroke a darker line on the left edge menu->StrokeLine(frame.LeftTop(), frame.LeftBottom()); frame.left++; // fill in background be_control_look->DrawButtonBackground(menu, frame, frame, base); menu->PopState(); }
// constructor ObjectView::ObjectView(BRect frame, const char* name, uint32 resizeFlags, uint32 flags) : BView(frame, name, resizeFlags, flags), fState(NULL), fObjectType(OBJECT_LINE), fStateList(20), fColor((rgb_color){ 0, 80, 255, 100 }), fDrawingMode(B_OP_ALPHA), fFill(false), fPenSize(10.0), fScrolling(false), fInitiatingDrag(false), fLastMousePos(0.0, 0.0) { SetLowColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_1_TINT)); // BFont font; // GetFont(&font); // font.SetFamilyAndStyle("Bitstream Vera Serif", "Roman"); // font.SetSize(20.0); //// font.SetRotation(6.0); // SetFont(&font, B_FONT_FAMILY_AND_STYLE | B_FONT_ROTATION | B_FONT_SIZE); // State* state = State::StateFor(OBJECT_ROUND_RECT, fColor, B_OP_COPY, // false, 50.0); // state->MouseDown(BPoint(15, 15)); // state->MouseMoved(BPoint(255, 305)); // state->MouseUp(); // // AddObject(state); SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY); }
void DownloadProgressView::AllAttached() { SetViewColor(B_TRANSPARENT_COLOR); SetLowColor(245, 245, 245); SetHighColor(tint_color(LowColor(), B_DARKEN_1_TINT)); }
//------------------------------------------------------------------------------ void BMenuField::DrawLabel(BRect bounds, BRect update) { font_height fh; GetFontHeight(&fh); if (Label()) { SetLowColor(ViewColor()); float y = (float)ceil(fh.ascent + fh.descent + fh.leading) + 2.0f; float x; switch (fAlign) { case B_ALIGN_RIGHT: x = fDivider - StringWidth(Label()) - 3.0f; break; case B_ALIGN_CENTER: x = fDivider - StringWidth(Label()) / 2.0f; break; default: x = 3.0f; break; } SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), IsEnabled() ? B_DARKEN_MAX_TINT : B_DISABLED_LABEL_TINT)); DrawString(Label(), BPoint(x, y)); } }
void CMimeItem::DrawItem(BView *owner, BRect bounds, bool) { BBitmap bm(BRect(0, 0, 15, 15), B_COLOR_8_BIT); if (IsSelected()) { bm.SetBits(fIconSelected, 256, 0, B_COLOR_8_BIT); owner->SetLowColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT)); } else { bm.SetBits(fIcon, 256, 0, B_COLOR_8_BIT); owner->SetLowColor(kWhite); } BRect r(bounds); owner->FillRect(r, B_SOLID_LOW); r.InsetBy(1, 1); font_height fh; be_plain_font->GetHeight(&fh); owner->SetDrawingMode(B_OP_OVER); owner->DrawBitmap(&bm, BPoint(r.left + 2, r.top)); owner->SetDrawingMode(B_OP_COPY); owner->DrawString(fMime.Type(), BPoint(r.left + 22, r.bottom - fh.descent)); owner->SetLowColor(kWhite); } /* CMimeItem::DrawItem */
void AppGroupView::_DrawCloseButton(const BRect& updateRect) { PushState(); BRect closeRect = fCloseRect; rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); float tint = B_DARKEN_2_TINT; if (fCloseClicked) { BRect buttonRect(closeRect.InsetByCopy(-4, -4)); be_control_look->DrawButtonFrame(this, buttonRect, updateRect, base, base, BControlLook::B_ACTIVATED | BControlLook::B_BLEND_FRAME); be_control_look->DrawButtonBackground(this, buttonRect, updateRect, base, BControlLook::B_ACTIVATED); tint *= 1.2; closeRect.OffsetBy(1, 1); } base = tint_color(base, tint); SetHighColor(base); SetPenSize(2); StrokeLine(closeRect.LeftTop(), closeRect.RightBottom()); StrokeLine(closeRect.LeftBottom(), closeRect.RightTop()); PopState(); }
void BComboBox::AttachedToWindow() { Window()->AddFilter(fWinMovedFilter); if (Parent()) { SetViewColor(Parent()->ViewColor()); SetLowColor(ViewColor()); } bool enabled = IsEnabled(); rgb_color mc = HighColor(); rgb_color base; BFont textFont; // mc used to be base in this line if (mc.red == 255 && mc.green == 255 && mc.blue == 255) base = ViewColor(); else base = LowColor(); fText->GetFontAndColor(0, &textFont); mc = enabled ? mc : disable_color(base); fText->SetFontAndColor(&textFont, B_FONT_ALL, &mc); if (!enabled) base = tint_color(base, B_DISABLED_MARK_TINT); else base.red = base.green = base.blue = 255; fText->SetLowColor(base); fText->SetViewColor(base); fText->MakeEditable(enabled); }
void ClipView::AdjustColors() { bool fade; int32 delay; int32 step; float maxlevel; bool pause; ClipdingerSettings* settings = my_app->Settings(); if (settings->Lock()) { fade = settings->GetFade(); step = settings->GetFadeStep(); delay = settings->GetFadeDelay() * kMinuteUnits; maxlevel = 1.0 + 0.025 * settings->GetFadeMaxLevel(); pause = settings->GetFadePause(); settings->Unlock(); } if (pause) return; bigtime_t now(real_time_clock()); for (int32 i = 0; i < CountItems(); i++) { ClipItem* sItem = dynamic_cast<ClipItem *> (ItemAt(i)); if (fade) { bigtime_t minutes = (now - sItem->GetTimeSince()) / 60; float level = B_NO_TINT + (maxlevel / step * ((float)minutes / delay) / kMinuteUnits); sItem->SetColor(tint_color(ui_color(B_LIST_BACKGROUND_COLOR), (level < maxlevel) ? level : maxlevel)); // limit to maxlevel } else sItem->SetColor(ui_color(B_LIST_BACKGROUND_COLOR)); } }
void TabContainerView::Draw(BRect updateRect) { // Stroke separator line at bottom. rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); BRect frame(Bounds()); SetHighColor(tint_color(base, B_DARKEN_2_TINT)); StrokeLine(frame.LeftBottom(), frame.RightBottom()); frame.bottom--; // Draw empty area before first tab. uint32 borders = BControlLook::B_TOP_BORDER | BControlLook::B_BOTTOM_BORDER; BRect leftFrame(frame.left, frame.top, kLeftTabInset, frame.bottom); be_control_look->DrawInactiveTab(this, leftFrame, updateRect, base, 0, borders); // Draw all tabs, keeping track of where they end. BGroupLayout* layout = GroupLayout(); int32 count = layout->CountItems() - 1; for (int32 i = 0; i < count; i++) { TabLayoutItem* item = dynamic_cast<TabLayoutItem*>( layout->ItemAt(i)); if (!item || !item->IsVisible()) continue; item->Parent()->Draw(updateRect); frame.left = item->Frame().right + 1; } // Draw empty area after last tab. be_control_look->DrawInactiveTab(this, frame, updateRect, base, 0, borders); }
/* virtual */ void HeaderListItem::DrawItem(BView *owner, BRect itemRect, bool drawEverthing) { owner->SetDrawingMode(B_OP_COPY); owner->PushState(); if (IsSelected()) { rgb_color lowColor = owner->LowColor(); owner->SetHighColor(tint_color(lowColor, B_DARKEN_2_TINT)); owner->FillRect(itemRect); } owner->PopState(); itemRect.InsetBy(0, 1); owner->StrokeRect(itemRect); itemRect.InsetBy(1, 0); owner->SetDrawingMode(B_OP_OVER); BFont font; owner->GetFont(&font); float baseLine = itemRect.top + (itemRect.IntegerHeight() / 2 + font.Size() / 2); for (int32 c = 0; c < sizeof(fLabels) / sizeof(fLabels[0]); c++) { owner->MovePenTo(itemRect.left + 1 + (fRect.Width() + kDistance) * c, baseLine); owner->DrawString(fLabels[c]); } }
void WidgetFrame::Draw(BRect rect) { rect = Bounds(); rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR); rgb_color shadowColor = {120,120,120}; float lightTint = 1.6; rgb_color high = tint_color(background, lightTint); rgb_color black = {120,120,120}; float x = 15; float y = 15; rect.left++; rect.top++; SetDrawingMode(B_OP_OVER); SetHighColor(shadowColor); SetDrawingMode(B_OP_ALPHA); BGradientRadialFocus frameGradient; frameGradient.AddColor(black, 0); frameGradient.AddColor(high, 255); frameGradient.AddColor(high, 0); FillRoundRect(rect, x, y, frameGradient); }