Ejemplo n.º 1
0
void TransparentWindow::keyPressEvent(QKeyEvent *event)
{
    if(event->key() == Qt::Key_Escape) {
        emit backColor();
        hide();
    }
}
Ejemplo n.º 2
0
// Render
/*virtual*/ void IntroState::Render(void)
{
	SGD::GraphicsManager*	pGraphics = SGD::GraphicsManager::GetInstance();

	// Use the game's font
	const BitmapFont* pFont = Game::GetInstance()->GetFont();

	SGD::Color backColor(transBack, 255, 255, 255);
	// Draw the background image
	pGraphics->DrawTexture(m_hBackgroundImage, { 0, 0 }, 0.0f, {}, backColor);

	if (IntroTimer.GetTime() < 20.0f)
	{
		SGD::Color colorTextOne(transTextFirst, 100, 0, 0);

		pFont->Draw("2 Weeks Later", { Game::GetInstance()->GetScreenWidth() / 2 - 150, Game::GetInstance()->GetScreenHeight() / 2 - 25 }, 1.0f, colorTextOne);

		SGD::Color colorText(transText, 100, 0, 0);

		pFont->Draw("Trying to survive", { Game::GetInstance()->GetScreenWidth() / 2 - 200, Game::GetInstance()->GetScreenHeight() / 2 - 25}, 1.0f, colorText);
	}

	if (SGD::InputManager::GetInstance()->IsControllerConnected(0) == false)
		pFont->Draw("Press 'ESC' to continue", { Game::GetInstance()->GetScreenWidth() / 2 - 175, Game::GetInstance()->GetScreenHeight() - 25 }, .5f, { 100, 0, 0 });
	else
		pFont->Draw("Press 'Start' to continue", { Game::GetInstance()->GetScreenWidth() / 2 - 175, Game::GetInstance()->GetScreenHeight() - 25 }, .5f, { 100, 0, 0 });


	// Align text based on window width
	float width = Game::GetInstance()->GetScreenWidth();

	// Display the mode title & its animation
	pFont->Draw("Story Mode", { (width - (10 * 25 * 3.0f)) / 2, 10 }, 3.0f, { 255, 255, 255 });

	// Display skip input
	std::string output0 = SGD::InputManager::GetInstance()->IsControllerConnected(0) == false
		? "Press 'Esc' to skip"
		: "Press 'Start' to skip";
	pFont->Draw(output0.c_str(), { (width - (output0.length() * 25 * 1.0f)) / 2, 100 }, 1.0f, { 0, 0, 0 });

	/*
	AnimationManager::GetInstance()->Render(animation, { width - 160.0f, 50 });



	// Setup text render data
	float left_start	= 10.0F;
	float y_offset		= 210.0f;
	float scale			= 1.0f;


	// story mode text
	std::string output1 = "HELLO WORLD!";
	std::string output2 = "GOODBYE WORLD!";


	pFont->Draw(output1.c_str(), { left_start, starting_y + (y_offset * 0) }, scale, { 0, 255, 0 });
	pFont->Draw(output2.c_str(), { left_start, starting_y + (y_offset * 1) }, scale, { 255, 0, 0 });
	*/
}
Ejemplo n.º 3
0
void WindowTree::onRenderItem( RenderContext & context, const RectInt & window, PointInt & pos, Item * pItem )
{
	WindowStyle * pStyle = windowStyle();
	ASSERT( pStyle );
	Font * pFont = windowStyle()->font();
	ASSERT( pFont );

	// get the depth of this item
	int depth = itemDepth( pItem );
	// determine the X position based on it's depth
	pos.x = window.left + (depth * m_Indent);
	// get the size of the label text
	SizeInt labelSize( pFont->size( pItem->sLabel ) );
	// determine the height of this item
	int height = (int)(labelSize.height + TREE_ITEM_BUFFER);
	RectInt itemRect( window.left, pos.y, window.right, pos.y + height );

	// check if this item is highlighted or not
	if ( m_CursorInWindow && itemRect.inRect( m_LastCursorPosition ) )
		onHighlight( pItem );

	PrimitiveMaterial::push( context.display(), WHITE, PrimitiveMaterial::ALPHA );

	if ( pItem->dwFlags & BUTTON )
	{
		bool expanded = (pItem->dwFlags & EXPANDED) != 0;
		Color backColor( expanded ? pStyle->backColor() * TREE_SHADE_COLOR : pStyle->backColor() );
		Color shadeColor( expanded ? pStyle->borderColor() * TREE_LIGHT_COLOR : pStyle->borderColor() * TREE_SHADE_COLOR );
		Color lightColor( expanded ? pStyle->borderColor() * TREE_SHADE_COLOR : pStyle->borderColor() * TREE_LIGHT_COLOR );

		// render the button
		pushBackground( context, itemRect, backColor, TREE_BUTTON_STYLE, TREE_BUTTON_BORDER );
		pushBorder( context, itemRect, lightColor, shadeColor, TREE_BUTTON_STYLE, TREE_BUTTON_BORDER );

		// draw glow around this object if the mouse is currently over this button
		if ( m_pCursorOver == pItem )
			pushGlow( context, itemRect, TREE_GLOW_SIZE, TREE_GLOW_INNER, TREE_GLOW_OUTER, TREE_BUTTON_STYLE, TREE_BUTTON_BORDER );

		// place the label in the center of the button
		PointInt labelPos( itemRect.center() - PointInt( labelSize.width / 2, labelSize.height / 2 ) );
		// draw the label
		Font::push( context.display(), pFont, labelPos, pItem->sLabel, pItem->cColor );
	}
	else
	{
		if ( m_pSelected == pItem )
			pushBackground( context, itemRect, pStyle->highColor(), 0, 0 );
		if ( m_pCursorOver == pItem )
			pushGlow( context, itemRect, TREE_GLOW_SIZE, TREE_GLOW_INNER, TREE_GLOW_OUTER, 0, 0 );

		PointInt labelPos( pos.x, (int)(pos.y + (TREE_ITEM_BUFFER / 2)) );
		// render the label text`
		Font::push( context.display(), pFont, labelPos, pItem->sLabel, pItem->cColor );

	}


	// move y down
	pos.y += (int)(height + WINDOW_TREE_SPACING);
}
Ejemplo n.º 4
0
void WeaponInfo::draw()
{
	/*
	Color backColor(200,200,200,80);
	graphics.drawRect(
		backColor,
		x, y,
		xmax,
		y + 48);
		*/

	Image *currImage;
	for (unsigned i = 0; i < weapons.size(); i++) {
		if (i == currWeapon) {
			Color backColor(0,128,32,100);
			graphics.drawRect(
				backColor,
				x + i*48, y,
				x + (i+1)*48,
				y + 48);
		}

		currImage = images.getImage(weapons[i].name.c_str());
		if (currImage->getHeight() <= 48) {
			graphics.drawImage(currImage,x+24 + i*48,y+24);
		}
		graphics.drawText(retprintf("%i", weapons[i].ammo).c_str(), x+24+i*48, y+48);
	}

}
Ejemplo n.º 5
0
void TransparentWindow::mouseReleaseEvent(QMouseEvent *event)
{
    if(event->button() == Qt::LeftButton){
        emit saveColor();
    } else {
        emit backColor();
    }
    hide();
}
int GraphView::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = CommonView::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 6)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 6;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< GraphWidget::Orientation*>(_v) = orientation(); break;
        case 1: *reinterpret_cast< GraphWidget::Mode*>(_v) = mode(); break;
        case 2: *reinterpret_cast< int*>(_v) = timeLinesCount(); break;
        case 3: *reinterpret_cast< int*>(_v) = valueLinesCount(); break;
        case 4: *reinterpret_cast< QColor*>(_v) = cursorColor(); break;
        case 5: *reinterpret_cast< QColor*>(_v) = linesColor(); break;
        case 6: *reinterpret_cast< QColor*>(_v) = textColor(); break;
        case 7: *reinterpret_cast< QColor*>(_v) = backColor(); break;
        case 8: *reinterpret_cast< QColor*>(_v) = selectionColor(); break;
        case 9: *reinterpret_cast< Plots*>(_v) = plots(); break;
        }
        _id -= 10;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setOrientation(*reinterpret_cast< GraphWidget::Orientation*>(_v)); break;
        case 1: setMode(*reinterpret_cast< GraphWidget::Mode*>(_v)); break;
        case 2: setTimeLinesCount(*reinterpret_cast< int*>(_v)); break;
        case 3: setValueLinesCount(*reinterpret_cast< int*>(_v)); break;
        case 4: setCursorColor(*reinterpret_cast< QColor*>(_v)); break;
        case 5: setLinesColor(*reinterpret_cast< QColor*>(_v)); break;
        case 6: setTextColor(*reinterpret_cast< QColor*>(_v)); break;
        case 7: setBackColor(*reinterpret_cast< QColor*>(_v)); break;
        case 8: setSelectionColor(*reinterpret_cast< QColor*>(_v)); break;
        case 9: setPlots(*reinterpret_cast< Plots*>(_v)); break;
        }
        _id -= 10;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 10;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Ejemplo n.º 7
