Ejemplo n.º 1
0
void MediaRoutingView::cleanUp()
{
	D_METHOD(("MediaRoutingView::cleanUp()\n"));

	sortItems(DiagramItem::M_BOX, compareID);

	// move all the panels offscreen
	for (uint32 i = 0; i < countItems(DiagramItem::M_BOX); i++)
	{
		itemAt(i, DiagramItem::M_BOX)->moveTo(BPoint(-200.0, -200.0));
	}

	// move all panels to their 'ideal' position
	for (uint32 i = 0; i < countItems(DiagramItem::M_BOX); i++)
	{
		MediaNodePanel *panel;
		panel = dynamic_cast<MediaNodePanel *>(itemAt(i, DiagramItem::M_BOX));
		BPoint p = findFreePositionFor(panel);
		panel->moveTo(p);
	}

	sortItems(DiagramItem::M_BOX, compareSelectionTime);
	Invalidate();
	updateDataRect();
}
Ejemplo n.º 2
0
static int countCtfSpawnpoints(void) {
    int mincount,tmp;
    
    mincount=100;
    
    tmp = countItems("team_CTF_redplayer",qtrue);
    if(!tmp){
	tmp = countFfaSpawnpoints(); //tmp==0 -> Fallback to FFA spawnpoints!
    }
    if(tmp<mincount)
	    mincount=tmp;
    
    tmp = countItems("team_CTF_blueplayer",qtrue);
    if(!tmp){
	tmp = countFfaSpawnpoints(); //tmp==0 -> Fallback to FFA spawnpoints!
    }
    if(tmp<mincount)
	    mincount=tmp;
    
    tmp = countItems("team_CTF_redspawn",qtrue);
    if(!tmp){
	tmp = countFfaSpawnpoints(); //tmp==0 -> Fallback to FFA spawnpoints!
    }
    if(tmp<mincount)
	    mincount=tmp;
    
    tmp = countItems("team_CTF_bluespawn",qtrue);
    if(!tmp){
	tmp = countFfaSpawnpoints(); //tmp==0 -> Fallback to FFA spawnpoints!
    }
    if(tmp<mincount)
	    mincount=tmp;
    
    return mincount;
}
Ejemplo n.º 3
0
void
DiagramBox::moveBy(
	float x,
	float y,
	BRegion *wireRegion) {
	D_METHOD(("DiagramBox::moveBy()\n"));

	if (view()) {
		view()->PushState();
		for (uint32 i = 0; i < countItems(); i++) {
			DiagramEndPoint *endPoint = dynamic_cast<DiagramEndPoint *>(itemAt(i));
			if (endPoint) {
				endPoint->moveBy(x, y, wireRegion);
			}
		}
		if (wireRegion) {
			wireRegion->Include(m_frame);
			m_frame.OffsetBy(x, y);
			wireRegion->Include(m_frame);
		}
		else {
			m_frame.OffsetBy(x, y);
		}
		view()->PopState();
	}
}
Ejemplo n.º 4
0
/*
 * Add an item after another item in a list.
 */
