Skip to content

[UI] Add detail bar of selected asset. #2

Description

@liubai01

This is a feature request for a detailed info bar of an asset.

Background

image

  • Asset explorer helps users organize resources in the filesystem.
  • Current implementation of asset icon in 4f19414 is in CoreAssetWidget.cpp.
  • The GUI of the editor is based on Dear ImGui.

Goal

  • Define a pointer of the selected asset.
  • When the user does a single mouse left click over an icon, the asset is selected (not opened.).
  • Show the asset's path(full name) in an info bar.

Example of unity:
image

References and guidance

For a quick start of getting handy on Dear imGUI, refer to imgui_demo.cpp.

A quick introduction to construct a widget could refer to this video (in Mandarin Chinese).

You could uncomment ImGui::ShowDemoWindow(); to show example of widgets of dearImGui in CoreApp.cpp

void CoreApp::BeforeUpdate()
{
    mGUIManager->Update();
    //ImGui::ShowDemoWindow();
}

For example, the logic of a folder.

...
} else if (assetNode->GetAssetType() == BaseAssetType::ASSET_FOLDER) {
				ImVec2 pos = ImGui::GetCursorPos();
				if (ImGui::Selectable(assetNode->mID.c_str(), false, ImGuiSelectableFlags_AllowDoubleClick, ImVec2(iconSize, iconSize)))
				{
					ImGuiIO& io = ImGui::GetIO();
					if (io.MouseDoubleClicked[0])
					{
						mNowSelectedAssetNodeDir = assetNode.get();
					}
				}

				// manually set a padding of 20.0 pixel (TBD: remove this magic number in the future)
				ImGui::SetCursorPos(ImVec2(pos.x + 20.0f, pos.y + 20.0f));
				BaseResourceImage* img = mResourceManager->LoadByURL<BaseResourceImage>("EditorAsset\\icon\\folder.png");
				ImGui::Image(img->GetImGuiRuntimeID(), ImVec2(iconSize - 40.0f, iconSize - 40.0f));

				ImGui::SetCursorPos(ImVec2(pos.x, pos.y + iconSize));
...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions