Ejemplo n.º 1
0
/* ------------------------------------------------------------------------------
 * twoDimTile - Tile the provided surface across the tempSurf starting at the
 * provided X,Y as far as the provided height and width.
 *
 * This is like wallpapering a wall.
 */
void Box::twoDimTile(SDL_Surface* surf, Uint16 x, Uint16 y, Uint16 w, Uint16 h) {

   // How many horizontal and vertical blits are required to accomplish the
   // tiling?
   Uint16 hBlitCnt = w / surf->w;
   Uint16 vBlitCnt = h / surf->h;

   // Set the Clipping Rect.
   // This ensures that we never blit beyond the edges of this rectable.
   SDL_Rect rect;
   rect.x = x;
   rect.y = y;
   rect.h = h;
   rect.w = w;
   SDL_SetClipRect(this->tempSurf.get(), &rect);

   for (Uint16 hCnt = 0; hCnt <= hBlitCnt; hCnt++) {
      for (Uint16 vCnt = 0; vCnt <= vBlitCnt; vCnt++) {
         this->singBlit(surf, hCnt * surf->w, vCnt * surf->h);
      }
   }

   // Clear the Clipping Rect.
   SDL_SetClipRect(this->tempSurf.get(), NULL);
}
Ejemplo n.º 2
0
	void GenericSkin::drawMultiTouchSimulation() const
	{
		if( !mIsSimulatingMultiTouch ) return;

		SDL_Rect clipRect;
		SDL_GetClipRect(getWindowSurface(), &clipRect);
		SDL_SetClipRect(getWindowSurface(), &screenRect);

		SDL_Rect dstRect = sMultiTouchImage->clip_rect;

		// Calculates the spacing so that the little marker
		// will be drawn at the center of the touch event
		int xSpacing = (windowRect.x - screenRect.x) + (dstRect.w / 2);
		int ySpacing = (windowRect.y - screenRect.y) + (dstRect.h / 2);

		// Draw first touch event
		dstRect.x = mLastKnownMousePosition[0].first - xSpacing;
		dstRect.y = mLastKnownMousePosition[0].second - ySpacing;

		SDL_BlitSurface(sMultiTouchImage, NULL, getWindowSurface(), &dstRect);

		// Draw second touch event
		dstRect.x = mLastKnownMousePosition[1].first - xSpacing;
		dstRect.y = mLastKnownMousePosition[1].second - ySpacing;

		SDL_BlitSurface(sMultiTouchImage, NULL, getWindowSurface(), &dstRect);

		SDL_UpdateRect(getWindowSurface(), windowRect.x, windowRect.y,
											windowRect.w, windowRect.h);

		SDL_SetClipRect(getWindowSurface(), &clipRect);
	}
