void FileTreeComponent::setSelectedFile (const File& target)
{
    for (int i = getNumSelectedItems(); --i >= 0;)
    {
        FileListTreeItem* t = dynamic_cast <FileListTreeItem*> (getSelectedItem (i));

        if (t != nullptr && t->file == target)
        {
            t->setSelected (true, true);
            return;
        }
    }

    clearSelectedItems();
}
Exemple #2
0
void LLSidepanelInventory::updateVerbs()
{
	mInfoBtn->setEnabled(FALSE);
	mShareBtn->setEnabled(FALSE);

	mWearBtn->setVisible(FALSE);
	mWearBtn->setEnabled(FALSE);
	mPlayBtn->setVisible(FALSE);
	mPlayBtn->setEnabled(FALSE);
 	mTeleportBtn->setVisible(FALSE);
 	mTeleportBtn->setEnabled(FALSE);
 	mShopBtn->setVisible(TRUE);

	mShareBtn->setEnabled(canShare());

	const LLInventoryItem *item = getSelectedItem();
	if (!item)
		return;

	bool is_single_selection = getSelectedCount() == 1;

	mInfoBtn->setEnabled(is_single_selection);

	switch(item->getInventoryType())
	{
		case LLInventoryType::IT_WEARABLE:
		case LLInventoryType::IT_OBJECT:
		case LLInventoryType::IT_ATTACHMENT:
			mWearBtn->setVisible(TRUE);
			mWearBtn->setEnabled(canWearSelected());
		 	mShopBtn->setVisible(FALSE);
			break;
		case LLInventoryType::IT_SOUND:
		case LLInventoryType::IT_GESTURE:
		case LLInventoryType::IT_ANIMATION:
			mPlayBtn->setVisible(TRUE);
			mPlayBtn->setEnabled(TRUE);
		 	mShopBtn->setVisible(FALSE);
			break;
		case LLInventoryType::IT_LANDMARK:
			mTeleportBtn->setVisible(TRUE);
			mTeleportBtn->setEnabled(TRUE);
		 	mShopBtn->setVisible(FALSE);
			break;
		default:
			break;
	}
}
Exemple #3
0
void ItemContainer::showPopupMenu(MenuType type, bool useMouseCoordinates)
{
    int x = 0;
    int y = 0;

    getPopupLocation(useMouseCoordinates, x, y);

    Item *item = getSelectedItem();

    if (!item)
        return;

    mPopupMenu->setType(type);
    mPopupMenu->setItem(item);
    mPopupMenu->showPopup(x, y);
}
void LocationPane::contextMenuRequested(const QPoint &pos)
{
	qDebug() << "void LocationPane::contextMenuRequested(const QPoint &pos)";

	QMenu *menu = 0;
	LocationItem *item = getSelectedItem();

	if (item && item->isSubscription())
		menu = getSubscriptionMenu();
	else if (item && item->isRemoteHost())
		menu = getRemoteHostMenu();
	else
		menu = getRootMenu();

	// Show the menu and handle the returned action
	action(menu->exec(ui.locationTree->mapToGlobal(pos)));
}
Exemple #5
0
void TreeView::moveSelectedRow (int delta)
{
    if (delta == 0)
        return;

    int rowSelected = 0;

    TreeViewItem* const firstSelected = getSelectedItem (0);
    if (firstSelected != 0)
        rowSelected = firstSelected->getRowNumberInTree();

    rowSelected = jlimit (0, getNumRowsInTree() - 1, rowSelected + delta);

    for (;;)
    {
        TreeViewItem* item = getItemOnRow (rowSelected);

        if (item != 0)
        {
            if (! item->canBeSelected())
            {
                // if the row we want to highlight doesn't allow it, try skipping
                // to the next item..
                const int nextRowToTry = jlimit (0, getNumRowsInTree() - 1,
                                                 rowSelected + (delta < 0 ? -1 : 1));

                if (rowSelected != nextRowToTry)
                {
                    rowSelected = nextRowToTry;
                    continue;
                }
                else
                {
                    break;
                }
            }

            item->setSelected (true, true);

            scrollToKeepItemVisible (item);
        }

        break;
    }
}
Exemple #6
0
void LLSidepanelInventory::onPlayButtonClicked()
{
	const LLInventoryItem *item = getSelectedItem();
	if (!item)
	{
		return;
	}

	switch(item->getInventoryType())
	{
	case LLInventoryType::IT_GESTURE:
		performActionOnSelection("play");
		break;
	default:
		performActionOnSelection("open");
		break;
	}
}
void MonitorGraphicsView::removeFixture(quint32 id)
{
    MonitorFixtureItem *item = NULL;

    if (id == Fixture::invalidId())
    {
        item = getSelectedItem();
        if (item != NULL)
            id = item->fixtureID();
    }
    else
        item = m_fixtures[id];

    if (item == NULL)
        return;

    m_scene->removeItem(item);
    m_fixtures.take(id);
    delete item;
}
void SCTPAllAssocsDialog::fillTable()
{
    QString output;
    GList *list;
    sctp_assoc_info_t* assinfo;
    int numAssocs;

    ui->assocList->setColumnHidden(0, true);
    ui->assocList->setColumnWidth(1,  85);
    ui->assocList->setColumnWidth(2,  85);
    ui->assocList->setColumnWidth(3,  150);
    ui->assocList->setColumnWidth(4,  150);

    sctp_assocs = (sctp_allassocs_info_t*)sctp_stat_get_info();
    if (sctp_stat_get_info()->is_registered == FALSE) {
        register_tap_listener_sctp_stat();
        /*  (redissect all packets) */
        cf_retap_packets(cap_file_);
    }
    numAssocs = 0;
    ui->assocList->setRowCount(g_list_length(sctp_assocs->assoc_info_list));

    list = g_list_first(sctp_assocs->assoc_info_list);

    while (list) {
        assinfo = (sctp_assoc_info_t*)(list->data);
        ui->assocList->setItem(numAssocs, 0, new QTableWidgetItem(QString("%1").arg(assinfo->assoc_id)));
        ui->assocList->setItem(numAssocs, 1, new QTableWidgetItem(QString("%1").arg(assinfo->port1)));
        ui->assocList->setItem(numAssocs, 2, new QTableWidgetItem(QString("%1").arg(assinfo->port2)));
        ui->assocList->setItem(numAssocs, 3, new QTableWidgetItem(QString("%1").arg(assinfo->n_packets)));
        ui->assocList->setItem(numAssocs, 4, new QTableWidgetItem(QString("%1").arg(assinfo->n_data_chunks)));
        ui->assocList->setItem(numAssocs, 5, new QTableWidgetItem(QString("%1").arg(assinfo->n_data_bytes)));
        list = g_list_next(list);
        numAssocs++;
    }
    ui->analyseButton->setEnabled(false);
    ui->setFilterButton->setEnabled(false);
    connect(ui->assocList, SIGNAL(itemSelectionChanged()), this, SLOT(getSelectedItem()));
 }
