Exemple #1
0
void GuiTabBookCtrl::renderTabs( const Point2I &offset, const RectI &tabRect )
{
   // If the tab size is zero, don't render tabs,
   //  assuming it's a tab-less book
   if( mPages.empty() || mTabHeight <= 0 )
      return;

   for( S32 i = 0; i < mPages.size(); i++ )
   {
      const TabHeaderInfo &currentTabInfo = mPages[i];
      RectI tabBounds = mPages[i].TabRect;
      tabBounds.point += offset;
      GuiTabPageCtrl *tab = mPages[i].Page;
      if( tab != NULL )
         renderTab( tabBounds, tab );

      // If we're on the last tab, draw the nice end piece
      if( i + 1 == mPages.size() )
      {
         Point2I tabEndPoint = Point2I(currentTabInfo.TabRect.point.x + currentTabInfo.TabRect.extent.x + offset.x, currentTabInfo.TabRect.point.y + offset.y);
         Point2I tabEndExtent = Point2I((tabRect.point.x + tabRect.extent.x) - tabEndPoint.x, currentTabInfo.TabRect.extent.y);
         RectI tabEndRect = RectI(tabEndPoint,tabEndExtent);

         GFX->setClipRect( tabEndRect );

         // As it turns out the last tab can be outside the viewport in which
         // case trying to render causes a DX assert. Could be better if 
         // setClipRect returned a bool.
         if ( GFX->getViewport().isValidRect() )
            renderFixedBitmapBordersFilled( tabEndRect, TabEnds + 1, mProfile );
      }
   }
}
Exemple #2
0
/**
 * Render graphics for this frame when the menu is open
 */
void MenuLog::render() {

	if (!visible) return;
	
	SDL_Rect src;
	
	// background
	src.x = 0;
	src.y = 0;
	src.w = menu_area.w;
	src.h = menu_area.h;
	SDL_BlitSurface(background, &src, screen, &menu_area);
	
	// close button
	closeButton->render();
	
	// text overlay
	WidgetLabel label;
	label.set(menu_area.x+160, menu_area.y+8, JUSTIFY_CENTER, VALIGN_TOP, msg->get("Log"), FONT_WHITE);
	label.render();

	// display tabs
	for (int i=0; i<LOG_TYPE_COUNT; i++) {
		renderTab(i);
	}
	
	// display latest log messages
	
	Point size;
	int display_number = 0;
	int total_size = 0;

	// first calculate how many entire messages can fit in the log view
	for (int i=log_count[active_log]-1; i>=0; i--) {
		size = font->calc_size(log_msg[active_log][i], list_area.w);
		total_size += size.y + paragraph_spacing;
		if (total_size < list_area.h) display_number++;
		else break;
	}
	
	// now display these messages
	int cursor_y = list_area.y;
	for (int i=log_count[active_log]-display_number; i<log_count[active_log]; i++) {
		
		size = font->calc_size(log_msg[active_log][i], list_area.w);	
		font->renderShadowed(log_msg[active_log][i], list_area.x, cursor_y, JUSTIFY_LEFT, screen, list_area.w, FONT_WHITE);
		cursor_y += size.y + paragraph_spacing;
	}
}
/**
 * Renders the widget.
 *
 * Remember to render then on top of it the actual content of the {@link getActiveTab() active tab}.
 */
void WidgetTabControl::render() {
	for (unsigned i=0; i<tabs.size(); i++) {
		renderTab(i);
	}

	// draw selection rectangle
	if (in_focus) {
		Point topLeft;
		Point bottomRight;

		topLeft.x = tabs[active_tab].x;
		topLeft.y = tabs[active_tab].y;
		bottomRight.x = topLeft.x + tabs[active_tab].w;
		bottomRight.y = topLeft.y + tabs[active_tab].h;
		Color color = Color(255,248,220,255);

		render_device->drawRectangle(topLeft, bottomRight, color);
	}
}