Ejemplo n.º 3
0
static void
_on_disp_setcellsize(disp_task_setcellsize_t* setcellsize)
{

int w=setcellsize->cell_width * Columns,
    h=setcellsize->cell_height * Rows;
info_push_messagef("resz w=%d, h=%d", w, h);

gDisplay_width=w;
gDisplay_height=h;
gDisplay_cell_w = setcellsize->cell_width;
gDisplay_cell_h = setcellsize->cell_height;
SDL_Rect clip={0,0,w,h};
/*
SDL_SetWindowSize(gDisplay, w, h);
// clear colors to bg.
// hope to restore render context,
// because of the bug with d3dx9 window resizing.
display_use_color(gDisplayColorBG);
SDL_RenderClear(gDisplayRenderer);
*/

// resize surfaces.
// do not clear them for now.
SDL_FreeSurface(gDisplayTarget0_surf);
SDL_FreeSurface(gDisplayTarget1_surf);
gDisplayTarget0_surf = SDL_CreateRGBSurface(0, w, h, 32, 0,0,0,0);
gDisplayTarget1_surf = SDL_CreateRGBSurface(0, w, h, 32, 0,0,0,0);
SDL_SetClipRect(gDisplayTarget0_surf, &clip);
SDL_SetClipRect(gDisplayTarget1_surf, &clip);
gDisplayTargetCur_surf = gDisplayTarget0_surf;
}
Ejemplo n.º 4
0
void CStackQueue::blitBg( SDL_Surface * to )
{
	if(bg)
	{
		SDL_SetClipRect(to, &pos);
		CSDL_Ext::fillTexture(to, bg);
		SDL_SetClipRect(to, nullptr);
	}
}
Ejemplo n.º 5
0
void
SDL_GUI_MainWindow::drawTitle(const RPG_Graphics_Font& font_in,
                              const std::string& text_in,
                              SDL_Surface* targetSurface_in)
{
  RPG_TRACE(ACE_TEXT("SDL_GUI_MainWindow::drawTitle"));

  if (text_in.empty())
    return;

  // sanity check
  SDL_Surface* target_surface = (targetSurface_in ? targetSurface_in
                                                  : inherited::screen_);
  ACE_ASSERT(target_surface);

  RPG_Graphics_TextSize_t title_size =
      RPG_Graphics_Common_Tools::textSize(font_in,
                                          text_in);

  SDL_Rect clip_rect, dirty_region;
  clip_rect.x = static_cast<Sint16>(borderLeft_);
  clip_rect.y = static_cast<Sint16>((borderTop_ - title_size.second) / 2);
  clip_rect.w = static_cast<Uint16>(title_size.first);
  clip_rect.h = static_cast<Uint16>(title_size.second);
  if (!SDL_SetClipRect(target_surface, &clip_rect))
  {
    ACE_DEBUG((LM_ERROR,
               ACE_TEXT("failed to SDL_SetClipRect(): %s, aborting\n"),
               ACE_TEXT(SDL_GetError())));

    return;
  } // end IF

  RPG_Graphics_Surface::putText(font_in,
                                text_in,
                                RPG_Graphics_SDL_Tools::colorToSDLColor(RPG_Graphics_SDL_Tools::getColor(RPG_GRAPHICS_FONT_DEF_COLOR,
                                                                                                         *target_surface),
                                                                        *target_surface),
                                true, // add shade
                                RPG_Graphics_SDL_Tools::colorToSDLColor(RPG_Graphics_SDL_Tools::getColor(RPG_GRAPHICS_FONT_DEF_SHADECOLOR,
                                                                                                         *target_surface),
                                                                        *target_surface),
                                std::make_pair(borderLeft_,                             // top left
                                               ((borderTop_ - title_size.second) / 2)), // center of top border
                                target_surface,
                                dirty_region);
  invalidate(dirty_region);
  if (!SDL_SetClipRect(target_surface, NULL))
  {
    ACE_DEBUG((LM_ERROR,
               ACE_TEXT("failed to SDL_SetClipRect(): %s, aborting\n"),
               ACE_TEXT(SDL_GetError())));

    return;
  } // end IF
}
Ejemplo n.º 6
0
/**
 * @brief Restricts drawing on this surface to a subarea.
 *
 * Sets a subarea of the surface where the next drawings will be restricted to
 * when this surface is used as the destination of blitting.
 * A zero-sized rectangle means that drawings are not restricted to a subarea of the surface.
 * The rectangle specified may be partially outside this rectangle
 * (then it will be resized to fit inside).
 *
 * @param clipping_rectangle a subarea of the rectangle to restrict the display to
 */
