Esempio n. 1
0
bool ElementImage::LoadDiskTexture()
{
	texture_dirty = false;

	// Get the source URL for the image.
	String image_source = GetAttribute< String >("src", "");
	if (image_source.Empty())
		return false;

	geometry_dirty = true;

	Rocket::Core::ElementDocument* document = GetOwnerDocument();
	URL source_url(document == NULL ? "" : document->GetSourceURL());

	if (!texture.Load(image_source, source_url.GetPath()))
	{
		geometry.SetTexture(NULL);
		return false;
	}

	// Set the texture onto our geometry object.
	geometry.SetTexture(&texture);
	return true;
}
Esempio n. 2
0
void Rocket_DocumentAction(const char* name, const char* action) {
    if (!Q_stricmp(action, "show") || !Q_stricmp(action, "open")) {
        Rocket::Core::ElementDocument* document = menuContext->GetDocument(name);
        if (document) {
            document->Show();
        }
    } else if (!Q_stricmp("close", action)) {
        if (!*name) // If name is empty, hide active
        {
            if (menuContext->GetFocusElement() &&
                menuContext->GetFocusElement()->GetOwnerDocument()) {
                menuContext->GetFocusElement()->GetOwnerDocument()->Close();
            }

            return;
        }

        Rocket::Core::ElementDocument* document = menuContext->GetDocument(name);
        if (document) {
            document->Close();
        }
    } else if (!Q_stricmp("goto", action)) {
        Rocket::Core::ElementDocument* document = menuContext->GetDocument(name);
        if (document) {
            Rocket::Core::ElementDocument* owner =
                    menuContext->GetFocusElement()->GetOwnerDocument();
            if (owner) {
                owner->Close();
            }
            document->Show();
        }
    } else if (!Q_stricmp("load", action)) {
        Rocket_LoadDocument(name);
    } else if (!Q_stricmp("blur", action) || !Q_stricmp("hide", action)) {
        Rocket::Core::ElementDocument* document = nullptr;

        if (!*name) // If name is empty, hide active
        {
            if (menuContext->GetFocusElement() &&
                menuContext->GetFocusElement()->GetOwnerDocument()) {
                document = menuContext->GetFocusElement()->GetOwnerDocument();
            }
        } else {
            document = menuContext->GetDocument(name);
        }

        if (document) {
            document->Hide();
        }
    } else if (!Q_stricmp("blurall", action)) {
        for (int i = 0; i < menuContext->GetNumDocuments(); ++i) {
            menuContext->GetDocument(i)->Hide();
        }
    } else if (!Q_stricmp("reload", action)) {
        Rocket::Core::ElementDocument* document = nullptr;

        if (!*name) // If name is empty, hide active
        {
            if (menuContext->GetFocusElement() &&
                menuContext->GetFocusElement()->GetOwnerDocument()) {
                document = menuContext->GetFocusElement()->GetOwnerDocument();
            }
        } else {
            document = menuContext->GetDocument(name);
        }

        if (document) {
            Rocket::Core::String url = document->GetSourceURL();
            document->Close();
            document = menuContext->LoadDocument(url);
            document->Show();
        }
    }
}