Skip to content

Commit

Permalink
Traktor: Texture node dpi aware. Added some padding to mesh asset edi…
Browse files Browse the repository at this point in the history
…tor.
  • Loading branch information
apistol78 committed Jun 10, 2024
1 parent 123e325 commit 506719f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
2 changes: 1 addition & 1 deletion code/Mesh/Editor/MeshAssetEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ bool MeshAssetEditor::create(ui::Widget* parent, db::Instance* instance, ISerial
staticDummy->create(containerFile, L"");

Ref< ui::Container > containerOptions = new ui::Container();
containerOptions->create(containerFile, ui::WsNone, new ui::TableLayout(L"50%,50%,*", L"*", 0_ut, 0_ut));
containerOptions->create(containerFile, ui::WsNone, new ui::TableLayout(L"50%,50%,*", L"*", 0_ut, 4_ut));

Ref< ui::Container > containerLeft = new ui::Container();
containerLeft->create(containerOptions, ui::WsNone, new ui::TableLayout(L"*", L"*", 0_ut, 4_ut));
Expand Down
17 changes: 7 additions & 10 deletions code/Render/Editor/Shader/Facades/TextureNodeFacade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
#include "Ui/Graph/GraphControl.h"
#include "Ui/Graph/Node.h"

namespace traktor
namespace traktor::render
{
namespace render
{

T_IMPLEMENT_RTTI_CLASS(L"traktor.render.TextureNodeFacade", TextureNodeFacade, INodeFacade)

Expand Down Expand Up @@ -86,7 +84,7 @@ Ref< ui::Node > TextureNodeFacade::createEditorNode(

editorNode->setComment(shaderNode->getComment());

updateThumb(editor, editorNode, texture);
updateThumb(editor, graphControl, editorNode, texture);

return editorNode;
}
Expand Down Expand Up @@ -114,7 +112,7 @@ void TextureNodeFacade::refreshEditorNode(
{
editorNode->setComment(shaderNode->getComment());
editorNode->setInfo(shaderNode->getInformation());
updateThumb(editor, editorNode, checked_type_cast< Texture*, false >(shaderNode));
updateThumb(editor, graphControl, editorNode, checked_type_cast< Texture*, false >(shaderNode));
}

void TextureNodeFacade::setValidationIndicator(
Expand All @@ -125,7 +123,7 @@ void TextureNodeFacade::setValidationIndicator(
editorNode->setState(validationSucceeded ? 0 : 1);
}

void TextureNodeFacade::updateThumb(editor::IEditor* editor, ui::Node* editorNode, Texture* texture) const
void TextureNodeFacade::updateThumb(editor::IEditor* editor, ui::GraphControl* graphControl, ui::Node* editorNode, Texture* texture) const
{
Guid textureGuid = texture ? texture->getExternal() : Guid();
if (textureGuid.isValid() && !textureGuid.isNull())
Expand All @@ -143,8 +141,8 @@ void TextureNodeFacade::updateThumb(editor::IEditor* editor, ui::Node* editorNod
const bool linearGamma = textureAsset->m_output.m_assumeLinearGamma;
Ref< drawing::Image > thumbnail = thumbnailGenerator->get(
fileName,
64,
64,
graphControl->pixel(64_ut),
graphControl->pixel(64_ut),
visibleAlpha ? editor::IThumbnailGenerator::Alpha::WithAlpha : editor::IThumbnailGenerator::Alpha::NoAlpha,
linearGamma ? editor::IThumbnailGenerator::Gamma::Linear : editor::IThumbnailGenerator::Gamma::SRGB
);
Expand All @@ -162,8 +160,7 @@ void TextureNodeFacade::updateThumb(editor::IEditor* editor, ui::Node* editorNod
}

// Failed to update thumb; or no texture bound yet.
editorNode->setImage(0);
editorNode->setImage(nullptr);
}

}
}
16 changes: 6 additions & 10 deletions code/Render/Editor/Shader/Facades/TextureNodeFacade.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* TRAKTOR
* Copyright (c) 2022 Anders Pistol.
* Copyright (c) 2022-2024 Anders Pistol.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand All @@ -10,17 +10,15 @@

#include "Render/Editor/Shader/INodeFacade.h"

namespace traktor
namespace traktor::ui
{
namespace ui
{

class INodeShape;

}
}

namespace render
{
namespace traktor::render
{

class Texture;

Expand Down Expand Up @@ -67,9 +65,7 @@ class TextureNodeFacade : public INodeFacade
private:
Ref<ui::INodeShape > m_nodeShape;

void updateThumb(editor::IEditor* editor, ui::Node* editorNode, Texture* texture) const;
void updateThumb(editor::IEditor* editor, ui::GraphControl* graphControl, ui::Node* editorNode, Texture* texture) const;
};

}
}

0 comments on commit 506719f

Please sign in to comment.