void Surface::set_clipping_rectangle(const Rectangle &clipping_rectangle) {

  if (clipping_rectangle.get_width() == 0) {
    SDL_SetClipRect(internal_surface, NULL);
  }
  else {
    Rectangle copy = clipping_rectangle;
    SDL_SetClipRect(internal_surface, copy.get_internal_rect());
  }
}
Ejemplo n.º 7
0
	void GenericSkin::drawDevice() const {
		//generatePhone();
		/*
		int width  = getWindowWidth();
		int height = getWindowHeight();
		*/

		// draw background
		//skinPhone(getWindowSurface());

		// draw buttons
		/*
		if(mProfile->mKeyboardType == DeviceProfile::DKT_KEYPAD) {
			SDL_Rect srcRect, dstRect;
			srcRect.x = 0;
			srcRect.y = 0;
			dstRect.w = srcRect.w = sUnselectedKeypad->w;
			dstRect.h = srcRect.h = sUnselectedKeypad->h;
			dstRect.x = width/2 - sUnselectedKeypad->w/2;
			dstRect.y = height - sUnselectedKeypad->h - 24;
			SDL_BlitSurface(sUnselectedKeypad, &srcRect, getWindowSurface(), &dstRect);
		}
		else if(mProfile->mKeyboardType == DeviceProfile::DKT_JOYSTICK) {
			SDL_Rect srcRect, dstRect;
			srcRect.x = 0;
			srcRect.y = 0;
			dstRect.w = srcRect.w = sUnselectedKeypad->w;
			dstRect.h = srcRect.h = 74;
			dstRect.x = width/2 - sUnselectedKeypad->w/2;
			dstRect.y = height - 74 - 24;
			SDL_BlitSurface(sUnselectedKeypad, &srcRect, getWindowSurface(), &dstRect);
		}
		*/

		SDL_Rect clipRect;
		SDL_GetClipRect(getWindowSurface(), &clipRect);
		SDL_SetClipRect(getWindowSurface(), &windowRect);

		int err;
		if((err=SDL_BlitSurface(unselectedPhone, NULL, getWindowSurface(), NULL)) != 0) {
			LOG("ERROR BLITTING: %s!!!!\n", SDL_GetError());
		}

		SDL_UpdateRect(getWindowSurface(), windowRect.x, windowRect.y, windowRect.w, windowRect.h);

		SDL_SetClipRect(getWindowSurface(), &clipRect);

		//Base::pixelDoubledBlit(0, 0, getWindowSurface(), unselectedPhone, unselectedPhone->clip_rect, 1);

		// draw screen

		//fillRect(width/2 - mProfile->mScreenWidth/2, 24, mProfile->mScreenWidth, mProfile->mScreenHeight, 0xff00ff);

	}
Ejemplo n.º 8
0
static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel)
{
	int i,j;
	n--;
	static int b=0;
	int bb=(b%6)/3;
	SDL_Rect r;
	extern SDL_Surface *text_screen;
	r.x=80-64; r.y=0; r.w=150-24+64+64; r.h=240;
	text_draw_background();
	text_draw_window(2,2,41,25,text_str_load_title);

	if (sel<min_in_dir)
	{
		min_in_dir=sel;
		max_in_dir=sel+SHOW_MAX_FILES;
	}
	else
		if (sel>=max_in_dir)
		{
			max_in_dir=sel+1;
			min_in_dir=max_in_dir-SHOW_MAX_FILES;
		}
	if (max_in_dir>n)
		max_in_dir=n-min_in_dir;

	for (i=min_in_dir,j=3;i<max_in_dir;i++,j+=2)
	{

		write_text(3,j,text_str_load_separator);
		SDL_SetClipRect(text_screen,&r);

	if ((sel+1==i+1)&&(bb))
			write_text_inv(4,j+1,namelist[i+1]->d_name);
		else
			write_text(4,j+1,namelist[i+1]->d_name);


		SDL_SetClipRect(text_screen,NULL);

		if (namelist[i+1]->d_type==DT_DIR)
			write_text(38,j+1,text_str_load_dir);
	}
	write_text(3,j,text_str_load_separator);

	write_text(5,27,"Button (A) = Insert Disk into DF0");
	write_text(6,29,"(Y) = DF1, (B) = DF2, (X) = DF3");

	text_flip();

	b++;
}
Ejemplo n.º 9
0
surface_t *
sdl_draw_masked_sprite(const sprite_t *sprite, int x, int y, const sprite_t *mask, surface_t *surface, frame_t *dest)
{
	int r;

	x += le16toh(mask->x) + dest->clip.x;
	y += le16toh(mask->y) + dest->clip.y;

	if (surface == NULL) {
		const surface_id_t id = { .sprite = sprite, .mask = mask, .offset = 0 };
		surface_t **s = surface_ht_store(&masked_sprite_cache, &id);
		if (*s == NULL) {
            *s = new surface_t;
			if (*s == NULL) abort();

			(*s)->surf = create_masked_surface(sprite, mask);
		}
		surface = *s;
	}

	SDL_Surface *surf = surface->surf;

	SDL_Rect src_rect = { 0, 0, surf->w, surf->h };
	SDL_Rect dest_rect = { x, y, 0, 0 };

	SDL_SetClipRect(dest->surf, &dest->clip);

	/* Blit to dest */
	r = SDL_BlitSurface(surf, &src_rect, dest->surf, &dest_rect);
	if (r < 0) {
		LOGE("sdl-video", "BlitSurface error: %s", SDL_GetError());
	}

	return surface;
}

