Esempio n. 1
0
void MCControl::layer_scrolled(void)
{
	if (!opened)
		return;
		
	// Check the visibility state of the object.
	bool t_is_visible;
	t_is_visible = isvisible() || MCshowinvisibles;

	// If the layer isn't scrolling, we must redraw the whole thing. Otherwise
	// we just need to invalidate a portion of the card.
	if (!layer_isscrolling())
	{
		// We only actually need to do something if we are in the sprite
		// case, or we are visible
		if (layer_issprite() || t_is_visible)
			layer_dirtyeffectiverect(geteffectiverect(), t_is_visible);
	}
	else
	{
		// If we are a scrolling layer and not visible, there is nothing to
		// do.
		if (t_is_visible)
			static_cast<MCCard *>(parent) -> layer_dirtyrect(geteffectiverect());
	}
}
Esempio n. 2
0
void MCControl::layer_rectchanged(const MCRectangle& p_old_rect, bool p_redraw_all)
{
	if (!opened)
		return;

	// Check the visibility state of the object.
	bool t_is_visible;
	t_is_visible = isvisible() || MCshowinvisibles;
	
	// If we are not a sprite, and are invisible there is nothing to do; otherwise
	// we must at least try to dump cached updated parts of the sprite.
	if (!layer_issprite() && !t_is_visible)
		return;

	// Cache the new rectangle.
	MCRectangle t_new_rect;
	t_new_rect = rect;

	// Temporarily set it back to the old one so we can compute the old effective
	// rect.
	MCRectangle t_old_effectiverect;
	rect = p_old_rect;
	t_old_effectiverect = geteffectiverect();

	// If the rect has changed size and we aren't a scrolling layer, then we
	// redraw all.
	if (!layer_isscrolling() && 
		(rect . width != t_new_rect . width || rect . height != t_new_rect . height))
		p_redraw_all = true;

	// Replace the new rect and do the rect changed updates.
	rect = t_new_rect;
	layer_changeeffectiverect(t_old_effectiverect, p_redraw_all, t_is_visible);
}
Esempio n. 3
0
void MCControl::layer_setrect(const MCRectangle& p_new_rect, bool p_redraw_all)
{
	if (!opened)
	{
		setrect(p_new_rect);
		return;
	}
	
	// Check the visibility state of the object.
	bool t_is_visible;
	t_is_visible = isvisible() || MCshowinvisibles;
	
	// If we are not a sprite, and are invisible there is nothing to do; otherwise
	// we must at least try to dump cached updated parts of the sprite.
	if (!layer_issprite() && !t_is_visible)
	{
		setrect(p_new_rect);
		return;
	}

	MCRectangle t_old_effectiverect;
	t_old_effectiverect = geteffectiverect();

	// If the rect has changed size and we aren't a scrolling layer, then we
	// redraw all.
	if (!layer_isscrolling() && 
		(rect . width != p_new_rect . width || rect . height != p_new_rect . height))
		p_redraw_all = true;
		
	setrect(p_new_rect);

	layer_changeeffectiverect(t_old_effectiverect, p_redraw_all, t_is_visible);
}
void MCControl::SetColorOverlayProperty(MCExecContext& ctxt, MCNameRef index, MCExecValue p_value)
{
    bool t_dirty = false;
    MCRectangle t_old_effective_rect = geteffectiverect();
    
    if (MCBitmapEffectsSetProperty(ctxt, m_bitmap_effects, index, P_BITMAP_EFFECT_COLOR_OVERLAY, p_value, t_dirty))
    {
        if (t_dirty)
            EffectRedraw(t_old_effective_rect);
        return;
    }
    
    ctxt . Throw();
}
void MCControl::SetInnerShadowProperty(MCExecContext& ctxt, MCNameRef index, MCExecValue p_value)
{
    bool t_dirty = false;
    MCRectangle t_old_effective_rect = geteffectiverect();
    
    if (MCBitmapEffectsSetProperty(ctxt, m_bitmap_effects, index, P_BITMAP_EFFECT_INNER_SHADOW, p_value, t_dirty))
    {
        if (t_dirty)
            EffectRedraw(t_old_effective_rect);
        return;
    }
    
    ctxt . Throw();
}
Esempio n. 6
0
void MCControl::layer_redrawall(void)
{
	if (!opened)
		return;

	// Check the visibility state of the object.
	bool t_is_visible;
	t_is_visible = isvisible() || MCshowinvisibles;

	// If we are not a sprite, and are invisible there is nothing to do; otherwise
	// we must at least try to dump cached updated parts of the sprite.
	if (!layer_issprite() && !t_is_visible)
		return;

	// Scrolling layers are a special case as its the content that must be dirtied
	// not the effective image.
	if (!layer_isscrolling())
		layer_dirtyeffectiverect(geteffectiverect(), t_is_visible);
	else
		layer_dirtycontentrect(layer_getcontentrect(), t_is_visible);
}
Esempio n. 7
0
void MCControl::layer_changeeffectiverect(const MCRectangle& p_old_effective_rect, bool p_force_update, bool p_update_card)
{
	// Compute the 'new' effectiverect based on visibility.
	MCRectangle t_new_effective_rect;
	if (getflag(F_VISIBLE) || MCshowinvisibles)
		t_new_effective_rect = geteffectiverect();
	else
		MCU_set_rect(t_new_effective_rect, 0, 0, 0, 0);

	// If the effective rect has not changed this is at most an update.
	if (MCU_equal_rect(p_old_effective_rect, t_new_effective_rect))
	{
		// If we are forcing an update, use the dirty method.
		if (p_force_update)
		{
			// If the layer is not scrolling just defer to the normal
			// dirty method; otherwise use the dirty content method.
			if (!layer_isscrolling())
				layer_dirtyeffectiverect(t_new_effective_rect, p_update_card);
			else
				layer_dirtycontentrect(layer_getcontentrect(), p_update_card);
		}

		// We are done.
		return;
	}

	// Fetch the tilecache, making it nil if the parent is a group (in the
	// latter case, this is just a dirty op).
	MCTileCacheRef t_tilecache;
	if (parent -> gettype() != CT_GROUP)
		t_tilecache = getstack() -> gettilecache();
	else
		t_tilecache = nil;
	
	// If no tilecache, then just dirty the old and new effective rects.
	if (t_tilecache == nil)
	{
		layer_dirtyeffectiverect(p_old_effective_rect, p_update_card);
		layer_dirtyeffectiverect(t_new_effective_rect, p_update_card);
		return;
	}

	// MW-2011-10-17: [[ Bug 9808 ]] Make sure we update the card regardless of
	//    whether we have a layer id - otherwise new objects don't show!
	// Add the rects to the update region - but only if instructed (update_card will be
	// false if the object was invisible).
	if (p_update_card)
	{
		static_cast<MCCard *>(parent) -> layer_dirtyrect(p_old_effective_rect);
		static_cast<MCCard *>(parent) -> layer_dirtyrect(t_new_effective_rect);
	}
	
	// We must be in tile-cache mode with a top-level control, but if the layer
	// id is zero, there is nothing to do.
	if (m_layer_id == 0)
		return;

	if (!layer_issprite())
	{
		// Non-dynamic layers are scenery in the tilecache, and we must use old
		// new effective rects so that the appropriate tiles get flushed. Note
		// that 'force_update' has no effect here as reshaping a scenery layer
		// implicitly invalidates all tiles it touches.
		MCTileCacheReshapeScenery(t_tilecache, m_layer_id, p_old_effective_rect, t_new_effective_rect);
	}
	else
	{
		// Dynamic layers are sprites in the tilecache, and there is nothing to
		// do unless 'force update' is required. In particular, if the layer is
		// just moving then no redraw of the layer will be needed. Note, however,
		// that this implicitly assumes that 'force update' is true if the content
		// in a sprite-relative co-ord system has changed.
		if (p_force_update)
		{
			MCRectangle t_rect;
			
			// If the layer is not scrolling, just use the width/height from the
			// effective rect; otherwise use content width/height.
			if (!layer_isscrolling())
				t_rect = p_old_effective_rect;
			else
				t_rect = layer_getcontentrect();
				
			MCTileCacheUpdateSprite(t_tilecache, m_layer_id, MCU_make_rect(0, 0, t_rect . width, t_rect . height));
		}
	}
}
Esempio n. 8
0
void MCControl::layer_dirtycontentrect(const MCRectangle& p_updated_rect, bool p_update_card)
{
	if (MCU_empty_rect(p_updated_rect))
		return;

	MCRectangle t_content_rect;
	t_content_rect = layer_getcontentrect();
	
	MCTileCacheRef t_tilecache;
	t_tilecache = getstack() -> gettilecache();

	// Note that this method is only called if layer_isscrolling() is true, which is only
	// possible if we have a tilecache.
	if (m_layer_id != 0)
		MCTileCacheUpdateSprite(t_tilecache, m_layer_id, MCU_offset_rect(p_updated_rect, -t_content_rect . x, -t_content_rect . y));
		
	// Add the rect to the update region - but only if instructed (update_card will be
	// false if the object was invisible).
	if (p_update_card)
		static_cast<MCCard *>(parent) -> layer_dirtyrect(MCU_intersect_rect(p_updated_rect, geteffectiverect()));
}