示例#1
0
void
SoXipMenuItem::GLRender( SoGLRenderAction* action )
{
	if( action->getState() )
	{
		SbXipMenuStyle style = SoXipMenuStyleElement::get( action->getState() );

		SbColor tColor = isEnabled() ? style.textColor : style.disabledTextColor;
		((SoMaterial *) mTextMaterial)->diffuseColor.setValue( tColor );

		// FIXME
		((SoTranslation *) mIconOffset)->translation.setValue( 0.05, 0.02, 0 );

		// FIXME
		SbVec3f textOffset( 0.2 /* icon width */ + 0.08, 0.15, 0 );
		((SoTranslation *) mTextOffset)->translation.setValue( textOffset );

		glPushAttrib( GL_COLOR_BUFFER_BIT );

		glEnable( GL_ALPHA_TEST );
		glAlphaFunc( GL_GREATER, 0 );

		glEnable( GL_BLEND );
		glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

		SoXipKit::GLRender( action );

		glPopAttrib();
	}
}
示例#2
0
// ---------------------------------------------------------------
// Constructor
//
// Sets up the view settings
//
// Preconditions:
//
// Parameters:
//
// Postconditions:
//
// Returns:
// ---------------------------------------------------------------
SGIView::SGIView(const BRect &frame, const char *name,
	uint32 resize, uint32 flags, TranslatorSettings *settings)
	:	BView(frame, name, resize, flags),
		fSettings(settings)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	SetLowColor(ViewColor());

	BPopUpMenu* menu = new BPopUpMenu("pick compression");

	uint32 currentCompression = fSettings->SetGetInt32(SGI_SETTING_COMPRESSION);
	// create the menu items with the various compression methods
	add_menu_item(menu, SGI_COMP_NONE, "None", currentCompression);
//	menu->AddSeparatorItem();
	add_menu_item(menu, SGI_COMP_RLE, "RLE", currentCompression);

// DON'T turn this on, it's so slow that I didn't wait long enough
// the one time I tested this. So I don't know if the code even works.
// Supposedly, this would look for an already written scanline, and
// modify the scanline tables so that the current row is not written
// at all...

