c66e2f4bcf
* Move Draw2d.h to Include folder * Initial phase of UI Canvas Editor rendering with Atom * Simplify Draw2d by removing BeginDraw2d/EndDraw2d which is no longer needed * Fix compile errors for non-unity builds
55 lines
2.6 KiB
C++
55 lines
2.6 KiB
C++
/*
|
|
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
|
* its licensors.
|
|
*
|
|
* For complete copyright and license terms please see the LICENSE at the root of this
|
|
* distribution (the "License"). All use of this software is governed by the License,
|
|
* or, if provided, by the license below or the license accompanying this file. Do not
|
|
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
*
|
|
*/
|
|
#pragma once
|
|
|
|
#include <Atom/RPI.Reflect/Image/Image.h>
|
|
|
|
class ViewportIcon
|
|
{
|
|
public:
|
|
|
|
ViewportIcon(const char* textureFilename);
|
|
virtual ~ViewportIcon();
|
|
|
|
AZ::Vector2 GetTextureSize() const;
|
|
|
|
void DrawImageAligned(Draw2dHelper& draw2d, AZ::Vector2& pivot, float opacity);
|
|
|
|
void DrawImageTiled(Draw2dHelper& draw2d, IDraw2d::VertexPosColUV* verts, float opacity);
|
|
|
|
void Draw(Draw2dHelper& draw2d, AZ::Vector2 anchorPos, const AZ::Matrix4x4& transform, float iconRot = 0.0f, AZ::Color color = AZ::Color(1.0f, 1.0f, 1.0f, 1.0f)) const;
|
|
|
|
void DrawAxisAlignedBoundingBox(Draw2dHelper& draw2d, AZ::Vector2 bound0, AZ::Vector2 bound1);
|
|
|
|
// draw two orthogonal lines that form an L shape from the anchor pos to the target pos on the element
|
|
void DrawAnchorLines(Draw2dHelper& draw2d, AZ::Vector2 anchorPos, AZ::Vector2 targetPos, const AZ::Matrix4x4& transform,
|
|
bool xFirst, bool xText, bool yText);
|
|
|
|
// the distance line is the segment of the anchor lines that has the distance displayed on it
|
|
void DrawDistanceLine(Draw2dHelper& draw2d, AZ::Vector2 start, AZ::Vector2 end, float displayDistance, const char* suffix = nullptr);
|
|
|
|
// draw two orthogonal lines that form an L or T shape from the two anchors to the target pos on the element
|
|
void DrawAnchorLinesSplit(Draw2dHelper& draw2d, AZ::Vector2 anchorPos1, AZ::Vector2 anchorPos2,
|
|
AZ::Vector2 targetPos, const AZ::Matrix4x4& transform, bool horizSplit, const char* suffix = nullptr);
|
|
|
|
// draw a distance line given untransformed points
|
|
void DrawDistanceLineWithTransform(Draw2dHelper& draw2d, AZ::Vector2 sourcePos, AZ::Vector2 targetPos, const AZ::Matrix4x4& transform,
|
|
float value, const char* suffix = nullptr);
|
|
|
|
// Draw a rectangle around an element using this icon's texture, The height of the texture is the
|
|
// width of the border (but the texture can have alpha at edges to make it thinner).
|
|
void DrawElementRectOutline(Draw2dHelper& draw2d, AZ::EntityId entityId, AZ::Color color);
|
|
|
|
private:
|
|
AZ::Data::Instance<AZ::RPI::Image> m_image;
|
|
};
|