예제 #1
0
void UserInterface::onButtonSelect(const UserInterfaceEvent& args)
{
    // if button is mutually exclusive
    // deselect others
    if (args.type == BUTTON_TOOL_BRUSH ||
        args.type == BUTTON_TOOL_TRANSLATE ||
        args.type == BUTTON_TOOL_ROTATE ||
        args.type == BUTTON_TOOL_SCALE)
    {

        std::vector<ImageButton*> buttons = getSelectedButtons();

        if (buttons.size() > 0)
        {
            for (std::size_t i = 0; i < buttons.size(); i++)
            {
                ImageButton* button = buttons[i];
                if (button->type != args.type &&
                    (args.type == BUTTON_TOOL_BRUSH ||
                     args.type == BUTTON_TOOL_TRANSLATE ||
                     args.type == BUTTON_TOOL_ROTATE ||
                     args.type == BUTTON_TOOL_SCALE))
                {
                    button->deselect();
                }
            }
        }
    }
}
예제 #2
0
ImageButton* ImageButton::Create(Window *parent, float x, float y, const char *texture)
{
	ImageButton *res = new ImageButton(parent);
	res->Move(x, y);
	res->SetTexture(texture, true);
	return res;
}
예제 #3
0
파일: bplayer.cpp 프로젝트: Nirlendu/mona
    void initComponents()
    {
        setBackground(BG_COLOR);
        setBounds(120, 120, ICON_WIDTH * 3 + PROGRESS_SIZE + PADDING * 3 + 40, ICON_HEIGHT + PROGRESS_SIZE + 50);

        statusLabel_ = new Label("ready");
        statusLabel_->setBounds(START_X, START_Y, ICON_WIDTH * 4, ICON_HEIGHT);
        statusLabel_->setBackground(BG_COLOR);
        statusLabel_->setForeground(monagui::Color::gray);
        add(statusLabel_);

        playButton_ = new ImageSinkButton(playImage_, stopImage_, playImageFocused_);
        playButton_->setBounds(ICON_WIDTH + PADDING + START_X, ICON_HEIGHT + START_Y + PADDING, ICON_WIDTH, ICON_HEIGHT);
        add(playButton_);

        backButton_ = new ImageButton(backImage_, backImageFocused_);
        backButton_->setBounds(START_X, ICON_HEIGHT + START_Y + PADDING, ICON_WIDTH, ICON_HEIGHT);
        add(backButton_);

        forwardButton_ = new ImageButton(forwardImage_, forwardImageFocused_);
        forwardButton_->setBounds(ICON_WIDTH * 2 + PADDING * 2 + START_X, ICON_HEIGHT + START_Y + PADDING, ICON_WIDTH, ICON_HEIGHT);
        add(forwardButton_);

        Strings icons;
        icons.push_back(APPLICATION_DATA_DIR"/BAR0.JPG");
        icons.push_back(APPLICATION_DATA_DIR"/BAR1.JPG");
        icons.push_back(APPLICATION_DATA_DIR"/BAR2.JPG");
        icons.push_back(APPLICATION_DATA_DIR"/BAR3.JPG");
        icons.push_back(APPLICATION_DATA_DIR"/BAR4.JPG");
        progressIcon_ = new ProgressIcon(icons, PROGRESS_SIZE, PROGRESS_SIZE);
        progressIcon_->setBounds(ICON_WIDTH * 3 + PADDING * 3 + START_X, ICON_HEIGHT + START_Y + PADDING, PROGRESS_SIZE, PROGRESS_SIZE);
        add(progressIcon_);
    }
