editor/src/ModelStateUI.cpp
//returns true if texture was changed
returns true if texture was changed
returns true if texture was changed
bool drawTextureSlot(const std::string label, std::uint32_t& dest, std::uint32_t thumbnail)
    {
        bool retVal = false;
        glm::vec2 imgSize = WindowLayouts[WindowID::MaterialSlot].second;
        if (ImGui::ImageButton((void*)(std::size_t)thumbnail, { imgSize.x, imgSize.y }, { 0.f, 1.f }, { 1.f, 0.f }))
        {
            if (cro::FileSystem::showMessageBox("Confirm", "Clear this slot? Drag a texture from the browser to set it", cro::FileSystem::YesNo, cro::FileSystem::Question))
            {
                dest = 0;
                retVal = true;
            }
        }
        if (ImGui::BeginDragDropTarget())
        {
            if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("TEXTURE_SRC"))
            {
                auto old = dest;
                CRO_ASSERT(payload->DataSize == sizeof(std::uint32_t), "");
                dest = *(const std::uint32_t*)payload->Data;
                retVal = (old != dest);
            }
            ImGui::EndDragDropTarget();
        }
        ImGui::SameLine();
        auto textSize = ImGui::CalcTextSize("Aty");
        auto pos = ImGui::GetCursorPosY();
        pos += (imgSize.y - textSize.y) / 2.f;
        ImGui::SetCursorPosY(pos);
        ImGui::Text("%s", label.c_str());
        ImGui::SameLine();
        helpMarker("Drag a texture from the Texture Browser to fill the slot, or click the icon to clear it.");
        return retVal;
    }
bool drawTextureSlot ( const std :: string label , std :: uint32_t & dest , std :: uint32_t thumbnail ) { bool retVal = false ; glm :: vec2 imgSize = WindowLayouts [ WindowID :: MaterialSlot ] . second ; if ( ImGui :: ImageButton ( ( void * ) ( std :: size_t ) thumbnail , { imgSize . x , imgSize . y } , { 0.f , 1.f } , { 1.f , 0.f } ) ) { if ( cro :: FileSystem :: showMessageBox ( " " , " " , cro :: FileSystem :: YesNo , cro :: FileSystem :: Question ) ) { dest = 0 ; retVal = true ; } } if ( ImGui :: BeginDragDropTarget ( ) ) { if ( const ImGuiPayload * payload = ImGui :: AcceptDragDropPayload ( " " ) ) { auto old = dest ; CRO_ASSERT ( payload -> DataSize == sizeof ( std :: uint32_t ) , " " ) ; dest = * ( const std :: uint32_t * ) payload -> Data ; retVal = ( old != dest ) ; } ImGui :: EndDragDropTarget ( ) ; } ImGui :: SameLine ( ) ; auto textSize = ImGui :: CalcTextSize ( " " ) ; auto pos = ImGui :: GetCursorPosY ( ) ; pos += ( imgSize . y - textSize . y ) / 2.f ; ImGui :: SetCursorPosY ( pos ) ; ImGui :: Text ( " " , label . c_str ( ) ) ; ImGui :: SameLine ( ) ; helpMarker ( " " ) ; return retVal ; }
returns true if texture was changed
returns true if texture was changed
//seems a waste to keep calling this but hey