TEST_F(ListTest, addAfterTest)
{
        int noItems=0;
        list.addTail(item);
        item2->addAfter(list.first());
        noItems = countItems(&list);

        EXPECT_EQ(list.next(list.first()), item2);
}
void Tileset::setTexture(TilesetLoadData tileset_data)
{
	sf::Image image;
	if (!image.loadFromFile(tileset_data.path))
		throw FileLoadException(tileset_data.path);
	name = tileset_data.path;
	image.createMaskFromColor(MASK_COLOR);
	texture.loadFromImage(image);
	items_per_row = image.getSize().x / tileset_data.size.x;
	tile_size = tileset_data.size;
	countItems();
}
Ejemplo n.º 6
0
static int countDdSpawnpoints(void) {
    int mincount,tmp;
    mincount = 100;
    
    tmp = countItems("info_player_dd_red",qtrue);
    if(!tmp){
	tmp = countFfaSpawnpoints(); //tmp==0 -> Fallback to FFA spawnpoints!
    }
    if(tmp<mincount)
	    mincount=tmp;
    
    tmp = countItems("info_player_dd_blue",qtrue);
    if(!tmp){
	tmp = countFfaSpawnpoints(); //tmp==0 -> Fallback to FFA spawnpoints!
    }
    if(tmp<mincount)
	    mincount=tmp;
    
    return mincount;
    
}
Ejemplo n.º 7
0
XmStringTable TextStringsToXmStrings (char **text_strings)
{
XmStringTable xmstrings = NULL;
int count, lcv;

if (text_strings) {
    count = countItems (text_strings);
    xmstrings = (XmStringTable) calloc (sizeof(XmString), (count));
    for (lcv = 0; lcv < count; lcv++)
        xmstrings[lcv] = (XmString) XmStringCreateSimple (text_strings[lcv]);
}
return ((XmStringTable)xmstrings);
}
Ejemplo n.º 8
0
void DiagramBox::draw(
	BRect updateRect)
{
	D_DRAW(("DiagramBox::draw()\n"));
	if (view()) {
		view()->PushState();
		if (m_flags & M_DRAW_UNDER_ENDPOINTS) {
			BRegion region, clipping;
			region.Include(frame());
			if (group()->getClippingAbove(this, &clipping))
				region.Exclude(&clipping);
			view()->ConstrainClippingRegion(&region);
			drawBox();
			for (uint32 i = 0; i < countItems(); i++) {
				DiagramItem *item = itemAt(i);
				if (region.Intersects(item->frame())) {
					item->draw(item->frame());
				}
			}
		}
		else {
			BRegion region, clipping;
			region.Include(frame());
			if (view()->getClippingAbove(this, &clipping))
				region.Exclude(&clipping);
			for (uint32 i = 0; i < countItems(); i++) {
				DiagramItem *item = itemAt(i);
				BRect r;
				if (region.Intersects(r = item->frame())) {
					item->draw(r);
					region.Exclude(r);
				}
			}
			view()->ConstrainClippingRegion(&region);
			drawBox();
		}
		view()->PopState();
	}
}
Ejemplo n.º 9
0
void
DiagramBox::_setOwner(
	DiagramView *owner) {
	D_METHOD(("DiagramBox::_setOwner()\n"));

	m_view = owner;
	for (uint32 i = 0; i < countItems(DiagramItem::M_ENDPOINT); i++) {
		DiagramItem *item = itemAt(i);
		item->_setOwner(m_view);
		if (m_view) {
			item->attachedToDiagram();
		}
	}
}
Ejemplo n.º 10
0
// +++++ export state info for currently inactive system nodes +++++
status_t MediaRoutingView::exportState(
	BMessage*									archive) const {

	// store layout mode
	archive->AddInt32("layout", m_layout);

	// store background settings
	if(m_backgroundBitmapEntry.InitCheck() == B_OK) {
		BPath path;
		m_backgroundBitmapEntry.GetPath(&path);
		archive->AddString("bgBitmap", path.Path());
	} else {
		rgb_color c = backgroundColor();
		archive->AddInt8("bgRed", c.red);
		archive->AddInt8("bgGreen", c.green);
		archive->AddInt8("bgBlue", c.blue);
	}

	// store panel positions w/ node names & signatures
	for(uint32 n = 0; n < countItems(DiagramItem::M_BOX); ++n) {
		MediaNodePanel* panel = dynamic_cast<MediaNodePanel*>(
			itemAt(n, DiagramItem::M_BOX));
		if(!panel)
			continue;
		
		if(panel->ref->isInternal())
			// skip internal nodes
			continue;

		BMessage m;
		panel->exportState(&m);
		archive->AddString("nodeName", panel->ref->name());
		archive->AddInt32("nodeKind", panel->ref->kind());
		archive->AddMessage("panel", &m);		
	}
	
	// copy inactive node state info
	for(int32 n = 0; n < m_inactiveNodeState.CountItems(); ++n) {
		_inactive_node_state_entry* e = reinterpret_cast<_inactive_node_state_entry*>(
			m_inactiveNodeState.ItemAt(n));

		archive->AddString("nodeName", e->name.String());
		archive->AddInt32("nodeKind", e->kind);
		archive->AddMessage("panel", &e->state);
	}

	return B_OK;	
}
Ejemplo n.º 11
0
status_t MediaRoutingView::_findWireFor(
	uint32 connectionID,
	MediaWire **outWire) const
{
	D_METHOD(("MediaRoutingView::_findWireFor()\n"));

	for (uint32 i = 0; i < countItems(DiagramItem::M_WIRE); i++)
	{
		MediaWire *wire = dynamic_cast<MediaWire *>(itemAt(i, DiagramItem::M_WIRE));
		if (wire && wire->connection.id() == connectionID)
		{
			*outWire = wire;
			return B_OK;
		}
	}
	return B_ERROR;
}
Ejemplo n.º 12
0
/*
 * Testing the functioning of an list iterator.
 */