void
sdl_draw_frame(int dx, int dy, frame_t *dest, int sx, int sy, frame_t *src, int w, int h)
{
	int x = dx + dest->clip.x;
	int y = dy + dest->clip.y;

	SDL_Rect dest_rect = { x, y, 0, 0 };
	SDL_Rect src_rect = { sx, sy, w, h };

	SDL_SetClipRect(dest->surf, &dest->clip);

	int r = SDL_BlitSurface(src->surf, &src_rect, dest->surf, &dest_rect);
	if (r < 0) {
		LOGE("sdl-video", "BlitSurface error: %s", SDL_GetError());
	}
}
Ejemplo n.º 10
0
void XListBox::paintSelectItem(XItem *item)
{
	XDC mDC;
	mDC.surface=screen;
	mDC.rect=&widget_rect;
	
	Uint32 color=SELECT_ITEM_COLOR;
	SDL_Rect lRect=item->paint(&mDC,divider_color,color);
	
	SDL_SetClipRect(screen,&lRect);
	vScrollbar.paint();
	SDL_SetClipRect(screen,NULL);
}
Ejemplo n.º 11
0
//*****************************************************************************
void CHTMLWidget::HandleAnimate()
//Draw as much of page surface as can be done this frame without slowing animation.
{
	ASSERT(IsVisible());
	if (!this->pHTMLSurface)
		return;
	if (this->wHeightDrawn >= (UINT)this->pHTMLSurface->h)
		return; //all done
	SDL_Surface *pDestSurface = GetDestSurface();

	//Blit horizontal strips of HTML surface to screen until animation duration is up.
	static const UINT dwMaxTime = 30;  //30ms
	const UINT dwStopTime = SDL_GetTicks() + dwMaxTime;

	ASSERT(this->pParent);
	SDL_Rect clipRect;
	this->pParent->GetChildClippingRect(clipRect);
	SDL_SetClipRect(pDestSurface, &clipRect);
	do {
		static const UINT wStripHeight = 64;
		SDL_Rect src = {-this->nOffsetX, -this->nOffsetY + this->wHeightDrawn,
				this->pHTMLSurface->w, wStripHeight};
		SDL_Rect dest = {this->x, this->y + this->wHeightDrawn, this->pHTMLSurface->w, wStripHeight};

		//Bounds check on last row.
		if (this->wHeightDrawn + wStripHeight > (UINT)this->pHTMLSurface->h)
			src.h = dest.h = this->pHTMLSurface->h - this->wHeightDrawn;
		if (dest.y + dest.h >= clipRect.y + clipRect.h)
		{
			//Now rendering past the visible rect -- stop drawing the page after this,
			//or repaint if dirty flag is set.
			src.h = dest.h = (clipRect.y + clipRect.h) - dest.y;
			if (bNeedRepaint)
			{
				bNeedRepaint = false;
				this->wHeightDrawn = -dest.h;
				GetScrollOffset(this->nOffsetX, this->nOffsetY);
			}
			else
				this->wHeightDrawn = this->pHTMLSurface->h;
		}

		SDL_BlitSurface(this->pHTMLSurface, &src, pDestSurface, &dest);
		UpdateRect(dest);

		this->wHeightDrawn += dest.h;
		if (this->wHeightDrawn >= (UINT)this->pHTMLSurface->h) break; //all done
		if (this->wHeightDrawn >= this->h) break; //drawn entire visible area
	} while (SDL_GetTicks() < dwStopTime);
	SDL_SetClipRect(pDestSurface, NULL);
}
Ejemplo n.º 12
0
static int
SW_UpdateClipRect(SDL_Renderer * renderer)
{
    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
    SDL_Surface *surface = data->surface;
    if (surface) {
        if (renderer->clipping_enabled) {
            SDL_SetClipRect(surface, &renderer->clip_rect);
        } else {
            SDL_SetClipRect(surface, NULL);
        }
    }
    return 0;
}
Ejemplo n.º 13
0
	void GenericSkin::drawScreen() const {
		//int width  = getWindowWidth();
		//fillRect(width/2 - mProfile->mScreenWidth/2, 24, mProfile->mScreenWidth, mProfile->mScreenHeight, 0xff00ff);

		SDL_Rect clipRect;
		SDL_GetClipRect(getWindowSurface(), &clipRect);
		SDL_SetClipRect(getWindowSurface(), &windowRect);

		if(SDL_BlitSurface(getPhoneScreen(), NULL, getWindowSurface(), (SDL_Rect*) &screenRect) != 0) {
			LOG("ERROR BLITTING!!!!\n");
		}

		SDL_UpdateRect(getWindowSurface(), screenRect.x, screenRect.y, screenRect.w, screenRect.h);
		SDL_SetClipRect(getWindowSurface(), &clipRect);
	}