예제 #4
0
파일: IconBar.cpp 프로젝트: louisdem/IMKit
IconBar::~IconBar() {
	int32 buttons = fButtons.size();
	for (int32 i = 0; i < buttons; i++) {
		ImageButton *button = fButtons[i];
		button->RemoveSelf();
		delete button;
	};
};
예제 #5
0
void TitleWidget::initUi(const bool &isMainTitle)
{
	QLabel *logoLabel = new QLabel;
	QPixmap pix(":/title_images/logo");
	QSize s(25, 25);
	//		将图标缩小
	logoLabel->setPixmap(pix.scaled(s, Qt::KeepAspectRatio));

	QLabel *titleLabel = new QLabel(APP_NAME + " " + APP_VERSION);
	titleLabel->setObjectName("TitleLabel");

	ImageButton *upButton = new ImageButton(":/title_images/update_btn");
	upButton->setCursorEnable(true);
	connect(upButton, SIGNAL(clicked()), this, SIGNAL(updateClicked()));

	QWidget *titleWidget = new QWidget(this);
	QHBoxLayout *titleLayout = new QHBoxLayout(titleWidget);
	titleLayout->addWidget(logoLabel, 0, Qt::AlignVCenter);
	titleLayout->addWidget(titleLabel, 0, Qt::AlignVCenter);
	titleLayout->addWidget(upButton, 0, Qt::AlignVCenter);
	titleLayout->setContentsMargins(0, 0, 0, 0);

	ImageButton *closeButton = new ImageButton(":/title_images/close_btn");
	closeButton->setCursorEnable(true);
	connect(closeButton, SIGNAL(clicked()), this, SIGNAL(closeClicked()));

	QWidget *buttonWidget = new QWidget;
	QHBoxLayout *buttnLayout = new QHBoxLayout(buttonWidget);

	if (isMainTitle)
	{
		ImageButton *miniButton = new ImageButton(":/title_images/mini_btn");
		miniButton->setCursorEnable(true);
		connect(miniButton, SIGNAL(clicked()), this, SIGNAL(showMini()));

		ImageButton *menuButton = new ImageButton(":/title_images/menu_btn");
		menuButton->setCursorEnable(true);
		//connect(menuButton, SIGNAL(clicked()), this, SIGNAL(showMenu()));
		connect(menuButton, SIGNAL(clicked()), this, SLOT(menuVisiable()));

		ImageButton *skinButton = new ImageButton(":/title_images/skin_btn");
		skinButton->setCursorEnable(true);
		connect(skinButton, SIGNAL(clicked()), this, SIGNAL(showSkin()));

		buttnLayout->addWidget(skinButton, 0, Qt::AlignVCenter);
		buttnLayout->addWidget(miniButton, 0, Qt::AlignVCenter);
		buttnLayout->addWidget(menuButton, 0, Qt::AlignVCenter);

	}
	buttnLayout->addWidget(closeButton, 0, Qt::AlignVCenter);
	buttnLayout->setContentsMargins(0, 0, 0, 0);

	QHBoxLayout *mainLayout = new QHBoxLayout(this);
	mainLayout->addWidget(titleWidget, 0, Qt::AlignLeft | Qt::AlignTop);
	mainLayout->addStretch();
	mainLayout->addWidget(buttonWidget, 0, Qt::AlignRight | Qt::AlignVCenter);
	mainLayout->setContentsMargins(5, 5, 5, 5);
}
예제 #6
0
bool
GridItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index )
{
    Q_UNUSED( model );
    Q_UNUSED( option );

    if ( event->type() != QEvent::MouseButtonRelease &&
         event->type() != QEvent::MouseMove &&
         event->type() != QEvent::MouseButtonPress &&
         event->type() != QEvent::Leave )
        return false;

    bool hoveringArtist = false;
    if ( m_artistNameRects.contains( index ) )
    {
        const QRect artistNameRect = m_artistNameRects[ index ];
        const QMouseEvent* ev = static_cast< QMouseEvent* >( event );
        hoveringArtist = artistNameRect.contains( ev->pos() );
    }

    if ( event->type() == QEvent::MouseMove )
    {
        if ( hoveringArtist )
            m_view->setCursor( Qt::PointingHandCursor );
        else
            m_view->setCursor( Qt::ArrowCursor );

        foreach ( const QModelIndex& idx, m_playButton.keys() )
        {
            if ( index != idx )
                m_playButton.take( idx )->deleteLater();
        }

        if ( !m_playButton.contains( index ) && !m_spinner.contains( index ) && !m_pauseButton.contains( index ) )
        {
            foreach ( ImageButton* button, m_playButton )
                button->deleteLater();
            m_playButton.clear();

            // only add the play button to a album picture if the party mode is not active
            const bool isPartyMode = TomahawkSettings::instance()->partyModeEnabled();
            if ( !isPartyMode )
            {
                ImageButton* button = new ImageButton( m_view );
                button->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::PlayButton, TomahawkUtils::Original, QSize( 48, 48 ) ) );
                button->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::PlayButtonPressed, TomahawkUtils::Original, QSize( 48, 48 ) ), QIcon::Off, QIcon::Active );
                button->setFixedSize( 48, 48 );
                button->move( option.rect.center() - QPoint( 23, 23 ) );
                button->setContentsMargins( 0, 0, 0, 0 );
                button->setFocusPolicy( Qt::NoFocus );
                button->installEventFilter( this );
                button->show();

                NewClosure( button, SIGNAL( clicked( bool ) ),
                            const_cast<GridItemDelegate*>(this), SLOT( onPlayClicked( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );

                m_playButton[ index ] = button;
            }
        }