Exemple #9
0
void ItemContainer::showItemPopup(bool show)
{
    Item *item = getSelectedItem();

    if (!item || item->getQuantity() <= 0 || !passesFilter(item))
    {
        mItemPopup->setVisible(false);
        return;
    }

    if (item->getInfo().getName() != mItemPopup->getItemName())
        mItemPopup->setItem(item->getInfo());

    int x = 0;
    int y = 0;

    getPopupLocation(false, x, y);

    mItemPopup->updateColors();
    mItemPopup->view(x, y);
    mItemPopup->setVisible(mShowItemInfo ? show : false);
}
bool MonitorGraphicsView::removeFixture(quint32 id)
{
    MonitorFixtureItem *item = NULL;

    if (id == Fixture::invalidId())
    {
        item = getSelectedItem();
        if (item != NULL)
            id = item->fixtureID();
    }
    else
        item = m_fixtures[id];

    if (item == NULL)
        return false;

    m_scene->removeItem(item);
    m_fixtures.take(id);
    m_doc->monitorProperties()->removeFixture(id);
    delete item;

    return true;
}
void Parametertuner::ChangeValue(int dir)
{
	QTreeWidgetItem* thisItem;
	if (!(thisItem = getSelectedItem()))
		return;

	if (thisItem->childCount() != 0)
	{
		if (dir == RIGHT && (!thisItem->isExpanded()))
			thisItem->setExpanded(true);
		else if (dir == LEFT && thisItem->isExpanded())
			thisItem->setExpanded(false);
		return;
	}
	ParameterWidgetBase* param;
	param = (ParameterWidgetBase *)m_ui.parameter_root_widget->itemWidget(thisItem, 1);
	if (!param)
		return;

	if (dir == LEFT)
		param->DecValue();
	else
		param->IncValue();
}
bool MainMenu::init() {
    if(!LayerColor::initWithColor(MENU_BACKGROUND_COLOR)) {
        return false;
    }
    
    auto titleFinalPosition = Point(VisibleRect::top().x, 1920 - 202);
    auto titleSprite = sprite("Title", Point(titleFinalPosition.x, titleFinalPosition.y + 300));
    
    addChild(titleSprite);
    
    titleSprite->runAction(EaseSineOut::create(MoveTo::create(DEFAULT_ANIMATION_TIME, titleFinalPosition)));
    
    auto menuBackground = sprite("MenuBackground", Point(VisibleRect::center().x, 1920 - 966));
    menuBackground->setScale(1.0f, 0.1);
    menuBackground->runAction(ScaleTo::create(DEFAULT_ANIMATION_TIME, 1.0f));
    addChild(menuBackground);

    auto arcadeButtonFinalPosition = Point(335, 1288);
    
    auto arcadeButton = MenuItemSprite::create(sprite("ArcadeButtonNormal"), sprite("ArcadeButtonPressed"), [=] (Ref* sender) {
        auto userDefault = UserDefault::getInstance();
        userDefault->setIntegerForKey("mode", GameMode::ARCADE);
        onPlayPress(sender);
    });
    arcadeButton->setPosition(arcadeButtonFinalPosition.x, arcadeButtonFinalPosition.y + 2000);
    arcadeButton->runAction(Sequence::create(DelayTime::create(DEFAULT_ANIMATION_TIME), EaseBounceOut::create(MoveTo::create(DEFAULT_ANIMATION_TIME, arcadeButtonFinalPosition)), CallFunc::create([=](){
        arcadeButton->runAction(RepeatForever::create(Sequence::create(DelayTime::create(DEFAULT_ANIMATION_TIME * 4), RotateTo::create(DEFAULT_ANIMATION_TIME / 2, TILE_ROTATION_DEGREE), RotateTo::create(DEFAULT_ANIMATION_TIME, -TILE_ROTATION_DEGREE),RotateTo::create(DEFAULT_ANIMATION_TIME / 2, 0.0f),NULL)));
    }), NULL) );
    
    auto timeAttackButtonFinalPosition = Point(788, 1920 - 932);
    auto timeAttackButton = MenuItemSprite::create(sprite("TimeAttackButtonNormal"), sprite("TimeAttackButtonPressed"), [=] (Ref* sender) {
        auto userDefault = UserDefault::getInstance();
        userDefault->setIntegerForKey("mode", GameMode::TIME_ATTACK);
        onPlayPress(sender);
    });
    timeAttackButton->setPosition(timeAttackButtonFinalPosition.x, timeAttackButtonFinalPosition.y + 2000);
    
    timeAttackButton->runAction(Sequence::create(DelayTime::create(DEFAULT_ANIMATION_TIME * 2), EaseBounceOut::create(MoveTo::create(DEFAULT_ANIMATION_TIME, timeAttackButtonFinalPosition)), CallFunc::create([=](){
        timeAttackButton->runAction(RepeatForever::create(Sequence::create(DelayTime::create(DEFAULT_ANIMATION_TIME * 4), RotateTo::create(DEFAULT_ANIMATION_TIME / 2, TILE_ROTATION_DEGREE), RotateTo::create(DEFAULT_ANIMATION_TIME, -TILE_ROTATION_DEGREE),RotateTo::create(DEFAULT_ANIMATION_TIME / 2, 0.0f),NULL)));
    }), NULL) );

    auto zenButtonFinalPosition = Point(335, 1920 - 1251);
    auto zenButton = MenuItemSprite::create(sprite("ZenButtonNormal"), sprite("ZenButtonPressed"), [=] (Ref* sender) {
        auto userDefault = UserDefault::getInstance();
        userDefault->setIntegerForKey("mode", GameMode::ZEN);
        onPlayPress(sender);
    });
    zenButton->setPosition(zenButtonFinalPosition.x, zenButtonFinalPosition.y + 2000);
    zenButton->runAction(Sequence::create(DelayTime::create(DEFAULT_ANIMATION_TIME * 3), EaseBounceOut::create(MoveTo::create(DEFAULT_ANIMATION_TIME, zenButtonFinalPosition)), CallFunc::create([=](){
        zenButton->runAction(RepeatForever::create(Sequence::create(DelayTime::create(DEFAULT_ANIMATION_TIME * 4), RotateTo::create(DEFAULT_ANIMATION_TIME / 2, TILE_ROTATION_DEGREE), RotateTo::create(DEFAULT_ANIMATION_TIME, -TILE_ROTATION_DEGREE),RotateTo::create(DEFAULT_ANIMATION_TIME / 2, 0.0f),NULL)));
    }), NULL) );
    
    auto arcadeLabel = label("ARCADE")->size(MENU_FONT_SIZE)->position(Point(timeAttackButtonFinalPosition.x, arcadeButtonFinalPosition.y))->color(ARCADE_TEXT_COLOR)->addTo(this);
    arcadeLabel->setVisible(false);
    arcadeLabel->runAction(Sequence::create(DelayTime::create(DEFAULT_ANIMATION_TIME * 3),  Show::create(), NULL));
    
    auto timeAttackLabel = label("  TIME\nATTACK")->size(MENU_FONT_SIZE)->position(Point(arcadeButtonFinalPosition.x, timeAttackButtonFinalPosition.y))->color(TIME_ATTACK_TEXT_COLOR)->addTo(this);
    timeAttackLabel->setVisible(false);
    timeAttackLabel->runAction(Sequence::create(DelayTime::create(DEFAULT_ANIMATION_TIME * 4),  Show::create(), NULL));
    
    auto zenLabel = label("ZEN")->size(MENU_FONT_SIZE)->position(Point(timeAttackButtonFinalPosition.x, zenButtonFinalPosition.y))->color(ZEN_TEXT_COLOR)->addTo(this);
    zenLabel->setVisible(false);
    zenLabel->runAction(Sequence::create(DelayTime::create(DEFAULT_ANIMATION_TIME * 5),  Show::create(), NULL));
    
    auto soundManager = SoundManager::sharedSoundManager();
    
    auto soundButtonOn = MenuItemSprite::create(sprite("SoundButtonOn"), nullptr);
    auto soundButton = MenuItemToggle::createWithCallback([=](Ref* sender) {
        auto button = (MenuItemToggle*) sender;
        if(button->getSelectedItem() == soundButtonOn) {
            soundManager->unmuteSound();
        } else {
            soundManager->muteSound();
        }
        playSoundEffect("Click");
    }, soundButtonOn, MenuItemSprite::create(sprite("SoundButtonOff"), nullptr), NULL);
    
    if(soundManager->isSoundEnabled()) {
        soundButton->setSelectedIndex(0);
    } else {
        soundButton->setSelectedIndex(1);
    }
    
    soundButton->setPosition(Point(291, 1920 - 1710));
    
#if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS)
    auto leaderBoardButton = MenuItemSprite::create(sprite("LeaderboardButtonNormal"), sprite("LeaderboardButtonPressed"), [=] (Ref* sender) {
        playSoundEffect("Click");
        NativeUtils::showLeaderboards();
    });
    leaderBoardButton->setPosition(Point(796, 1920 - 1710));
    
    auto menu = Menu::create(arcadeButton, timeAttackButton, zenButton, soundButton, leaderBoardButton, NULL);
    menu->setPosition(Point::ZERO);
    addChild(menu);
#else
    
    auto menu = Menu::create(arcadeButton, timeAttackButton, zenButton, soundButton, NULL);
    menu->setPosition(Point::ZERO);
    addChild(menu);
    
#endif
    
    
    runAction(RepeatForever::create(Sequence::create(DelayTime::create(DEFAULT_ANIMATION_TIME * 12), CallFunc::create([=] () {
        playSoundEffect("Giggle");
    }) , NULL)));
    
    return true;
}
// Move the selection within the parameter tuner tree widget
void Parametertuner::moveSelection(int dir)
{
	// Error checking
	if(dir != UP && dir != DOWN) return;

	// Declare variables
	QTreeWidgetItem* item;
	QTreeWidgetItem* tmpItem;
	QTreeWidgetItem* thisItem;
	QTreeWidgetItem* parentItem;
	int itemIndex;

	// Get the currently selected item
	thisItem = getSelectedItem();

	// If no item is selected then select the first top level item
	if(!thisItem)
	{
		if(dir == DOWN)
			updateSelection(NULL, m_ui.parameter_root_widget->topLevelItem(0));
		else
			updateSelection(NULL, m_ui.parameter_root_widget->topLevelItem(m_ui.parameter_root_widget->topLevelItemCount() - 1));
		return;
	}

	// Handle UP case
	if(dir == UP)
	{
		// Go to the previous item in the tree
		parentItem = itemGetParent(thisItem);
		itemIndex = parentItem->indexOfChild(thisItem);
		tmpItem = parentItem->child(itemIndex + UP);
		if(tmpItem)
		{
			item = tmpItem;
			while(item->childCount() > 0 && item->isExpanded())
				item = item->child(item->childCount() - 1);
			updateSelection(thisItem, item);
			return;
		}
		else if(itemHasParent(thisItem))
		{
			updateSelection(thisItem, parentItem);
			return;
		}
		else return; // <-- This is the case that we are at the very top-most element
	}

	// Handle DOWN case
	if(dir == DOWN)
	{
		// If the item has children and is expanded then go to the first child
		if(thisItem->childCount() > 0 && thisItem->isExpanded())
		{
			updateSelection(thisItem, thisItem->child(0));
			return;
		}

		// Go to the next item in the tree
		item = thisItem;
		while(true)
		{
			parentItem = itemGetParent(item);
			itemIndex = parentItem->indexOfChild(item);
			tmpItem = parentItem->child(itemIndex + DOWN);
			if(tmpItem)
			{
				updateSelection(thisItem, tmpItem);
				return;
			}
			else
			{
				if(itemHasParent(item))
					item = parentItem;
				else return; // <-- This is the case that we are at the very bottom-most element
			}
		}
	}
}
Exemple #14
0
bool TreeView::keyPressed (const KeyPress& key)
{
    if (key.isKeyCode (KeyPress::upKey))
    {
        moveSelectedRow (-1);
    }
    else if (key.isKeyCode (KeyPress::downKey))
    {
        moveSelectedRow (1);
    }
    else if (key.isKeyCode (KeyPress::pageDownKey) || key.isKeyCode (KeyPress::pageUpKey))
    {
        if (rootItem != 0)
        {
            int rowsOnScreen = getHeight() / jmax (1, rootItem->itemHeight);

            if (key.isKeyCode (KeyPress::pageUpKey))
                rowsOnScreen = -rowsOnScreen;

            moveSelectedRow (rowsOnScreen);
        }
    }
    else if (key.isKeyCode (KeyPress::homeKey))
    {
        moveSelectedRow (-0x3fffffff);
    }
    else if (key.isKeyCode (KeyPress::endKey))
    {
        moveSelectedRow (0x3fffffff);
    }
    else if (key.isKeyCode (KeyPress::returnKey))
    {
        TreeViewItem* const firstSelected = getSelectedItem (0);
        if (firstSelected != 0)
            firstSelected->setOpen (! firstSelected->isOpen());
    }
    else if (key.isKeyCode (KeyPress::leftKey))
    {
        TreeViewItem* const firstSelected = getSelectedItem (0);

        if (firstSelected != 0)
        {
            if (firstSelected->isOpen())
            {
                firstSelected->setOpen (false);
            }
            else
            {
                TreeViewItem* parent = firstSelected->parentItem;

                if ((! rootItemVisible) && parent == rootItem)
                    parent = 0;

                if (parent != 0)
                {
                    parent->setSelected (true, true);
                    scrollToKeepItemVisible (parent);
                }
            }
        }
    }
    else if (key.isKeyCode (KeyPress::rightKey))
    {
        TreeViewItem* const firstSelected = getSelectedItem (0);

        if (firstSelected != 0)
        {
            if (firstSelected->isOpen() || ! firstSelected->mightContainSubItems())
                moveSelectedRow (1);
            else
                firstSelected->setOpen (true);
        }
    }
    else
    {
        return false;
    }

    return true;
}
Exemple #15
0
void CmdBox::execCommand(){
    cmdManager->execCommand(getSelectedItem(), getItem(getSelectedItem())->text());
}
Exemple #16
0
void ItemContainer::keyPressed(gcn::KeyEvent &event)
{
    const int columns = std::max(1, getWidth() / gridWidth);
    const int gridSlot = getVisibleSlot(getSelectedItem());
    int itemX = gridSlot % columns;
    int itemY = gridSlot / columns;

    // Handling direction keys: all of these set selectNewItem, and change
    // itemX or itemY checking only that the selection doesn't go off the top,
    // left or right of the grid.  The block below the switch statement then
    // checks that there's an item in that slot (implictly bounds-checking that
    // the selection didn't go off the bottom of the grid).
    bool selectNewItem = false;
    switch (event.getKey().getValue())
    {
        case Key::LEFT:
            if (itemX != 0)
                itemX--;

            selectNewItem = true;
            event.consume();
            break;
        case Key::RIGHT:
            if (itemX < (columns - 1))
                itemX++;

            selectNewItem = true;
            event.consume();
            break;
        case Key::UP:
            if (itemY != 0)
                itemY--;

            selectNewItem = true;
            event.consume();
            break;
        case Key::DOWN:
            itemY++;
            selectNewItem = true;
            event.consume();
            break;
        case Key::ENTER:
        case Key::SPACE:
            if (event.isShiftPressed())
            {
                const std::string actionEventId = getActionEventId();
                setActionEventId("default");
                distributeActionEvent();
                setActionEventId(actionEventId);
            }
            else
                distributeActionEvent();

            event.consume();
            break;
    }

    if (selectNewItem)
    {
        Item* selection = getItemInVisibleSlot(itemX + columns * itemY);

        if (selection)
            setSelectedItemIndex(selection->getInvIndex());
    }
}