Ejemplo n.º 14
0
void Video::resize(int xres, int yres)
{
	SDL_Rect Rect;

	this->xres = xres;
	this->yres = yres;
	this->ratio = ((float)xres)/((float)yres);
	
	//I shouldn't be changing these according to the documentation but it works
	primary->w = xres;
	primary->h = yres;

	Rect.h = yres;
	Rect.w = xres;
	Rect.x = 0;
	Rect.y = 0;
	SDL_SetClipRect(primary, &Rect);

	glViewport(0, 0, xres, yres);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(45.0f, (GLfloat)xres/(GLfloat)yres, 1.0f, 1024.0f);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
}
Ejemplo n.º 15
0
	void GenericSkin::keyReleased(int mak) {
		for(size_t i = 0; i < keyRects.size(); i++) {
			if(keyRects[i].keyCode == mak) {
				SDL_Rect clipRect;
				SDL_GetClipRect(getWindowSurface(), &clipRect);
				SDL_SetClipRect(getWindowSurface(), &windowRect);

				SDL_Rect src = { (Sint16)keyRects[i].x, (Sint16)keyRects[i].y,
					(Uint16)keyRects[i].w, (Uint16)keyRects[i].h };
				SDL_BlitSurface(unselectedPhone, &src, getWindowSurface(), &src);
				SDL_UpdateRect(getWindowSurface(), src.x, src.y, src.w, src.h);
				SDL_SetClipRect(getWindowSurface(), &clipRect);
				return;
			}
		}
	}