예제 #7
0
파일: main.cpp 프로젝트: PyroOS/Pyro
void BrowserWindow::UpdateButtonState( bool bLoadStarted )
{
	BrowserWebView *pcWebView = GetCurrentWebView();

	if( bLoadStarted )
	{
		m_pcStopButton->SetEnable( true );
		m_pcReloadButton->SetEnable( false );

		m_pcProgress->SetProgress( true );
	}
	else
	{
		m_pcStopButton->SetEnable( false );
		m_pcReloadButton->SetEnable( true );

		m_pcProgress->SetProgress( false );
	}

	if( pcWebView->GetForwardListCount() > 0 )
		m_pcForwardButton->SetEnable( true );
	else
		m_pcForwardButton->SetEnable( false );

	if( pcWebView->GetBackListCount() > 0 )
		m_pcBackButton->SetEnable( true );
	else
		m_pcBackButton->SetEnable( false );
}
예제 #8
0
파일: IconBar.cpp 프로젝트: louisdem/IMKit
void IconBar::AttachedToWindow(void) {
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
 	SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
 	SetHighColor(0, 0, 0, 255);

	BDirectory dir(fAppPath.String());
 	entry_ref ref;
 	BRect iconRect = Bounds();

	fIconSize = (int16)(iconRect.Height() - (fPadding * 2));
 	
	iconRect.bottom -= fPadding;
	iconRect.top += fPadding;
 	iconRect.right = fIconSize;
 	iconRect.left += fPadding;
 	
 	fIconSize -= fPadding * 4;
	
 	while (dir.GetNextRef(&ref) == B_OK) {
 		BPath path(&ref);
 		BNode node(&ref);
 		BBitmap *icon = ReadNodeIcon(path.Path(), fIconSize, true);

		int32 length = -1;
		char *desc = ReadAttribute(node, "im_client:description", &length);
		if ((length < 1) || (desc == NULL)) desc = strdup(ref.name);
		
		BMessage *msg = new BMessage(kClickMsg);
		msg->AddRef("app_ref", &ref);
				
 		ImageButton *button = new ImageButton(iconRect, ref.name, msg,
 			B_FOLLOW_NONE, B_WILL_DRAW, icon, NULL);
 		fBubbles->SetHelp(button, desc);
 		AddChild(button);
 		
 		button->SetTarget(this);
 		
 		fButtons.push_back(button);
 		
 		free(desc);

 		
 		iconRect.OffsetBy(iconRect.Width() + fPadding, 0);
 	};
};
예제 #9
0
bool
AlbumItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index )
{
    Q_UNUSED( model );
    Q_UNUSED( option );

    if ( event->type() != QEvent::MouseButtonRelease &&
         event->type() != QEvent::MouseMove &&
         event->type() != QEvent::MouseButtonPress &&
         event->type() != QEvent::Leave )
        return false;

    bool hoveringArtist = false;
    if ( m_artistNameRects.contains( index ) )
    {
        const QRect artistNameRect = m_artistNameRects[ index ];
        const QMouseEvent* ev = static_cast< QMouseEvent* >( event );
        hoveringArtist = artistNameRect.contains( ev->pos() );
    }

    if ( event->type() == QEvent::MouseMove )
    {
        foreach ( const QModelIndex& idx, m_playButton.keys() )
        {
            if ( index != idx )
                m_playButton.take( idx )->deleteLater();
        }

        if ( !m_playButton.contains( index ) && !m_spinner.contains( index ) && !m_pauseButton.contains( index ) )
        {
            foreach ( ImageButton* button, m_playButton )
                button->deleteLater();
            m_playButton.clear();

            ImageButton* button = new ImageButton( m_view );
            button->setPixmap( RESPATH "images/play-rest.png" );
            button->setPixmap( RESPATH "images/play-pressed.png", QIcon::Off, QIcon::Active );
            button->setFixedSize( 48, 48 );
            button->move( option.rect.center() - QPoint( 23, 23 ) );
            button->setContentsMargins( 0, 0, 0, 0 );
            button->setFocusPolicy( Qt::NoFocus );
            button->installEventFilter( this );
            button->show();

            NewClosure( button, SIGNAL( clicked( bool ) ),
                        const_cast<AlbumItemDelegate*>(this), SLOT( onPlayClicked( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );

            m_playButton[ index ] = button;
        }
예제 #10
0
void MapPanel::AddMap(char* imageName, char* mapCommand, char* mapName)
{
	char tmp[256];
	Q_snprintf(tmp, sizeof(tmp), "Map%i", count);
	Label *name = new Label(this, tmp, mapName);

	ImageButton *image;	
	Q_snprintf(tmp, sizeof(tmp), "materials/vgui/%s.vmt", imageName);
	if (!g_pFullFileSystem->FileExists(tmp, "MOD")){
		Q_snprintf(tmp, sizeof(tmp), "Image%i", count);
		image = new ImageButton(this, tmp, "maps/menu_thumb_default", NULL, NULL, mapCommand);
	}
	else{
		Q_snprintf(tmp, sizeof(tmp), "Image%i", count);
		image = new ImageButton(this, tmp, imageName, NULL, NULL, mapCommand);
	}
	image->AddActionSignalTarget(this);
	//image->SetSize(32, 32);

	AddItem(image, name);
	count++;
}
예제 #11
0
bool
GridItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index )
{
    Q_UNUSED( model );
    Q_UNUSED( option );

    if ( event->type() != QEvent::MouseButtonRelease &&
            event->type() != QEvent::MouseMove &&
            event->type() != QEvent::MouseButtonPress &&
            event->type() != QEvent::Leave )
        return false;

    bool hoveringArtist = false;
    if ( m_artistNameRects.contains( index ) )
    {
        const QRect artistNameRect = m_artistNameRects[ index ];
        const QMouseEvent* ev = static_cast< QMouseEvent* >( event );
        hoveringArtist = artistNameRect.contains( ev->pos() );
    }

    if ( event->type() == QEvent::MouseMove )
    {
        if ( hoveringArtist )
            m_view->setCursor( Qt::PointingHandCursor );
        else
            m_view->setCursor( Qt::ArrowCursor );

        foreach ( const QModelIndex& idx, m_playButton.keys() )
        {
            if ( index != idx )
                m_playButton.take( idx )->deleteLater();
        }

        if ( !m_playButton.contains( index ) && !m_spinner.contains( index ) && !m_pauseButton.contains( index ) )
        {
            foreach ( ImageButton* button, m_playButton )
                button->deleteLater();
            m_playButton.clear();

            ImageButton* button = new ImageButton( m_view );
            button->setPixmap( RESPATH "images/play-rest.png" );
            button->setPixmap( RESPATH "images/play-pressed.png", QIcon::Off, QIcon::Active );
            button->setFixedSize( 48, 48 );
            button->move( option.rect.center() - QPoint( 23, 23 ) );
            button->setContentsMargins( 0, 0, 0, 0 );
            button->setFocusPolicy( Qt::NoFocus );
            button->installEventFilter( this );
            button->show();

            NewClosure( button, SIGNAL( clicked( bool ) ),
                        const_cast<GridItemDelegate*>(this), SLOT( onPlayClicked( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );

            m_playButton[ index ] = button;
        }

        if ( m_hoveringOver != index || ( !hoveringArtist && m_hoveringOver.isValid() ) )
        {
            emit updateIndex( m_hoveringOver );

            if ( hoveringArtist )
                m_hoveringOver = index;
            else
                m_hoveringOver = QPersistentModelIndex();

            emit updateIndex( index );
        }

        if ( m_hoverIndex != index )
        {
            if ( m_hoverIndex.isValid() )
            {
                QTimeLine* fadeOut = createTimeline( QTimeLine::Forward );
                _detail::Closure* c = NewClosure( fadeOut, SIGNAL( frameChanged( int ) ), this, SLOT( fadingFrameChanged( QPersistentModelIndex ) ), QPersistentModelIndex( m_hoverIndex ) );
                c->setAutoDelete( false );
                c = NewClosure( fadeOut, SIGNAL( finished() ), this, SLOT( fadingFrameFinished( QPersistentModelIndex ) ), QPersistentModelIndex( m_hoverIndex ) );
                c->setAutoDelete( false );
                m_hoverFaders[ m_hoverIndex ] = fadeOut;
                fadeOut->start();
            }

            emit updateIndex( m_hoverIndex );
            m_hoverIndex = index;

            QTimeLine* fadeIn = createTimeline( QTimeLine::Backward );
            _detail::Closure* c = NewClosure( fadeIn, SIGNAL( frameChanged( int ) ), this, SLOT( fadingFrameChanged( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );
            c->setAutoDelete( false );
            c = NewClosure( fadeIn, SIGNAL( finished() ), this, SLOT( fadingFrameFinished( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );
            c->setAutoDelete( false );

            m_hoverFaders[ index ] = fadeIn;
            fadeIn->start();

            emit updateIndex( index );
        }
예제 #12
0
GlassSpinner::GlassSpinner() : GlassContainer(), GlassWidget(this) {
	spinStep = 1;
	downSpin = upSpin = false;
	value = 0;
	min = -1000;
	max =  1000;
	ticks = Host_Milliseconds();
	
	setSize(50, getFont()->getHeight()+4);
	text = new GlassTextField("000");
	text->setWidthChars(5);
	add(text, getHeight()/2, 0);
	ImageButton *b = new ImageButton();
	b->addActionListener(this);
	b->addMouseListener(this);
	b->setActionEventId("up");
	b->setImage("/gui/standard/scroll_up.png");
	b->setSize(getHeight()/2, getHeight()/2);
	add(b, 0, 0);
	b = new ImageButton();
	b->addActionListener(this);
	b->addMouseListener(this);
	b->setActionEventId("down");
	b->setImage("/gui/standard/scroll_down.png");
	b->setSize(getHeight()/2, getHeight()/2);
	add(b, 0, getHeight()/2);
	
	setSize(text->getWidth()+getHeight()/2, getFont()->getHeight()+4);
}