Beispiel #1
0
// -----------------------------------------------------------------------------
// Called when the left button is pressed within the canvas
// -----------------------------------------------------------------------------
void GfxCanvas::onMouseLeftDown(wxMouseEvent& e)
{
	int  x        = e.GetPosition().x;
	int  y        = e.GetPosition().y;
	bool on_image = onImage(x, y - 2);

	// Left mouse down
	if (e.LeftDown() && on_image)
	{
		// Paint in paint mode
		if (editing_mode_ != EditMode::None)
		{
			drawing_ = true;
			brushCanvas(x, y);
		}

		// Begin drag if mouse is over image and dragging allowed
		else if (allow_drag_)
		{
			drag_origin_.set(x, y);
			drag_pos_.set(x, y);
			Refresh();
		}
	}

	e.Skip();
}
Beispiel #2
0
// -----------------------------------------------------------------------------
// Called when the mouse pointer is moved within the canvas
// -----------------------------------------------------------------------------
void GfxCanvas::onMouseMovement(wxMouseEvent& e)
{
	bool refresh = false;

	// Check if the mouse is over the image
	int  x        = e.GetPosition().x;
	int  y        = e.GetPosition().y - 2;
	bool on_image = onImage(x, y);
	cursor_pos_   = imageCoords(x, y);
	if (on_image && editing_mode_ != EditMode::None)
	{
		if (cursor_pos_ != prev_pos_)
			generateBrushShadow();
		prev_pos_ = cursor_pos_;
	}
	if (on_image != image_hilight_)
	{
		image_hilight_ = on_image;
		refresh        = true;

		// Update cursor if drag allowed
		if (on_image)
		{
			if (editing_mode_ != EditMode::None)
				SetCursor(wxCursor(wxCURSOR_PENCIL));
			else if (allow_drag_)
				SetCursor(wxCursor(wxCURSOR_SIZING));
		}
		else if (allow_drag_ && !e.LeftIsDown())
			SetCursor(wxNullCursor);
	}
	// Drag
	if (e.LeftIsDown())
	{
		if (editing_mode_ != EditMode::None)
		{
			brushCanvas(x, y);
		}
		else
		{
			drag_pos_.set(e.GetPosition().x, e.GetPosition().y);
			refresh = true;
		}
	}
	else if (e.MiddleIsDown())
	{
		offset_ = offset_ + Vec2d(e.GetPosition().x - mouse_prev_.x, e.GetPosition().y - mouse_prev_.y);
		refresh = true;
	}
	// Right mouse down
	if (e.RightIsDown() && on_image)
		pickColour(x, y);

	if (refresh)
		Refresh();

	mouse_prev_.set(e.GetPosition().x, e.GetPosition().y);
}
Beispiel #3
0
// -----------------------------------------------------------------------------
// Called when the left button is pressed within the canvas
// -----------------------------------------------------------------------------
void GfxCanvas::onMouseRightDown(wxMouseEvent& e)
{
	int x = e.GetPosition().x;
	int y = e.GetPosition().y - 2;

	// Right mouse down
	if (e.RightDown() && onImage(x, y))
		pickColour(x, y);

	e.Skip();
}
Beispiel #4
0
void prefDialog::connectSlots()
{
	connect(ui.okPushButton, SIGNAL(clicked()), this, SLOT(onOK()) );
	connect(ui.cancelPushButton, SIGNAL(clicked()), this, SLOT(onCancel()) );
	connect(ui.selectsoundPushButton, SIGNAL(clicked()), this, SLOT(onSound()) );
	connect(ui.selectPlayerPushButton, SIGNAL(clicked()), this, SLOT(onPlayer()) );
	connect(ui.choosehttpPushButton, SIGNAL(clicked()), this, SLOT(onHttp()) );
	connect(ui.browsePushButton, SIGNAL(clicked()), this, SLOT(onBrowse()) );
	connect(ui.imagePushButton, SIGNAL(clicked()), this, SLOT(onImage()) );
	connect(ui.poolPushButton, SIGNAL(clicked()), this, SLOT(onPool()) );
	connect(ui.resetPushButton, SIGNAL(clicked()), this, SLOT(onReset()) );
}
Beispiel #5
0
void CAppButton::setIcon(const QString on,const QString off,bool bPaint)
{
    QImage img_on,img_off;
    if(bPaint)
    {
        //if(!img_on.load(on))
        {
            QUrl qurl(on);
            img_on.load(":images/app_on.png");
            img_on = img_on.scaled(width(),height(),Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
            QImage onImage(qurl.path());
            //onImage = onImage.scaled(height()*0.4,height()*0.4);
            do
            {
                QPainter painter(&img_on);
                QRect irect=onImage.rect();
                QRect orect=img_on.rect();
                int sx=(orect.width()-irect.width())/2;
                int sy=(orect.height()-irect.height())/4;
                painter.drawImage(sx,sy,onImage,0,0);
            }while(0);
        }

        //if(!img_off.load(off))
        {
            QUrl qurl(off);
            img_off.load(":images/app_off.png");
            img_off = img_off.scaled(width(),height(),Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
            QImage offImage(qurl.path());
            //offImage = offImage.scaled(width()*0.6,height()*0.6,Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
            do{
                QPainter painter(&img_off);
                QRect irect=offImage.rect();
                QRect orect=img_off.rect();
                int sx=(orect.width()-irect.width())/2;
                int sy=(orect.height()-irect.height())/4;
                painter.drawImage(sx,sy,offImage);
            }while(0);
        }
    }
    else
    {
        img_on.load(on);
        img_off.load(off);
    }

    MenuButton::setIcon(img_on,img_off);
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y){
	if(onImage(x, y)) {
		int r, g, b;

		// get rgb from image int r, g, b;
		getImagePixelRGB(x, y, &r, &g, &b);
		
		// get colour magnitudes
		double white, black, grey, blue, yellow, green, red;
		rgbToColourMags(&white, &black, &grey, &green, &red, &blue, &yellow, r, g, b);	
	
		synth.mapColourMags(white, black, grey, green, red, blue, yellow);
	} else {
		synth.fadeOut();
	}
}