Ejemplo n.º 16
0
void
sdl_draw_sprite(const sprite_t *sprite, int x, int y, int y_offset, frame_t *dest)
{
	x += dest->clip.x;
	y += dest->clip.y;

	SDL_Surface *surf = create_surface_from_sprite(sprite);

	SDL_Rect src_rect = { 0, y_offset, surf->w, surf->h - y_offset };
	SDL_Rect dest_rect = { x, y + y_offset, 0, 0 };

	SDL_SetClipRect(dest->surf, &dest->clip);

	/* Blit sprite */
	int r = SDL_BlitSurface(surf, &src_rect, (SDL_Surface*)dest->surf, &dest_rect);
	if (r < 0) {
		LOGE("sdl-video", "BlitSurface error: %s.", SDL_GetError());
	}

	/* Clean up */
	SDL_FreeSurface(surf);

#if 0
	/* Bounding box */
	sdl_draw_rect(x, y + y_off, surf->w, surf->h - y_off, 72, dest);
#endif
}
Ejemplo n.º 17
0
//creating an image and connecting it to its parent in the UI tree, return if succeeded
int create_image(Sint16 xcut, Sint16 ycut, Sint16 xlocation, Sint16 ylocation,
	Uint16 width, Uint16 height, SDL_Surface* image_surface, gui_tree_node* parent){
	gui_tree_node img;
	SDL_Rect img_rect;

	img.children.len = 0;
	img.offset_rect = (SDL_Rect*)malloc(sizeof(SDL_Rect));
	if (img.offset_rect == NULL) {
		perror_message("malloc");
		return FALSE;
	}
	img.offset_rect->x = xlocation;
	img.offset_rect->y = ylocation;
	img.surface = SDL_ConvertSurface(image_surface, image_surface->format, SDL_SWSURFACE);
	if (img.surface == NULL){
		fprintf(stderr, "surface conversion failed: %s\n", SDL_GetError());
		free(img.offset_rect);
		return FALSE;
	}
	SDL_GetClipRect(img.surface, &img_rect);
	img_rect.x = xcut;
	img_rect.y = ycut;
	img_rect.w = width;
	img_rect.h = height;
	SDL_SetClipRect(img.surface, &img_rect);
	return add_child(&img, parent);

}
Ejemplo n.º 18
0
static int
SW_UpdateClipRect(SDL_Renderer * renderer)
{
    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
    SDL_Surface *surface = data->surface;
    const SDL_Rect *rect = &renderer->clip_rect;

    if (surface) {
        if (!SDL_RectEmpty(rect)) {
            SDL_SetClipRect(surface, rect);
        } else {
            SDL_SetClipRect(surface, NULL);
        }
    }
    return 0;
}
Ejemplo n.º 19
0
void
sdl_draw_sprite(const sprite_t *sprite, int x, int y, frame_t *dest)
{
	int r;

	x += le16toh(sprite->x) + dest->clip.x;
	y += le16toh(sprite->y) + dest->clip.y;

	SDL_Surface *surf = create_sprite_surface(sprite); /* Not cached */

	SDL_Rect dest_rect = { x, y, 0, 0 };

	SDL_SetClipRect(dest->surf, &dest->clip);

	/* Blit sprite */
	r = SDL_BlitSurface(surf, NULL, dest->surf, &dest_rect);
	if (r < 0) {
		LOGE("sdl-video", "BlitSurface error: %s.", SDL_GetError());
	}

	/* Clean up */
	SDL_FreeSurface(surf);

#if 0
	/* Bounding box */
	sdl_draw_rect(x, y, surf->w, surf->h, 68, dest);
#endif
}
Ejemplo n.º 20
0
	// if r is NULL, clip to the full size of the surface.
	clip_rect_setter(const surface &surf, const SDL_Rect* r, bool operate = true) : surface_(surf), rect_(), operate_(operate)
	{
		if(operate_){
			SDL_GetClipRect(surface_, &rect_);
			SDL_SetClipRect(surface_, r);
		}
	}
