MultiIconValueIndicator::MultiIconValueIndicator(GG::X w, const std::vector<int>& object_ids,
                                                 const std::vector<std::pair<MeterType, MeterType>>& meter_types) :
    GG::Wnd(GG::X0, GG::Y0, w, GG::Y1, GG::INTERACTIVE),
    m_icons(),
    m_meter_types(meter_types),
    m_object_ids(object_ids)
{
    SetName("MultiIconValueIndicator");

    GG::X x(EDGE_PAD);
    for (const std::pair<MeterType, MeterType>& meter_type : m_meter_types) {
        const MeterType PRIMARY_METER_TYPE = meter_type.first;
        // get icon texture.
        std::shared_ptr<GG::Texture> texture = ClientUI::MeterIcon(PRIMARY_METER_TYPE);

        // special case for population meter for an indicator showing only a
        // single popcenter: icon is species icon, rather than generic pop icon
        if (PRIMARY_METER_TYPE == METER_POPULATION && m_object_ids.size() == 1) {
	    if (std::shared_ptr<const PopCenter> pc = GetPopCenter(*m_object_ids.begin()))
		texture = ClientUI::SpeciesIcon(pc->SpeciesName());
        }

        m_icons.push_back(new StatisticIcon(texture, 0.0, 3, false,
                                            GG::X0, GG::Y0, IconWidth(), IconHeight()));
        GG::Pt icon_ul(x, GG::Y(EDGE_PAD));
        GG::Pt icon_lr = icon_ul + GG::Pt(IconWidth(), IconHeight() + ClientUI::Pts()*3/2);
        m_icons.back()->SizeMove(icon_ul, icon_lr);
        m_icons.back()->InstallEventFilter(this);
        AttachChild(m_icons.back());
        x += IconWidth() + IconSpacing();
    }
    if (!m_icons.empty())
        Resize(GG::Pt(Width(), EDGE_PAD + IconHeight() + ClientUI::Pts()*3/2));
    Update();
}
Example #2
0
void
VolumeTab::DrawLabel(BView* owner, BRect frame)
{
	owner->SetDrawingMode(B_OP_OVER);
	if (fIcon != NULL) {
		owner->MovePenTo(frame.left + kSmallHMargin,
			(frame.top + frame.bottom - fIcon->Bounds().Height()) / 2.0);
		owner->DrawBitmap(fIcon);
	}
	font_height fh;
	owner->GetFontHeight(&fh);

	BString label = Label();

	owner->TruncateString(&label, B_TRUNCATE_END,
		frame.Width() - IconWidth() - kSmallHMargin);

	owner->SetHighColor(ui_color(B_CONTROL_TEXT_COLOR));
	owner->DrawString(label,
		BPoint(frame.left + IconWidth() + kSmallHMargin,
			(frame.top + frame.bottom - fh.ascent - fh.descent) / 2.0
				+ fh.ascent));
}
Example #3
0
void
VolumeTab::DrawFocusMark(BView* owner, BRect frame)
{
	frame.left += IconWidth();
	BTab::DrawFocusMark(owner, frame);
}