TEST_F(ListTest, listIteratorTests)
{
        int noItems = 0;
        list.addHead(item);
        list.addTail(item1);
        Stateplex::ListIterator<Stateplex::ListItem> li(&list);

        EXPECT_EQ(li.hasCurrent(), true);
        EXPECT_EQ(li.current(), item);
        EXPECT_EQ(li.subsequent(), item1);
        EXPECT_EQ(li.hasSubsequent(), false);
        EXPECT_EQ(li.isBackwards(), false);
        list.addTail(item2);
        EXPECT_EQ(li.hasCurrent(),true);
        EXPECT_EQ(li.current(),item1);

        EXPECT_EQ(li.hasSubsequent(),false);
        noItems = countItems(&list);
        std::cout << "noItems is " << noItems << std::endl;
}
Ejemplo n.º 13
0
status_t MediaRoutingView::_findPanelFor(
	media_node_id id,
	MediaNodePanel **outPanel) const
{
	D_METHOD(("MediaRoutingView::_findPanelFor()\n"));

	for (uint32 i = 0; i < countItems(DiagramItem::M_BOX); i++)
	{
		MediaNodePanel *panel = dynamic_cast<MediaNodePanel *>(itemAt(i, DiagramItem::M_BOX));
		if (panel)
		{
			if (panel->ref->id() == id)
			{
				*outPanel = panel;
				return B_OK;
			}
		}
	}
	return B_ERROR;
}
Ejemplo n.º 14
0
static int countFfaSpawnpoints(void) {
    return countItems("info_player_deathmatch",qtrue);
}
void
ActivitiesWidget::
setActivitiesFeed( const QString l_nextPageToken )
{
    qDebug() << Q_FUNC_INFO;

    QMap<QString, QVariant> map;
    QVariantList varList( m_pPlusDataManager->getActivities() );

    ui->activitiesTableWidget->setHorizontalHeaderLabels( m_activitiesHeaderLabels );
    ui->activitiesTableWidget->setRowCount( varList.size() );

    int i(0);
    QVariant countItems(0);

    QTextEdit htmlEncoder;

    foreach(const QVariant & var, varList)
    {
        map = var.toMap();

        QString title = map["title"].toString();


        QMap<QString, QVariant> object = map["object"].toMap();
        QVariantList attachments;

        if( title.isEmpty() )
        {
            title = object["content"].toString().left(30);
            if( ! title.isEmpty() )
                title += "...";
            else
            {
                attachments = object["attachments"].toList();
                if( attachments.size() )
                {
                    title = attachments.first().toMap()["displayName"].toString();
                    if( title.isEmpty() )
                    {
                        title = attachments.first().toMap()["content"].toString().left(30);
                        if( ! title.isEmpty() )
                            title += "...";
                    }
                }
            }
        }

        if( title.isEmpty() )
            title = "Without title";
        else {
            htmlEncoder.setHtml(title);
            title = htmlEncoder.toPlainText();
        }

        ui->activitiesTableWidget->setItem(i, 0, createItem( title ) );
        ui->activitiesTableWidget->setItem(i, 1, createItem( map["actor"].toMap()["displayName"].toString() ) );
        ui->activitiesTableWidget->setItem(i, 2, createItem( map["published"].toDateTime().toString("yyyy-MM-dd hh:mm") ) );

        countItems = object["replies"].toMap()["totalItems"];
        ui->activitiesTableWidget->setItem(i, 3, createItem( countItems.toInt() > 1 ? countItems.toString() : QString("none") ) );

        countItems = object["plusoners"].toMap()["totalItems"];
        ui->activitiesTableWidget->setItem(i, 5, createItem( countItems.toInt() > 1 ? countItems.toString() : QString("none") ) );

        countItems = object["resharers"].toMap()["totalItems"];
        ui->activitiesTableWidget->setItem(i, 4, createItem( countItems.toInt() > 1 ? countItems.toString() : QString("none") ) );

        ++i;
    }
Ejemplo n.º 16
0
status_t MediaRoutingView::importState(
	const BMessage*						archive) {

	status_t err;

	_emptyInactiveNodeState();

	layout_t layout;
	err = archive->FindInt32("layout", (int32*)&layout);
	if(err == B_OK && layout != m_layout) {
		layoutChanged(layout);
	}
	
	const char* path;
	err = archive->FindString("bgBitmap", &path);
	if(err == B_OK) {
		BEntry entry(path);
		entry_ref ref;
		err = entry.GetRef(&ref);
		if(err == B_OK)
			_changeBackground(&ref);
	}
	else {
		rgb_color color;
		color.alpha = 255;
		if(
			archive->FindInt8("bgRed", (int8*)&color.red) == B_OK &&
			archive->FindInt8("bgGreen", (int8*)&color.green) == B_OK &&
			archive->FindInt8("bgBlue", (int8*)&color.blue) == B_OK)
				_changeBackground(color);
	}	
	
	for(int32 n = 0; ; ++n) {

		// find panel state info; stop when exhausted
		BMessage m;
		err = archive->FindMessage("panel", n, &m);
		if(err < B_OK)
			break;
		
		const char* nodeName;
		err = archive->FindString("nodeName", n, &nodeName);
		if(err < B_OK)
			break;
			
		uint32 nodeKind;
		err = archive->FindInt32("nodeKind", n, (int32*)&nodeKind);
		if(err < B_OK)
			break;

		// look up matching panel +++++ SLOW +++++
		uint32 panelIndex;
		uint32 items = countItems(DiagramItem::M_BOX);
		for(
			panelIndex = 0;
			panelIndex < items;
			++panelIndex) {
		
			MediaNodePanel* panel = dynamic_cast<MediaNodePanel*>(
				itemAt(panelIndex, DiagramItem::M_BOX));
				
			if(panel &&
				!strcmp(panel->ref->name(), nodeName) &&
				panel->ref->kind() == nodeKind) {
				
				// found match; hand message to panel
				panel->importState(&m);
				break;
			}
		}
		if(panelIndex == items) {
			// no panel found
			// if a "system node" hang onto (and re-export) state info
			bool sysOwned;
			if(m.FindBool("sysOwned", &sysOwned) == B_OK && sysOwned) {
				m_inactiveNodeState.AddItem(
					new _inactive_node_state_entry(
						nodeName, nodeKind, m));
			}
		}
	}

	updateDataRect();
	
	return B_OK;
}
Ejemplo n.º 17
0
void MediaRoutingView::layoutChanged(
	layout_t layout)
{
	D_METHOD(("MediaRoutingView::layoutChanged()\n"));
	
	switch (layout)
	{
		case M_ICON_VIEW:
		{
			float temp;

			// swap the cleanup defaults
			temp = M_CLEANUP_H_GAP;
			M_CLEANUP_H_GAP = M_CLEANUP_V_GAP;
			M_CLEANUP_V_GAP = temp;
			temp = M_CLEANUP_H_MARGIN;
			M_CLEANUP_H_MARGIN = M_CLEANUP_V_MARGIN;
			M_CLEANUP_V_MARGIN = temp;

			// swap the default dimensions for MediaJacks
			temp = MediaJack::M_DEFAULT_WIDTH;
			MediaJack::M_DEFAULT_WIDTH = MediaJack::M_DEFAULT_HEIGHT;
			MediaJack::M_DEFAULT_HEIGHT = temp;

			// Add space for the 3-letter i/o-abbreviation
			BFont font(be_plain_font);
			font.SetSize(font.Size() - 2.0);
			for (int i = 0; i < MediaJack::M_MAX_ABBR_LENGTH; i++)
			{
				MediaJack::M_DEFAULT_WIDTH += font.StringWidth("M");
			}
			MediaJack::M_DEFAULT_WIDTH += 2.0; // add some padding

			// Adjust the default size for MediaNodePanels
			float labelWidth, bodyWidth;
			float labelHeight, bodyHeight;
			font_height fh;
			be_plain_font->GetHeight(&fh);
			labelWidth = 4 * MediaNodePanel::M_LABEL_H_MARGIN
						 + be_plain_font->StringWidth(" Be Audio Mixer ");
			bodyWidth = 2 * MediaNodePanel::M_BODY_H_MARGIN + B_LARGE_ICON
						+ 2 * MediaJack::M_DEFAULT_WIDTH;
			labelHeight = 2 * MediaNodePanel::M_LABEL_V_MARGIN
						  + fh.ascent + fh.descent + fh.leading + 1.0;
			bodyHeight = 2 * MediaNodePanel::M_BODY_V_MARGIN + B_LARGE_ICON;
			MediaNodePanel::M_DEFAULT_WIDTH = labelWidth > bodyWidth ? labelWidth : bodyWidth;
			MediaNodePanel::M_DEFAULT_HEIGHT = labelHeight + bodyHeight;
			align(&MediaNodePanel::M_DEFAULT_WIDTH, &MediaNodePanel::M_DEFAULT_HEIGHT);
			break;
		}
		case M_MINI_ICON_VIEW:
		{
			float temp;

			// Swap the cleanup defaults
			temp = M_CLEANUP_H_GAP;
			M_CLEANUP_H_GAP = M_CLEANUP_V_GAP;
			M_CLEANUP_V_GAP = temp;
			temp = M_CLEANUP_H_MARGIN;
			M_CLEANUP_H_MARGIN = M_CLEANUP_V_MARGIN;
			M_CLEANUP_V_MARGIN = temp;

			// Subtract space for the 3-letter i/o-abbreviation
			BFont font(be_plain_font);
			font.SetSize(font.Size() - 2.0);
			for (int i = 0; i < MediaJack::M_MAX_ABBR_LENGTH; i++)
			{
				MediaJack::M_DEFAULT_WIDTH -= font.StringWidth("M");
			}
			MediaJack::M_DEFAULT_WIDTH -= 2.0; // substract the padding

			// Swap the default dimensions for MediaJacks
			temp = MediaJack::M_DEFAULT_WIDTH;
			MediaJack::M_DEFAULT_WIDTH = MediaJack::M_DEFAULT_HEIGHT;
			MediaJack::M_DEFAULT_HEIGHT = temp;

			// Adjust the default size for MediaNodePanels
			float labelWidth, bodyWidth;
			float labelHeight, bodyHeight;
			font_height fh;
			be_plain_font->GetHeight(&fh);
			labelWidth = 4 * MediaNodePanel::M_LABEL_H_MARGIN
						 + be_plain_font->StringWidth(" Be Audio Mixer ");
			bodyWidth = 2 * MediaNodePanel::M_BODY_H_MARGIN + B_MINI_ICON;
			labelHeight = 3 * MediaNodePanel::M_LABEL_V_MARGIN
						  + fh.ascent + fh.descent + fh.leading
						  + 2 * MediaJack::M_DEFAULT_HEIGHT;
			bodyHeight = 2 * MediaNodePanel::M_BODY_V_MARGIN + B_MINI_ICON;
			MediaNodePanel::M_DEFAULT_WIDTH = labelWidth + bodyWidth;
			MediaNodePanel::M_DEFAULT_HEIGHT = labelHeight > bodyHeight ? labelHeight : bodyHeight;
			align(&MediaNodePanel::M_DEFAULT_WIDTH, &MediaNodePanel::M_DEFAULT_HEIGHT);
			break;
		}
	}
	m_layout = layout;
	for (uint32 i = 0; i < countItems(DiagramItem::M_BOX); i++)
	{
		MediaNodePanel *panel = dynamic_cast<MediaNodePanel *>(itemAt(i, DiagramItem::M_BOX));
		if (panel)
		{
			panel->layoutChanged(layout);
		}
	}

	_adjustScrollBars();
}
Ejemplo n.º 18
0
BPoint MediaRoutingView::findFreePositionFor(
	const MediaNodePanel* panel) const
{
	D_METHOD(("MediaRoutingView::_findFreeSpotFor()\n"));
	
	BPoint p(M_CLEANUP_H_MARGIN, M_CLEANUP_V_MARGIN);
	if (panel)
	{
		switch (m_layout)
		{
			case M_ICON_VIEW:
			{
				// find the target column by node_kind
				p.x += M_CLEANUP_H_GAP + MediaNodePanel::M_DEFAULT_WIDTH;
				if (panel->ref->kind() & B_BUFFER_PRODUCER)
				{
					p.x -= M_CLEANUP_H_GAP + MediaNodePanel::M_DEFAULT_WIDTH;
				}
				if (panel->ref->kind() & B_BUFFER_CONSUMER)
				{
					p.x += M_CLEANUP_H_GAP + MediaNodePanel::M_DEFAULT_WIDTH;
				}
				// find the bottom item in the column
				float bottom = 0.0;
				for (uint32 i = 0; i < countItems(DiagramItem::M_BOX); i++)
				{
					BRect r = itemAt(i, DiagramItem::M_BOX)->frame();
					if ((r.left >= p.x)
					 && (r.left <= p.x + MediaNodePanel::M_DEFAULT_WIDTH))
					{
						bottom = (r.bottom > bottom) ? r.bottom : bottom;
					}
				}
				if (bottom >= p.y)
				{
					p.y = bottom + M_CLEANUP_V_GAP;
				}
				break;
			}
			case M_MINI_ICON_VIEW:
			{
				// find the target row by node_kind
				p.y += M_CLEANUP_V_GAP + MediaNodePanel::M_DEFAULT_HEIGHT;
				if (panel->ref->kind() & B_BUFFER_PRODUCER)
				{
					p.y -= M_CLEANUP_V_GAP + MediaNodePanel::M_DEFAULT_HEIGHT;
				}
				if (panel->ref->kind() & B_BUFFER_CONSUMER)
				{
					p.y += M_CLEANUP_V_GAP + MediaNodePanel::M_DEFAULT_HEIGHT;
				}
				// find the right-most item in the row
				float right = 0.0;
				for (uint32 i = 0; i < countItems(DiagramItem::M_BOX); i++)
				{
					BRect r = itemAt(i, DiagramItem::M_BOX)->frame();
					if ((r.top >= p.y)
					 && (r.top <= p.y + MediaNodePanel::M_DEFAULT_HEIGHT))
					{
						right = (r.right > right) ? r.right : right;
					}
				}
				if (right >= p.x)
				{
					p.x = right + M_CLEANUP_H_GAP;
				}
				break;				
			}
		}
	}
	return p;
}