Пример #1
0
void StatusView::allocBackBitmap(float width, float height) {
	D_OPERATION(("StatusView::allocBackBitmap(%.1f, %.1f)\n", width, height));

	// sanity check
	if(width <= 0.0 || height <= 0.0)
		return;

	if(m_backBitmap) {
		// see if the bitmap needs to be expanded
		BRect b = m_backBitmap->Bounds();
		if(b.Width() >= width && b.Height() >= height)
			return;

		// it does; clean up:
		freeBackBitmap();
	}

	BRect b(0.0, 0.0, width, height);
	m_backBitmap = new BBitmap(b, B_RGB32, true);
	if(!m_backBitmap) {
		D_OPERATION(("StatusView::allocBackBitmap(): failed to allocate\n"));
		return;
	}
	
	m_backView = new BView(b, 0, B_FOLLOW_NONE, B_WILL_DRAW);
	m_backBitmap->AddChild(m_backView);
	m_dirty = true;
}
Пример #2
0
void
CStatusBar::AllocBackBitmap(
	float width,
	float height) {
	D_OPERATION(("CStatusBar::AllocBackBitmap(%.1f, %.1f)\n", width, height));

	// sanity check
	if (width <= 0.0 || height <= 0.0)
		return;

	if (m_backBitmap != NULL)
	{
		// see if the bitmap needs to be expanded
		BRect rect = m_backBitmap->Bounds();
		if ((rect.Width() >= width) && (rect.Height() >= height))
			return;

		// it does; clean up:
		FreeBackBitmap();
	}

	BRect rect(0.0, 0.0, width, height);
	m_backBitmap = new BBitmap(rect, B_RGB32, true);

	m_backView = new BView(rect, 0, B_FOLLOW_NONE, B_WILL_DRAW);
	m_backBitmap->AddChild(m_backView);
	m_dirty = true;
}
Пример #3
0
void
CStatusBar::Update()
{
	D_OPERATION(("CStatusBar::Update()\n"));

	m_dirty = true;
	Invalidate();
}
Пример #4
0
void StatusView::setMessage(
	BString &title,
	BString &details,
	status_t error) {
	D_OPERATION(("StatusView::setMessage(%s)\n", title.String()));

	// get the tip manager instance and reset
	TipManager *manager = TipManager::Instance();
	manager->removeAll(this);

	// append error string
	if (error) {
		title << " (" << strerror(error) << ")";
	}

	// truncate if necessary
	bool truncated = false;
	m_fullText = title;
	if (be_plain_font->StringWidth(title.String()) > Bounds().Width() - 25.0) {
		be_plain_font->TruncateString(&title, B_TRUNCATE_END,
									  Bounds().Width() - 25.0);
		truncated = true;
	}
	BStringView::SetText(title.String());

	if (truncated || details.CountChars() > 0) {
		BString tip = m_fullText;
		if (details.CountChars() > 0) {
			tip << "\n" << details;
		}
		manager->setTip(tip.String(), this);
	}

	if (error) {
		beep();
		// set icon
		if (m_icon) {
			delete m_icon;
			m_icon = 0;
		}
		BRect iconRect(0.0, 0.0, 7.0, 11.0);
		m_icon = new BBitmap(iconRect, B_CMAP8);
		m_icon->SetBits(ERROR_ICON_BITS, 96, 0, B_CMAP8);
	}
	else {
		// set icon
		if (m_icon) {
			delete m_icon;
			m_icon = 0;
		}
		BRect iconRect(0.0, 0.0, 7.0, 11.0);
		m_icon = new BBitmap(iconRect, B_CMAP8);
		m_icon->SetBits(INFO_ICON_BITS, 96, 0, B_CMAP8);
	}
	m_dirty = true;
	startFade();
	Invalidate();
}
Пример #5
0
void
CStatusBar::FreeBackBitmap() {
	D_OPERATION(("CStatusBar::FreeBackBitmap()\n"));

	if (m_backBitmap) {
		delete m_backBitmap;
		m_backBitmap = 0;
		m_backView = 0;
	}
}
Пример #6
0
void
CTrackListView::ShowContextMenu(
	BPoint point)
{
	D_OPERATION(("CTrackListView::ShowContextMenu()"));

	int32 index = IndexOf(point);
	CTrackListItem *item = dynamic_cast<CTrackListItem *>(ItemAt(index));
	if (!item)
		return;

	if (!m_contextMenu)
	{
		m_contextMenu = new BPopUpMenu("TrackList ContextMenu", false,
									   false, B_ITEMS_IN_COLUMN);
		m_contextMenu->SetFont(be_plain_font);

		m_contextMenu->AddItem(new BMenuItem("Edit",
											 new BMessage(CTrackListItem::EDIT_TRACK)));
		m_contextMenu->AddSeparatorItem();
		m_contextMenu->AddItem(new BMenuItem("Record" B_UTF8_ELLIPSIS,
											 new BMessage(CTrackListItem::RECORD_TRACK),
											 'R'));
		m_contextMenu->AddItem(new BMenuItem("Mute",
											 new BMessage(CTrackListItem::MUTE_TRACK),
											 'M'));
		m_contextMenu->AddItem(new BMenuItem("Solo",
											 new BMessage(CTrackListItem::SOLO_TRACK),
											 'S'));
		m_contextMenu->AddSeparatorItem();
		m_contextMenu->AddItem(new BMenuItem("Rename",
											 new BMessage(CTrackListItem::RENAME_TRACK),
											 'E'));
		m_contextMenu->AddItem(new BMenuItem("Delete",
											 new BMessage(CTrackListItem::DELETE_TRACK),
											 'T'));

		m_contextMenu->SetTargetForItems(this);
	}

	m_contextMenu->FindItem(CTrackListItem::RECORD_TRACK)->SetEnabled(false);

	if (item->GetTrack()->Muted())
		m_contextMenu->FindItem(CTrackListItem::MUTE_TRACK)->SetMarked(true);
	else
		m_contextMenu->FindItem(CTrackListItem::MUTE_TRACK)->SetMarked(false);

	m_contextMenu->FindItem(CTrackListItem::SOLO_TRACK)->SetEnabled(false);

	ConvertToScreen(&point);
	point -= BPoint(1.0, 1.0);
	m_contextMenu->Go(point, true, true, true);
}
Пример #7
0
void StatusView::startFade() {
	D_OPERATION(("StatusView::startFade()\n"));
	
	m_opacity = 1.0;
	m_decayDelay = TEXT_DECAY_DELAY;
	if(!m_clock) {
		m_clock = new BMessageRunner(
			BMessenger(this),
			new BMessage('Tick'),
			TICK_PERIOD);
	}
}
Пример #8
0
void
CTool::SetValue(
	int32 value)
{
	D_OPERATION(("CTool::SetValue(%ld)\n", value));

	if (value != m_value)
	{
		if (Mode() == TRIGGER_MODE)
		{
			// trigger tools don't change their value
			return;
		}

		if ((Mode() == RADIO_MODE) && (Flags() & FORCE_SELECTION)
		 && (Value() == B_CONTROL_ON))
		{
			// radio mode with the force-selection flag set does not
			// allow 'turning off' the tool directly
			return;
		}

		m_value = value;

		if ((Mode() == RADIO_MODE) && (Value() == B_CONTROL_ON))
		{
			// turn off other tools in radio group
			CTool *tool;
			tool = PreviousTool();
			while (tool)
			{
				if (tool->m_value == B_CONTROL_ON)
				{
					tool->m_value = B_CONTROL_OFF;
					tool->ValueChanged();
				}
				tool = tool->PreviousTool();
			}
			tool = NextTool();
			while (tool)
			{
				if (tool->m_value == B_CONTROL_ON)
				{
					tool->m_value = B_CONTROL_OFF;
					tool->ValueChanged();
				}
				tool = tool->NextTool();
			}
		}
		ValueChanged();
	}	
}
Пример #9
0
void
CTrackListView::SetDocument(
	CMeVDoc *doc)
{
	D_OPERATION(("CTrackListView::SetDocument()\n"));

	if (doc != m_doc)
	{	
		if (m_doc != NULL)
			m_doc->RemoveObserver(this);

		m_doc = doc;
		if (m_doc != NULL)
			m_doc->AddObserver(this);

		BuildTrackList();
	}
}
Пример #10
0
void StatusView::setErrorMessage(
	BString text,
	bool error) {
	D_OPERATION(("StatusView::setErrorMessage(%s)\n",
				 text.String()));

	// get the tip manager instance and reset
	TipManager *manager = TipManager::Instance();
	manager->removeAll(this);

	// truncate if necessary
	m_fullText = text;
	if (be_plain_font->StringWidth(text.String()) > Bounds().Width() - 25.0) {
		be_plain_font->TruncateString(&text, B_TRUNCATE_END,
									  Bounds().Width() - 25.0);
		manager->setTip(m_fullText.String(), this);
	}
	BStringView::SetText(text.String());

	if (error) {
		beep();
		// set icon
		if (m_icon) {
			delete m_icon;
			m_icon = 0;
		}
		BRect iconRect(0.0, 0.0, 7.0, 11.0);
		m_icon = new BBitmap(iconRect, B_CMAP8);
		m_icon->SetBits(ERROR_ICON_BITS, 96, 0, B_CMAP8);
	}
	else {
		// set icon
		if (m_icon) {
			delete m_icon;
			m_icon = 0;
		}
		BRect iconRect(0.0, 0.0, 7.0, 11.0);
		m_icon = new BBitmap(iconRect, B_CMAP8);
		m_icon->SetBits(INFO_ICON_BITS, 96, 0, B_CMAP8);
	}
	m_dirty = true;
	startFade();
	Invalidate();
}
Пример #11
0
void
CMenuTool::SetBitmap(
	BBitmap *bitmap)
{
	D_OPERATION(("CMenuTool::SetBitmap()\n"));

	if (bitmap && (bitmap != m_bitmap))
	{
		delete m_bitmap;
		delete m_disabledBitmap;

		m_bitmap = bitmap;

		// calculate disabled bitmap
		BScreen screen;
		uint8 light = screen.IndexForColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
													  B_LIGHTEN_1_TINT));
		uint8 dark  = screen.IndexForColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
													  B_DARKEN_1_TINT));
		m_disabledBitmap = new BBitmap(bitmap);
		uint8 *start = (uint8 *)m_disabledBitmap->Bits();
		uint8 *end = start + m_disabledBitmap->BitsLength();
		for (uint8 *pos = start; pos < end; pos++)
		{
			rgb_color color = screen.ColorForIndex(*pos);
			if ((color.alpha < 255) || (color.red + color.green + color.blue >= 765))
				continue;
			if (color.red + color.green + color.blue > 384)
				*pos = light;
			else
				*pos = dark;
		}
	}

	if (ToolBar())
		ToolBar()->Invalidate();
}
Пример #12
0
void 
StatusView::drawInto(BView *v, BRect updateRect)
{
	BRect r(Bounds());
	D_OPERATION(("StatusView::drawInto(%.1f, %.1f)\n", r.Width(), r.Height()));

	// draw border (minus right edge, which the scrollbar draws)
	v->SetDrawingMode(B_OP_COPY);
	v->BeginLineArray(8);
	v->AddLine(r.LeftTop(), r.RightTop(), M_MED_GRAY_COLOR);
	BPoint rtop = r.RightTop();
	rtop.y++;
	v->AddLine(rtop, r.RightBottom(), tint_color(M_MED_GRAY_COLOR, B_LIGHTEN_1_TINT));
	v->AddLine(r.RightBottom(), r.LeftBottom(), M_MED_GRAY_COLOR);
	v->AddLine(r.LeftBottom(), r.LeftTop(), M_MED_GRAY_COLOR);
	r.InsetBy(1.0, 1.0);
	v->AddLine(r.LeftTop(), r.RightTop(), M_LIGHT_GRAY_COLOR);
	rtop.y++;
	rtop.x--;
	v->AddLine(rtop, r.RightBottom(), M_GRAY_COLOR);
	v->AddLine(r.RightBottom(), r.LeftBottom(), tint_color(M_MED_GRAY_COLOR, B_LIGHTEN_1_TINT));
	v->AddLine(r.LeftBottom(), r.LeftTop(), M_LIGHT_GRAY_COLOR);
	v->EndLineArray();
	r.InsetBy(1.0, 1.0);
	v->SetLowColor(M_GRAY_COLOR);
	v->FillRect(r, B_SOLID_LOW);

	r.InsetBy(2.0, 0.0);
	v->SetDrawingMode(B_OP_ALPHA);
	v->SetHighColor(0, 0, 0, uchar(255 * m_opacity));

	// draw icon
	if (m_icon) {
		v->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
		BPoint p = r.LeftTop();
		p.y--;
		v->DrawBitmap(m_icon, p);
	}

	// draw text
	r.left += 10.0;
	font_height fh;
	be_plain_font->GetHeight(&fh);
	r.bottom = Bounds().bottom - fh.descent
		- (Bounds().Height() - fh.ascent - fh.descent) / 2;
	v->MovePenTo(r.LeftBottom());
	v->DrawString(Text());

	// draw resize dragger
	v->SetDrawingMode(B_OP_OVER);
	r = Bounds();
	r.right -= 2.0;
	r.left = r.right - 2.0;
	r.InsetBy(0.0, 3.0);
	r.top += 1.0;
	for (int32 i = 0; i < r.IntegerHeight(); i += 3) {
		BPoint p = r.LeftTop() + BPoint(0.0, i);
		v->SetHighColor(M_MED_GRAY_COLOR);
		v->StrokeLine(p, p, B_SOLID_HIGH);
		p += BPoint(1.0, 1.0);
		v->SetHighColor(M_WHITE_COLOR);
		v->StrokeLine(p, p, B_SOLID_HIGH);
	}
}