0
void EmulationHandler::load( const Profile& prof) {

    // try to read the fontconfig from the profile
    QString aFont = prof.readEntry( "Font" );
    int aFontSize = prof.readNumEntry( "FontSize" );
    // use defaults from qpe.conf if no profile yet
    if ( ( aFontSize == -1 ) || ( aFont == QString::null ) )
    {
        Config c( "qpe" );
        c.setGroup( "Appearance" );
        aFont = c.readEntry( "FixedFontFamily", "Fixed" );
        aFontSize = c.readNumEntry( "FixedFontSize", 7 );
    }
    QFont font( aFont, aFontSize );
    font.setFixedPitch( TRUE );
    m_teWid->setVTFont( font );

    int num = prof.readNumEntry("Color", 0);
    setColor( foreColor(num), backColor(num) );
    m_teWid->setBackgroundColor(backColor(num) );

    int term = prof.readNumEntry("Terminal", Profile::Linux ) ;
    switch(term) {
    default:
    case Profile::VT102:
    case Profile::VT100:
        m_teEmu->setKeytrans("vt100.keytab");
        break;
    case Profile::Linux:
        m_teEmu->setKeytrans("linux.keytab");
        break;
    case Profile::XTerm:
        m_teEmu->setKeytrans("default.Keytab");
        break;
    }
}
Ejemplo n.º 8
0
    /**
     * Constructs the default theme
     */
    Theme::Theme() {
        Color backColor(0.27, 0.44, 0.58, 1.0);
        Color foreColor(1.0, 1.0, 1.0, 1.0);

        Color backSelector(1.9, 1.0, 1.0, 0.3);
        Color foreSelector(1.1, 1.1, 1.0, 1.0);

        this->m_window = new ColorWindow();
        this->m_panel = new ColorWindow(true, backColor, foreColor, 0.7, 4.0);
        this->m_panelSelector = new ColorWindow(true, backSelector, foreSelector, 1.5, 4.0);
        this->m_panelTitle = new ColorWindow(true, backColor, foreColor, 0.0, 4.0);
        this->m_panelTitleText = new ColorWindow(true, Color(), Color(1.0, 1.0, 1.0, 1.0), 0.0, 0.0);
        this->m_preview = new ColorWindow(true, backColor, foreColor, 0.7, 4.0);
        this->m_previewTitle = new ColorWindow(true, Color(0.0, 0.0, 1.0, 0.0), Color(1.0, 1.0, 1.0, 0.0), 1.0, 0.0);
        this->m_previewTitleText = new ColorWindow(true, Color(), Color(), 0.0, 0.0);
        this->m_previewSelector = new ColorWindow(true, backSelector, foreSelector, 2.0, 4.0);
        this->m_previewSelectorClose = new ColorWindow(true, Color(0.0, 0.50, 0.0, 1.0), foreColor, 4.0, 4.0);

    }