Ejemplo n.º 21
0
static void draw_loadMenu(int c)
{
	int i,j;
	static int b=0;
	int bb=(b%6)/3;
	SDL_Rect r;
	extern SDL_Surface *text_screen;
	r.x=80-64; r.y=0; r.w=110+64+64; r.h=240;

	text_draw_background();
	text_draw_window(80-64,12,160+64+64,220,text_str_load_title);

	if (text_dir_num_files_index<min_in_dir)
	{
		min_in_dir=text_dir_num_files_index;
		max_in_dir=text_dir_num_files_index+SHOW_MAX_FILES;
	}
	else
		if (text_dir_num_files_index>=max_in_dir)
		{
			max_in_dir=text_dir_num_files_index+1;
			min_in_dir=max_in_dir-SHOW_MAX_FILES;
		}
	if (max_in_dir>text_dir_num_files)
		max_in_dir=text_dir_num_files-min_in_dir;


	for (i=min_in_dir,j=1;i<max_in_dir;i++,j+=2)
	{
		write_text(3,j,text_str_load_separator);

		SDL_SetClipRect(text_screen,&r);

		if ((text_dir_num_files_index==i)&&(bb))
			write_text_inv(4,j+1,(char *)&text_dir_files[i].d_name);
		else
			write_text(4,j+1,(char *)&text_dir_files[i].d_name);

		SDL_SetClipRect(text_screen,NULL);

		if (text_dir_files[i].d_type==4)
			write_text(32,j+1,text_str_load_dir);
	}
	write_text(3,j,text_str_load_separator);
	text_flip();
	b++;
}
Ejemplo n.º 22
0
// Dessin
void DrawList(Widget *w)
{
	SDL_Surface *scr = w->construct->scr;
	wTHEME *t = w->construct->theme;
	ListArgs *args = w->args;
	wMENU *m = args->menu;
	Uint32 c = Darker(t->color1, 60);
	Uint32 c2 = args->isActive? t->request_c1:t->request_c2;
	if (!c2) c2 = t->color1;
	char *s;

	int ws = nSDL_GetStringWidth(t->font, m->title);
	int xw = (w->bounds.w*3)/5;
	if (!m->title)
		xw = w->bounds.w - 6;
	else if (xw + ws + 9 > w->bounds.w)
		xw = w->bounds.w - ws - 9;
	int x = w->bounds.x + w->bounds.w - xw - 3;
	
	if (m->title)
		DrawClippedStr(scr, t->font, w->bounds.x+3, w->bounds.y+6, m->title);
	DrawFillRectXY(scr, x, w->bounds.y + 3, xw, 14, c2);
	DrawRectXY(scr, x, w->bounds.y + 3, xw, 14, c);
	
	if (!args->isActive) SDL_SetAlpha(t->menus_right, SDL_SRCALPHA, 128);
	DrawSurface(t->menus_right, NULL, scr, &(SDL_Rect) {x+xw-8, w->bounds.y+6, 5, 7});
	if (!args->isActive) SDL_SetAlpha(t->menus_right, SDL_SRCALPHA, SDL_ALPHA_OPAQUE);
	
	if (args->nSelected) {
		s = wMenu_GetSelectedStr(m);
		SDL_Rect clip;
		SDL_GetClipRect(scr, &clip);
		SDL_SetClipRect(scr, &(SDL_Rect) {x+2, w->bounds.y, xw-11, w->bounds.h});
		
		if (args->nSelected>1) {
			char str[strlen(s)+5];
			sprintf(str, "%s,...", s);
			DrawClippedStr(scr, t->menus_font1, x+2, w->bounds.y+6, str);
		}
		else if (args->nSelected==1) DrawClippedStr(scr, t->menus_font1, x+2, w->bounds.y+6, s);
		
		SDL_SetClipRect(scr, &clip);
	}
	else {
		DrawClippedStr(scr, t->menus_font1, x+2 + (xw-4)/2, w->bounds.y+6, "-");
	}
}
Ejemplo n.º 23
0
Archivo: glue.c Proyecto: GWRon/sdl.mod
void bmx_sdl_surface_SetClipRect(SDL_Surface * surface, int x, int y, int w, int h) {
	SDL_Rect r;
	r.x = x;
	r.y = y;
	r.w = w;
	r.h = h;
	SDL_SetClipRect(surface, &r);
}
Ejemplo n.º 24
0
void Image::set_bounds ( const IntRect& bounds )
{
  SDL_Rect clip = SDL_RECT(bounds);

  // As per libSDL docs, if SDL_Rect is nullptr, the clipping rectangle is set
  // to the full size of the surface
  SDL_SetClipRect ( this->image(), &clip );
}
Ejemplo n.º 25
0
	// if r is nullptr, clip to the full size of the surface.
	clip_rect_setter(const surface &surf, const SDL_Rect* r, bool operate = true) : surface_(surf), rect_(), operate_(operate)
	{
		if(operate_){
			SDL_GetClipRect(surface_, &rect_);
			SDL_Rect final_rect;
			SDL_IntersectRect(&rect_, r, &final_rect);
			SDL_SetClipRect(surface_, &final_rect);
		}
	}
	void RenderBackendSDL::clearBackBuffer() {
		SDL_Rect rect;
		rect.x = 0;
		rect.y = 0;
		rect.w = getWidth();
		rect.h = getHeight();
		SDL_SetClipRect(m_screen->getSurface(), &rect);
		SDL_FillRect(m_screen->getSurface(), 0, 0x00);
	}
