Esempio n. 1
0
void layer_slide(struct LAYER * lay, int vx0, int vy0){
     int old_vx0 = lay->vx0;
     int old_vy0 = lay->vy0;
     lay->vx0 = vx0;
     lay->vy0 = vy0;
     if(lay->height >= 0){
         layer_refresh_map(lay->ctl,old_vx0,old_vy0,old_vx0 + lay->bxsize,old_vy0 + lay->bysize, 0);
         layer_refresh_map(lay->ctl,    vx0,    vy0,    vx0 + lay->bxsize,    vy0 + lay->bysize, lay->height);
         layer_refresh_sub(lay->ctl,old_vx0,old_vy0,old_vx0 + lay->bxsize,old_vy0 + lay->bysize, 0,           lay->height - 1);
         layer_refresh_sub(lay->ctl,    vx0,    vy0,    vx0 + lay->bxsize,    vy0 + lay->bysize, lay->height, lay->height);
     }
}
Esempio n. 2
0
void layer_updown(struct LAYER * lay, int height){
    struct LAYER_CTL *ctl = lay->ctl;
    int h,old = lay->height;

    if(height > ctl->top + 1){
        height = ctl->top + 1;
    }
    if(height < -1){
         height = -1;
    }
    lay->height = height;

    if(old > height){
        if(height >= 0){
            for(h = old; h > height; h--){
                ctl->layers_p[h] = ctl->layers_p[h - 1];
                ctl->layers_p[h]->height = h;
            }
            ctl->layers_p[height] = lay;
            layer_refresh_map(lay->ctl,lay->vx0,lay->vy0,lay->vx0 + lay->bxsize, lay->vy0 + lay->bysize, height + 1);
            layer_refresh_sub(lay->ctl,lay->vx0,lay->vy0,lay->vx0 + lay->bxsize, lay->vy0 + lay->bysize, height + 1, old);
        }else{
            if(ctl->top > old){
                for(h = old; h < ctl->top; h++){
                    ctl->layers_p[h] = ctl->layers_p[h + 1];
                    ctl->layers_p[h]->height = h;
                }
            }
            ctl->top--;
            layer_refresh_map(lay->ctl,lay->vx0,lay->vy0,lay->vx0 + lay->bxsize, lay->vy0 + lay->bysize, 0);
            layer_refresh_sub(lay->ctl,lay->vx0,lay->vy0,lay->vx0 + lay->bxsize, lay->vy0 + lay->bysize, 0, old - 1);
        }
    }else if(old < height){
        if(old >= 0){
            for(h = old; h < height; h++){
                ctl->layers_p[h] = ctl->layers_p[h + 1];
                ctl->layers_p[h]->height = h;
            }
        ctl->layers_p[height] = lay;
        }else{
            for(h = ctl->top; h >= height; h--){
                ctl->layers_p[h + 1] = ctl->layers_p[h];
                ctl->layers_p[h + 1]->height = h + 1;
            }
            ctl->layers_p[height] = lay;
            ctl->top++;
        }
        layer_refresh_map(lay->ctl,lay->vx0,lay->vy0,lay->vx0 + lay->bxsize, lay->vy0 + lay->bysize, height);
        layer_refresh_sub(lay->ctl,lay->vx0,lay->vy0,lay->vx0 + lay->bxsize, lay->vy0 + lay->bysize, height, height);
    }
    return;
}
Esempio n. 3
0
//图层平移,不切换
void layer_slide(LAYER *layer, int x0, int y0)
{
	LAYER_MANAGE *layer_man = layer->layer_man;
	int old_x0 = layer->x, old_y0 = layer->y;
	layer->x = x0;
	layer->y = y0;
	if(layer->height >= 0)			//只要图层位于显示区域(没有隐藏),就可以进行平移
	{
		//图层移动之后,原来位置上的所有图层都需要刷新
		layer_refresh_map(layer_man, old_x0, old_y0, old_x0 + layer->length, old_y0 + layer->width, 0);
		//图层移动的新的位置上,只刷新该图层到最顶层的地图,下面的图层即时刷新也会被上层掩盖,所以不用白费功夫
		layer_refresh_map(layer_man, x0, y0, x0 + layer->length, y0 + layer->width, layer->height);
		//原来的位置需要从最底层开始刷新,因为移动之后最底层的图像有可能会显示出来
		layer_part_refresh(layer_man, old_x0, old_y0, old_x0 + layer->length, old_y0 + layer->width, 0, layer->height - 1);					//刷新图层原来的位置
		//移动到新位置后,只刷新自己这一图层就行了,因为它不会影响更高图层的显示,刷新高层图层也是浪费时间,做无用功
		layer_part_refresh(layer_man, x0, y0, x0 + layer->length, y0 + layer->width, layer->height, layer->height);						//刷新图层现在所在的位置
	}
}
Esempio n. 4
0
void 
layer_slide(layer_t* layer, int x, int y)
{
  int old_x = layer->x;
  int old_y = layer->y;
  layer->x = x;
  layer->y = y;
  if (layer->height >= 0) {
    layer_refresh_map(layer->mgr, old_x, old_y, 
        old_x + layer->w_size, old_y + layer->h_size, 0);
    layer_refresh_map(layer->mgr, x, y, 
        x + layer->w_size, y + layer->h_size, layer->height);
    layers_refresh_sub(layer->mgr, old_x, old_y, 
        old_x + layer->w_size, old_y + layer->h_size, 0, layer->height - 1);
    layers_refresh_sub(layer->mgr, x, y, 
        x + layer->w_size, y + layer->h_size, layer->height, layer->height);
  }
}
Esempio n. 5
0
//图层高度上的移动,即前后显示切换
void layer_switch(LAYER *layer, int height)
{
	LAYER_MANAGE *layer_man = layer->layer_man;
	int h, old = layer->height;			//记录这个图层切换前的高度
	/*1.如果指定的高度不合理,过低或者过高都要进行修正,然后对图层高度赋值*/
	if(height > layer_man->top + 1)
	{
		height = layer_man->top + 1;
	}
	if(height < -1)
	{
		height = 1;
	}
	layer->height = height;		//把新的要设置的高度赋值给这个图层
	/*2.对layers_order进行重新排序*/
	if(old > height)			//如果把图层向下调的情况
	{
		if(height >= 0)			//依旧处于屏幕内,处于显示状态下
		{
			/*需要把这个图层切换高度中间夹的图层的高度向上调整,其他高度的图层不受影响*/
			for(h = old; h > height; h--)
			{
				layer_man->layers_order[h] = layer_man->layers_order[h - 1];
				layer_man->layers_order[h]->height = h;
			}
			layer_man->layers_order[height] = layer;			//把其他图层高度调好之后,再把自己的高度调整到指定高度位置
			//将土层向下调之后,因为没有平移,所以自己的图层就不用在map表中刷新了,直接刷新下调到的高度之上的图层就行了
			layer_refresh_map(layer_man, layer->x, layer->y, layer->x + layer->length, layer->y + layer->width, height + 1);
			//这里只需要刷新两个移动的高度层之间的图层即可,其他的图层不会受到影响
			layer_part_refresh(layer_man, layer->x, layer->y, layer->x + layer->length, layer->y + layer->width, height + 1, old);
		}
		else					//height < 0,不处于显示状态下,即隐藏该图层
		{
			if(layer_man->top > old)		//只有当这个图层处于非最上层的时候才需要调整它上面的图层高度,如果是最上层,其他的图层就不需要调整了
			{
				for(h = old; h < layer_man->top; h++)
				{
					layer_man->layers_order[h] = layer_man->layers_order[h + 1];
					layer_man->layers_order[h]->height = h;
				}
			}
			layer_man->top--;				//图层减少一个,所以最高高度减1
		}
		layer_refresh_map(layer_man, layer->x, layer->y, layer->x + layer->length, layer->y + layer->width, 0);
		layer_part_refresh(layer_man, layer->x, layer->y, layer->x + layer->length, layer->y + layer->width, 0, old - 1);			
	}
	else if(old < height)			//如果把图层向上调的情况
	{
		if(old >= 0)
		{
			for(h = old; h < height; h++)
			{
				layer_man->layers_order[h] = layer_man->layers_order[h + 1];
				layer_man->layers_order[h]->height = h;
			}
			layer_man->layers_order[height] = layer;
		}
		else				//有可能就是刚刚创建的图层,height还是0,;或者是像上面的情况,已经被隐藏起来的图层,height是-1
		{
			for(h = layer_man->top; h >= height; h--)
			{
				layer_man->layers_order[h + 1] = layer_man->layers_order[h];
				layer_man->layers_order[h + 1]->height = h + 1;
			}
			layer_man->layers_order[height] = layer;
			layer_man->top++;
		}
		layer_refresh_map(layer_man, layer->x, layer->y, layer->x + layer->length, layer->y + layer->width, height);
		layer_part_refresh(layer_man, layer->x, layer->y, layer->x + layer->length, layer->y + layer->width, height, height);	
	}
	return ;
}
Esempio n. 6
0
void 
layer_updown(layer_t* layer, int height)
{
  layer_mgr_t* layer_mgr = layer->mgr;
  int h, old_height = layer->height;

  /* correct the wrong height */
  if (height > layer_mgr->top + 1)
    height = layer_mgr->top + 1;
  if (height < -1)
    height = -1;
  layer->height = height;   /* setting the height */

  /* rearrangement the layers_addr[] */
  if (old_height > height) {
    if (height >= 0) {
      for (h = old_height; h > height; --h) {
        layer_mgr->layers_addr[h] = layer_mgr->layers_addr[h - 1];
        layer_mgr->layers_addr[h]->height = h;
      }
      layer_mgr->layers_addr[height] = layer;
      layer_refresh_map(layer_mgr, layer->x, layer->y, 
          layer->x + layer->w_size, layer->y + layer->h_size, height + 1);
      layers_refresh_sub(layer_mgr, layer->x, layer->y, 
          layer->x + layer->w_size, layer->y + layer->h_size, 
          height + 1, old_height);
    }
    else {
      if (layer_mgr->top > old_height) {
        for (h = old_height; h < layer_mgr->top; ++h) {
          layer_mgr->layers_addr[h] = layer_mgr->layers_addr[h + 1];
          layer_mgr->layers_addr[h]->height = h;
        }
      }
      --layer_mgr->top;
      layer_refresh_map(layer->mgr, layer->x, layer->y, 
          layer->x + layer->w_size, layer->y + layer->h_size, 0);
      layers_refresh_sub(layer_mgr, layer->x, layer->y, 
          layer->x + layer->w_size, layer->y + layer->h_size, 
          0, old_height - 1);
    }
  }
  else if (old_height < height) {
    if (old_height >= 0) {
      for (h = old_height; h < height; ++h) {
        layer_mgr->layers_addr[h] = layer_mgr->layers_addr[h + 1];
        layer_mgr->layers_addr[h]->height = h;
      }
      layer_mgr->layers_addr[height] = layer;
    }
    else {
      for (h = layer_mgr->top; h >= height; --h) {
        layer_mgr->layers_addr[h + 1] = layer_mgr->layers_addr[h];
        layer_mgr->layers_addr[h + 1]->height = h + 1;
      }
      layer_mgr->layers_addr[height] = layer;
      ++layer_mgr->top;
    }

    layer_refresh_map(layer_mgr, layer->x, layer->y, 
        layer->x + layer->w_size, layer->y + layer->h_size, height);
    layers_refresh_sub(layer_mgr, layer->x, layer->y, 
        layer->x + layer->w_size, layer->y + layer->h_size, height, height);
  }
}