Ejemplo n.º 9
0
Gdiplus::Brush* CFDE_GdiDevice::CreateGdiBrush(IFDE_Brush* pBrush) {
  if (pBrush == NULL) {
    return NULL;
  }
  Gdiplus::Brush* pGdiBrush = NULL;
  switch (pBrush->GetType()) {
    case FDE_BRUSHTYPE_Solid: {
      IFDE_SolidBrush* pSolidBrush = (IFDE_SolidBrush*)pBrush;
      Gdiplus::Color gdiColor((Gdiplus::ARGB)pSolidBrush->GetColor());
      pGdiBrush = new Gdiplus::SolidBrush(gdiColor);
    } break;
    case FDE_BRUSHTYPE_Hatch: {
      IFDE_HatchBrush* pHatchBrush = (IFDE_HatchBrush*)pBrush;
      Gdiplus::Color foreColor((Gdiplus::ARGB)pHatchBrush->GetColor(TRUE));
      Gdiplus::Color backColor((Gdiplus::ARGB)pHatchBrush->GetColor(FALSE));
      Gdiplus::HatchStyle hatchStyle =
          (Gdiplus::HatchStyle)pHatchBrush->GetHatchStyle();
      pGdiBrush = new Gdiplus::HatchBrush(hatchStyle, foreColor, backColor);
    } break;
    case FDE_BRUSHTYPE_Texture: {
      IFDE_TextureBrush* pTextureBrush = (IFDE_TextureBrush*)pBrush;
      CFDE_GdiImage* pImgHolder = (CFDE_GdiImage*)pTextureBrush->GetImage();
      Gdiplus::Image* pGdiImage = pImgHolder ? pImgHolder->m_pImage : NULL;
      Gdiplus::WrapMode wrapMode =
          (Gdiplus::WrapMode)pTextureBrush->GetWrapMode();
      pGdiBrush = new Gdiplus::TextureBrush(pGdiImage, wrapMode);
    } break;
    case FDE_BRUSHTYPE_LinearGradient: {
      IFDE_LinearGradientBrush* pLinearBrush =
          (IFDE_LinearGradientBrush*)pBrush;
      Gdiplus::WrapMode wrapMode =
          (Gdiplus::WrapMode)pLinearBrush->GetWrapMode();
      CFX_PointF ptStart, ptEnd;
      pLinearBrush->GetLinearPoints(ptStart, ptEnd);
      FX_ARGB crStart, crEnd;
      pLinearBrush->GetLinearColors(crStart, crEnd);
      pGdiBrush = new Gdiplus::LinearGradientBrush(
          (const Gdiplus::PointF&)ptStart, (const Gdiplus::PointF&)ptEnd,
          (const Gdiplus::Color&)crStart, (const Gdiplus::Color&)crEnd);
    } break;
  }
  return pGdiBrush;
}
int MessageListScript::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = MessageList::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    
#ifndef QT_NO_PROPERTIES
     if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QColor*>(_v) = criColor(); break;
        case 1: *reinterpret_cast< QColor*>(_v) = attColor(); break;
        case 2: *reinterpret_cast< QColor*>(_v) = normColor(); break;
        case 3: *reinterpret_cast< QColor*>(_v) = backColor(); break;
        case 4: *reinterpret_cast< vtlmeta::types::NamedList*>(_v) = getList(); break;
        case 5: *reinterpret_cast< QString*>(_v) = sourcerName(); break;
        case 6: *reinterpret_cast< QString*>(_v) = toolTip(); break;
        case 7: *reinterpret_cast< VISIBLE*>(_v) = getVisible(); break;
        case 8: *reinterpret_cast< bool*>(_v) = useMask(); break;
        case 9: *reinterpret_cast< QString*>(_v) = globalListName(); break;
        case 10: *reinterpret_cast< QFont*>(_v) = font(); break;
        case 11: *reinterpret_cast< QRect*>(_v) = geometry(); break;
        case 12: *reinterpret_cast< Shape*>(_v) = frameShape(); break;
        case 13: *reinterpret_cast< Shadow*>(_v) = frameShadow(); break;
        case 14: *reinterpret_cast< int*>(_v) = lineWidth(); break;
        case 15: *reinterpret_cast< int*>(_v) = midLineWidth(); break;
        case 16: *reinterpret_cast< int*>(_v) = margin(); break;
        case 17: *reinterpret_cast< vtlmeta::types::NamedList*>(_v) = getFuncList(); break;
        }
        _id -= 18;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setCriColor(*reinterpret_cast< QColor*>(_v)); break;
        case 1: setAttColor(*reinterpret_cast< QColor*>(_v)); break;
        case 2: setNormColor(*reinterpret_cast< QColor*>(_v)); break;
        case 3: setBackColor(*reinterpret_cast< QColor*>(_v)); break;
        case 4: setList(*reinterpret_cast< vtlmeta::types::NamedList*>(_v)); break;
        case 5: setSourcerName(*reinterpret_cast< QString*>(_v)); break;
        case 6: setToolTip(*reinterpret_cast< QString*>(_v)); break;
        case 7: setVisible(*reinterpret_cast< VISIBLE*>(_v)); break;
        case 8: setUseMask(*reinterpret_cast< bool*>(_v)); break;
        case 9: setGlobalListName(*reinterpret_cast< QString*>(_v)); break;
        case 10: setFont(*reinterpret_cast< QFont*>(_v)); break;
        case 11: setGeometry(*reinterpret_cast< QRect*>(_v)); break;
        case 12: setFrameShape(*reinterpret_cast< Shape*>(_v)); break;
        case 13: setFrameShadow(*reinterpret_cast< Shadow*>(_v)); break;
        case 14: setLineWidth(*reinterpret_cast< int*>(_v)); break;
        case 15: setMidLineWidth(*reinterpret_cast< int*>(_v)); break;
        case 16: setMargin(*reinterpret_cast< int*>(_v)); break;
        case 17: setFuncList(*reinterpret_cast< vtlmeta::types::NamedList*>(_v)); break;
        }
        _id -= 18;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 18;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 18;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 18;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 18;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 18;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 18;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Ejemplo n.º 11