Ejemplo n.º 27
0
 void Painter::setClipRect(iRect rect){
     currentTransform.apply(rect);
     SDL_Rect r;
     r.x = rect.min.x;
     r.y = rect.min.y;
     r.w = rect.getSizeX();
     r.h = rect.getSizeY();
     SDL_SetClipRect(drawingSurface, &r);
 }
Ejemplo n.º 28
0
void XListBox::resumeItem()
{
	XDC mDC;
	mDC.surface=screen;
	mDC.rect=&widget_rect;
	
	if(pItem)
	{
		SDL_Rect lRect=pItem->paint(&mDC,divider_color,item_color);
		
		SDL_SetClipRect(screen,&lRect);
		
		vScrollbar.paint();
		SDL_UpdateRects(screen,1,&lRect);
		SDL_SetClipRect(screen,NULL);
	}
	
}
Ejemplo n.º 29
0
static int
SW_UpdateClipRect(SDL_Renderer * renderer)
{
    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
    SDL_Surface *surface = data->surface;
    if (surface) {
        if (renderer->clipping_enabled) {
            SDL_Rect clip_rect;
            clip_rect = renderer->clip_rect;
            clip_rect.x += renderer->viewport.x;
            clip_rect.y += renderer->viewport.y;
            SDL_IntersectRect(&renderer->viewport, &clip_rect, &clip_rect);
            SDL_SetClipRect(surface, &clip_rect);
        } else {
            SDL_SetClipRect(surface, &renderer->viewport);
        }
    }
    return 0;
}
Ejemplo n.º 30
0
/// Draw text to the specified surface
/// @param surface			SDL surface to draw text to
/// @param s				Character string to draw
/// @param rect				Destination rectangle for the text
/// @param clip				If true, clip the text output to the destination rect
void FontEngine::DrawText(SDL_Surface* surface, const char *s, SDL_Rect& rect, bool clip)
{
	if (fontImg)
		{
		if (clip)
			SDL_SetClipRect(surface, &rect);
			
		int destx = rect.x;
		const char* p = s;
		while (*p)
			{
			DrawGlyph(surface, *p, destx, rect.y);
			destx += fontCharWidth;
			p++;	
			}

		if (clip)
			SDL_SetClipRect(surface, NULL);
		}
}