Ejemplo n.º 1
0
/* CTextureCanvas::openTexture
 * Loads a composite texture to be displayed
 *******************************************************************/
bool CTextureCanvas::openTexture(CTexture* tex, Archive* parent)
{
	// Clear the current texture
	clearTexture();

	// Set texture
	texture = tex;
	this->parent = parent;

	// Init patches
	clearPatchTextures();
	for (uint32_t a = 0; a < tex->nPatches(); a++)
	{
		// Create GL texture
		patch_textures.push_back(new GLTexture());

		// Set selection
		selected_patches.push_back(false);
	}

	// Listen to it
	listenTo(tex);

	// Redraw
	Refresh();

	return true;
}
Ejemplo n.º 2
0
/* CTextureCanvas::onAnnouncement
 * Called when the texture canvas recieves an announcement from the
 * texture being displayed
 *******************************************************************/
void CTextureCanvas::onAnnouncement(Announcer* announcer, string event_name, MemChunk& event_data)
{
	// If the announcer isn't this canvas' texture, ignore it
	if (announcer != texture)
		return;

	// Patches modified
	if (event_name == "patches_modified")
	{
		// Reload patches
		selected_patches.clear();
		clearPatchTextures();
		hilight_patch = -1;
		for (uint32_t a = 0; a < texture->nPatches(); a++)
		{
			// Create GL texture
			patch_textures.push_back(new GLTexture());

			// Set selection
			selected_patches.push_back(false);
		}

		redraw(true);
	}
}
Ejemplo n.º 3
0
/* CTextureCanvas::clearTexture
 * Clears the current texture and the patch textures list
 *******************************************************************/
void CTextureCanvas::clearTexture()
{
	// Stop listening to the current texture (if it exists)
	if (texture)
		stopListening(texture);

	// Clear texture;
	texture = NULL;

	// Clear patch textures
	clearPatchTextures();

	// Reset view offset
	resetOffsets();

	// Clear patch selection
	selected_patches.clear();
	hilight_patch = -1;

	// Clear full preview
	tex_preview.clear();

	// Refresh canvas
	Refresh();
}
Ejemplo n.º 4
0
/* CTextureCanvas::~CTextureCanvas
 * CTextureCanvas class destructor
 *******************************************************************/
CTextureCanvas::~CTextureCanvas()
{
	clearPatchTextures();
}