0
	{
		if (!g_consoleFlag)
		{
			return;
		}

		static bool stringRectSet = false;
		static CRect stringRect;

		if (!stringRectSet)
		{
			TheFonts->GetStringMetrics(L"a", 16.0f, 1.0f, "Lucida Console", stringRect);
		}

		CRect backRect(0.0f, 0.0f, GetScreenResolutionX(), (16.0f * 25) + 16.0f);
		CRGBA backColor(0, 0x2b, 0x36, 220);
		CRGBA frontColor(0xee, 0xe8, 0xd5);

		TheFonts->DrawRectangle(backRect, backColor);

		backRect.SetRect(backRect.fX1, backRect.fY2, backRect.fX2, backRect.fY2 + 5.0f);
		backColor.red *= 0.8;
		backColor.green *= 0.8;
		backColor.blue *= 0.8;
		backColor.alpha = 250;

		TheFonts->DrawRectangle(backRect, backColor);

		for (int i = 0; i < 25; i++)
		{
			wchar_t str[2048];
Ejemplo n.º 12
0
int Text::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = VtlWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: { QString _r = getText();
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 1: setText((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 2;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QColor*>(_v) = backColor(); break;
        case 1: *reinterpret_cast< QColor*>(_v) = normColor(); break;
        case 2: *reinterpret_cast< QString*>(_v) = getText(); break;
        case 3: *reinterpret_cast< bool*>(_v) = useMask(); break;
        case 4: *reinterpret_cast< QString*>(_v) = sourcerName(); break;
        case 5: *reinterpret_cast< QString*>(_v) = toolTip(); break;
        case 6: *reinterpret_cast< VISIBLE*>(_v) = getVisible(); break;
        case 7: *reinterpret_cast< QFont*>(_v) = font(); break;
        case 8: *reinterpret_cast< QRect*>(_v) = geometry(); break;
        case 9: *reinterpret_cast< Shape*>(_v) = frameShape(); break;
        case 10: *reinterpret_cast< Shadow*>(_v) = frameShadow(); break;
        case 11: *reinterpret_cast< int*>(_v) = lineWidth(); break;
        case 12: *reinterpret_cast< int*>(_v) = midLineWidth(); break;
        case 13: *reinterpret_cast< int*>(_v) = margin(); break;
        }
        _id -= 14;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setBackColor(*reinterpret_cast< QColor*>(_v)); break;
        case 1: setNormColor(*reinterpret_cast< QColor*>(_v)); break;
        case 2: setText(*reinterpret_cast< QString*>(_v)); break;
        case 3: setUseMask(*reinterpret_cast< bool*>(_v)); break;
        case 4: setSourcerName(*reinterpret_cast< QString*>(_v)); break;
        case 5: setToolTip(*reinterpret_cast< QString*>(_v)); break;
        case 6: setVisible(*reinterpret_cast< VISIBLE*>(_v)); break;
        case 7: setFont(*reinterpret_cast< QFont*>(_v)); break;
        case 8: setGeometry(*reinterpret_cast< QRect*>(_v)); break;
        case 9: setFrameShape(*reinterpret_cast< Shape*>(_v)); break;
        case 10: setFrameShadow(*reinterpret_cast< Shadow*>(_v)); break;
        case 11: setLineWidth(*reinterpret_cast< int*>(_v)); break;
        case 12: setMidLineWidth(*reinterpret_cast< int*>(_v)); break;
        case 13: setMargin(*reinterpret_cast< int*>(_v)); break;
        }
        _id -= 14;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 14;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 14;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 14;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 14;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 14;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 14;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Ejemplo n.º 13
0
void FilmstripFrameHeadGadget::drawOnionSkinSelection(QPainter &p, const QColor &lightColor, const QColor &darkColor)
{
	int currentRow = getCurrentFrame();

	TPixel frontPixel, backPixel;
	bool inksOnly;
	Preferences::instance()->getOnionData(frontPixel, backPixel, inksOnly);
	QColor frontColor((int)frontPixel.r, (int)frontPixel.g, (int)frontPixel.b, 128);
	QColor backColor((int)backPixel.r, (int)backPixel.g, (int)backPixel.b, 128);

	OnionSkinMask osMask = TApp::instance()->getCurrentOnionSkin()->getOnionSkinMask();
	int mosCount = osMask.getMosCount();

	int i;
	//OnionSkinの円の左上座標のy値
	int onionDotYPos = m_dy / 2 - 5;

	p.setPen(Qt::red);
	//--- OnionSkinが有効なら実線、無効なら点線
	if (!osMask.isEnabled()) {
		QPen currentPen = p.pen();
		currentPen.setStyle(Qt::DashLine);
		currentPen.setColor(QColor(128, 128, 128, 255));
		p.setPen(currentPen);
	}
	//カレントフレームにOnionSkinを伸ばすハンドルを描画
	{
		int angle180 = 16 * 180;
		QRectF handleRect(0, 0, 30, 30);

		//上向きのハンドル:1フレーム目のときは描画しない
		if (currentRow > 0) {
			int y0 = index2y(currentRow) - 15;
			p.setBrush(QBrush(backColor));
			p.drawChord(handleRect.translated(0, y0), 0, angle180);
		}

		//下向きのハンドル:最終フレームの時は描画しない
		std::vector<TFrameId> fids;
		m_filmstrip->getLevel()->getFids(fids);
		int frameCount = (int)fids.size();
		if (currentRow < frameCount - 1) {
			int y1 = index2y(currentRow + 1) - 15;
			p.setBrush(QBrush(frontColor));
			p.drawChord(handleRect.translated(0, y1), angle180, angle180);
		}

		//--- 動く Onion Skinの描画 その1
		//先に線を描く
		//まず OnionSkinの最大/最小値を取得
		int minMos = 0;
		int maxMos = 0;
		for (i = 0; i < mosCount; i++) {
			int mos = osMask.getMos(i);
			if (minMos > mos)
				minMos = mos;
			if (maxMos < mos)
				maxMos = mos;
		}
		p.setBrush(Qt::NoBrush);
		//min/maxが更新されていたら、線を描く
		if (minMos < 0) //上方向に伸ばす線
		{
			int y0 = index2y(currentRow + minMos) + onionDotYPos + 10; //10は●の直径
			int y1 = index2y(currentRow) - 15;
			p.drawLine(15, y0, 15, y1);
		}
		if (maxMos > 0) //下方向に伸ばす線
		{
			int y0 = index2y(currentRow + 1) + 15;
			int y1 = index2y(currentRow + maxMos) + onionDotYPos;
			p.drawLine(15, y0, 15, y1);
		}
	}

	//--- Fix Onion Skinの描画
	for (i = 0; i < osMask.getFosCount(); i++) {
		int fos = osMask.getFos(i);
		//if(fos == currentRow) continue;
		int y = index2y(fos) + onionDotYPos;
		p.setPen(Qt::red);
		//OnionSkinがDisableなら中空にする
		p.setBrush(osMask.isEnabled() ? QBrush(QColor(0, 255, 255, 128)) : Qt::NoBrush);
		p.drawEllipse(0, y, 10, 10);
	}
	//---

	//--- 動く Onion Skinの描画 その2

	//続いて、各OnionSkinの●を描く
	p.setPen(Qt::red);
	for (i = 0; i < mosCount; i++) {
		//mosはOnionSkinの描かれるフレームのオフセット値
		int mos = osMask.getMos(i);
		//100312 iwasawa ハイライトする場合は後で描くのでスキップする
		if (currentRow + mos == m_highlightedMosFrame)
			continue;

		int y = index2y(currentRow + mos) + onionDotYPos;

		p.setBrush(mos < 0 ? backColor : frontColor);

		p.drawEllipse(10, y, 10, 10);
	}

	//Fix Onion Skin ハイライトの描画 FixOnionSkinがマウスが乗ってハイライトされていて、
	//かつ 現在のフレームでないときに描画
	if (m_highlightedFosFrame >= 0 && m_highlightedFosFrame != currentRow) {
		p.setPen(QColor(255, 128, 0));
		p.setBrush(QBrush(QColor(255, 255, 0, 200)));
		p.drawEllipse(0, index2y(m_highlightedFosFrame) + onionDotYPos, 10, 10);
	}

	//通常のOnion Skin ハイライトの描画
	if (m_highlightedMosFrame >= 0 && m_highlightedMosFrame != currentRow) {
		p.setPen(QColor(255, 128, 0));
		p.setBrush(QBrush(QColor(255, 255, 0, 200)));
		p.drawEllipse(10, index2y(m_highlightedMosFrame) + onionDotYPos, 10, 10);
	}
}
Ejemplo n.º 14
0
void RowArea::drawOnionSkinSelection(QPainter &p)
{
	TApp *app = TApp::instance();
	OnionSkinMask osMask = app->getCurrentOnionSkin()->getOnionSkinMask();

	TXsheet *xsh = app->getCurrentScene()->getScene()->getXsheet();
	assert(xsh);
	int currentRow = m_viewer->getCurrentRow();

	// get onion colors
	TPixel frontPixel, backPixel;
	bool inksOnly;
	Preferences::instance()->getOnionData(frontPixel, backPixel, inksOnly);
	QColor frontColor((int)frontPixel.r, (int)frontPixel.g, (int)frontPixel.b, 128);
	QColor backColor((int)backPixel.r, (int)backPixel.g, (int)backPixel.b, 128);

	int onionDotDiam = 8;
	int onionHandleDiam = RowHeight - 1;
	int onionDotYPos = (RowHeight - onionDotDiam) / 2;

	// If the onion skin is disabled, draw dash line instead.
	if (osMask.isEnabled())
		p.setPen(Qt::red);
	else
	{
		QPen currentPen = p.pen();
		currentPen.setStyle(Qt::DashLine);
		currentPen.setColor(QColor(128, 128, 128, 255));
		p.setPen(currentPen);
	}

	// Draw onion skin extender handles.
	QRectF handleRect(3, m_viewer->rowToY(currentRow) + 1, onionHandleDiam, onionHandleDiam);
	int angle180 = 16 * 180;
	p.setBrush(QBrush(backColor));
	p.drawChord(handleRect, 0, angle180);
	p.setBrush(QBrush(frontColor));
	p.drawChord(handleRect, angle180, angle180);

	//-- draw movable onions

	// draw line between onion skin range
	int minMos = 0;
	int maxMos = 0;
	int mosCount = osMask.getMosCount();
	for (int i = 0; i < mosCount; i++) {
		int mos = osMask.getMos(i);
		if (minMos > mos)
			minMos = mos;
		if (maxMos < mos)
			maxMos = mos;
	}
	p.setBrush(Qt::NoBrush);
	if (minMos < 0) // previous frames
	{
		int y0 = m_viewer->rowToY(currentRow + minMos) + onionDotYPos + onionDotDiam;
		int y1 = m_viewer->rowToY(currentRow);
		p.drawLine(onionDotDiam*1.5, y0, onionDotDiam*1.5, y1);
	}
	if (maxMos > 0) // foward frames
	{
		int y0 = m_viewer->rowToY(currentRow + 1);
		int y1 = m_viewer->rowToY(currentRow + maxMos) + onionDotYPos;
		p.drawLine(onionDotDiam*1.5, y0, onionDotDiam*1.5, y1);
	}

	// draw onion skin dots
	p.setPen(Qt::red);
	for (int i = 0; i < mosCount; i++) {
		// mos : frame offset from the current frame
		int mos = osMask.getMos(i);
		// skip drawing if the frame is under the mouse cursor
		if (m_showOnionToSet == Mos && currentRow + mos == m_row)
			continue;
		int y = m_viewer->rowToY(currentRow + mos) + onionDotYPos;

		if (osMask.isEnabled())
			p.setBrush(mos < 0 ? backColor : frontColor);
		else
			p.setBrush(Qt::NoBrush);
		p.drawEllipse(onionDotDiam, y, onionDotDiam, onionDotDiam);
	}

	//-- draw fixed onions
	for (int i = 0; i < osMask.getFosCount(); i++)
	{
		int fos = osMask.getFos(i);
		if (fos == currentRow) continue;
		// skip drawing if the frame is under the mouse cursor
		if (m_showOnionToSet == Fos && fos == m_row)
			continue;
		int y = m_viewer->rowToY(fos) + onionDotYPos;

		if (osMask.isEnabled())
			p.setBrush(QBrush(QColor(0, 255, 255, 128)));
		else
			p.setBrush(Qt::NoBrush);
		p.drawEllipse(0, y, onionDotDiam, onionDotDiam);
	}

	//-- draw highlighted onion
	if (m_showOnionToSet != None)
	{
		int y = m_viewer->rowToY(m_row) + onionDotYPos;
		int xPos = (m_showOnionToSet == Fos) ? 0 : onionDotDiam;
		p.setPen(QColor(255, 128, 0));
		p.setBrush(QBrush(QColor(255, 255, 0, 200)));
		p.drawEllipse(xPos, y, onionDotDiam, onionDotDiam);
	}
}