//	add_menu_item(menu, SGI_COMP_ARLE, "Agressive RLE", currentCompression);

	BRect menuFrame = Bounds();
	menuFrame.bottom = menuFrame.top + menu->Bounds().Height();
	fCompressionMF = new BMenuField(menuFrame, "compression",
									"Use compression:", menu, true/*,
									B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP*/);
	if (fCompressionMF->MenuBar())
		fCompressionMF->MenuBar()->ResizeToPreferred();
	fCompressionMF->ResizeToPreferred();

	// figure out where the text ends
	font_height fh;
	be_bold_font->GetHeight(&fh);
	float xbold, ybold;
	xbold = fh.descent + 1;
	ybold = fh.ascent + fh.descent * 2 + fh.leading;

	font_height plainh;
	be_plain_font->GetHeight(&plainh);
	float yplain;
	yplain = plainh.ascent + plainh.descent * 2 + plainh.leading;

	// position the menu field below all the text we draw in Draw()
	BPoint textOffset(0.0, yplain * 2 + ybold);
	fCompressionMF->MoveTo(textOffset);

	AddChild(fCompressionMF);

	ResizeToPreferred();
}
示例#3
0
QRect QCommandLinkButtonPrivate::titleRect() const
{
    Q_Q(const QCommandLinkButton);
    QRect r = q->rect().adjusted(textOffset(), topMargin(), -rightMargin(), 0);
    if (description.isEmpty())
    {
        QFontMetrics fm(titleFont());
        r.setTop(r.top() + qMax(0, (q->icon().actualSize(q->iconSize()).height()
                 - fm.height()) / 2));
    }

    return r;
}
示例#4
0
// Calculates the height of the description text based on widget width
int QCommandLinkButtonPrivate::descriptionHeight(int widgetWidth) const
{
    // Calc width of actual paragraph
    int lineWidth = widgetWidth - textOffset() - rightMargin();

    qreal descriptionheight = 0;
    if (!description.isEmpty()) {
        QTextLayout layout(description);
        layout.setFont(descriptionFont());
        layout.beginLayout();
        while (true) {
            QTextLine line = layout.createLine();
            if (!line.isValid())
                break;
            line.setLineWidth(lineWidth);
            line.setPosition(QPointF(0, descriptionheight));
            descriptionheight += line.height();
        }
        layout.endLayout();
    }
    return qRound(descriptionheight);
}
示例#5
0
QRect QCommandLinkButtonPrivate::descriptionRect() const
{
    Q_Q(const QCommandLinkButton);
    return q->rect().adjusted(textOffset(), descriptionOffset(),
                              -rightMargin(), -bottomMargin());
}
示例#6
0
QRect QCommandLinkButtonPrivate::titleRect() const
{
    Q_Q(const QCommandLinkButton);
    return q->rect().adjusted(textOffset(), topMargin(),
                              -rightMargin(), 0);
}
void GuiGameListMenuCtrl::onRender(Point2I offset, const RectI &updateRect)
{
   GuiGameListMenuProfile * profile = (GuiGameListMenuProfile *) mProfile;

   F32 xScale = (float) getWidth() / profile->getRowWidth();

   bool profileHasIcons = profile->hasArrows();

   S32 rowHeight = profile->getRowHeight();

   Point2I currentOffset = offset;
   Point2I extent = getExtent();
   Point2I rowExtent(extent.x, rowHeight);
   Point2I textOffset(profile->mTextOffset.x * xScale, profile->mTextOffset.y);
   Point2I textExtent(extent.x - textOffset.x, rowHeight);
   Point2I iconExtent, iconOffset(0.0f, 0.0f);
   if (profileHasIcons)
   {
      iconExtent = profile->getIconExtent();

      // icon is centered vertically plus any specified offset
      S32 iconOffsetY = (rowHeight - iconExtent.y) >> 1;
      iconOffsetY += profile->mIconOffset.y;
      iconOffset = Point2I(profile->mIconOffset.x * xScale, iconOffsetY);
   }
   for (Vector<Row *>::iterator row = mRows.begin(); row < mRows.end(); ++row)
   {
      if (row != mRows.begin())
      {
         // rows other than the first can have padding above them
         currentOffset.y += (*row)->mHeightPad;
         currentOffset.y += rowHeight;
      }

      // select appropriate colors and textures
      ColorI fontColor;
      U32 buttonTextureIndex;
      S32 iconIndex = (*row)->mIconIndex;
      bool useHighlightIcon = (*row)->mUseHighlightIcon;
      if (! (*row)->mEnabled)
      {
         buttonTextureIndex = Profile::TEX_DISABLED;
         fontColor = profile->mFontColorNA;
      }
      else if (row == &mRows[mSelected])
      {
         if (iconIndex != NO_ICON)
         {
            iconIndex++;
         }
         buttonTextureIndex = Profile::TEX_SELECTED;
         fontColor = profile->mFontColorSEL;
      }
      else if ((mHighlighted != NO_ROW) && (row == &mRows[mHighlighted]))
      {
         if (iconIndex != NO_ICON && useHighlightIcon)
         {
            iconIndex++;
         }
         buttonTextureIndex = Profile::TEX_HIGHLIGHT;
         fontColor = profile->mFontColorHL;
      }
      else
      {
         buttonTextureIndex = Profile::TEX_NORMAL;
         fontColor = profile->mFontColor;
      }

      // render the row bitmap
      GFX->getDrawUtil()->clearBitmapModulation();
      GFX->getDrawUtil()->drawBitmapStretchSR(profile->mTextureObject, RectI(currentOffset, rowExtent), profile->getBitmapArrayRect(buttonTextureIndex));

      // render the row icon if it has one
      if ((iconIndex != NO_ICON) && profileHasIcons && (! profile->getBitmapArrayRect((U32)iconIndex).extent.isZero()))
      {
         iconIndex += Profile::TEX_FIRST_ICON;
         GFX->getDrawUtil()->clearBitmapModulation();
         GFX->getDrawUtil()->drawBitmapStretchSR(profile->mTextureObject, RectI(currentOffset + iconOffset, iconExtent), profile->getBitmapArrayRect(iconIndex));
      }

      // render the row text
      GFX->getDrawUtil()->setBitmapModulation(fontColor);
      renderJustifiedText(currentOffset + textOffset, textExtent, (*row)->mLabel);
   }

   if (mDebugRender)
   {
      onDebugRender(offset);
   }

   renderChildControls(offset, updateRect);
}