You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
o3de/Code/Sandbox/Editor/QtViewPane.h

154 lines
4.0 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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_EDITORCOMMON_QTVIEWPANE_H
#define CRYINCLUDE_EDITORCOMMON_QTVIEWPANE_H
#pragma once
#include "IEditor.h"
#include "Include/IEditorClassFactory.h"
#include "Include/IViewPane.h"
#include "Include/ObjectEvent.h"
#include "Objects/ClassDesc.h"
#include <QRect>
#include <QWidget>
namespace Serialization {
class IArchive;
}
using Serialization::IArchive;
// ---------------------------------------------------------------------------
template<class TObject>
class CTemplateObjectClassDesc
: public CObjectClassDesc
{
public:
const char* m_className;
const char* m_category;
const char* m_textureIcon;
ObjectType m_objectType;
int m_order;
const char* m_fileSpec;
const char* m_toolClassName;
CTemplateObjectClassDesc(const char* className, const char* category, const char* textureIcon, ObjectType objectType, int order = 100, const char* fileSpec = "", const char* toolClassName = nullptr)
: m_className(className)
, m_category(category)
, m_textureIcon(textureIcon)
, m_objectType(objectType)
, m_order(order)
, m_fileSpec(fileSpec)
, m_toolClassName(toolClassName)
{
}
REFGUID ClassID() override
{
return TObject::GetClassID();
}
QString GetFileSpec() override
{
return m_fileSpec;
}
ESystemClassID SystemClassID() override
{
return ESYSTEM_CLASS_OBJECT;
};
ObjectType GetObjectType() override
{
return m_objectType;
}
QString ClassName() override
{
return m_className;
}
QString Category() override
{
return m_category;
}
QString GetTextureIcon() override
{
return m_textureIcon;
}
QObject* CreateQObject() const override
{
return new TObject;
}
int GameCreationOrder() override
{
return m_order;
};
bool IsEnabled() const override
{
return TObject::IsEnabled();
}
QString GetToolClassName() override
{
return m_toolClassName ? m_toolClassName : CObjectClassDesc::GetToolClassName();
}
};
template<class TWidget>
class CQtViewClass
: public IViewPaneClass
{
public:
const char* m_name;
const char* m_category;
ESystemClassID m_classId;
CQtViewClass(const char* name, const char* category, ESystemClassID classId = ESYSTEM_CLASS_VIEWPANE)
: m_name(name)
, m_category(category)
, m_classId(classId)
{
}
virtual ESystemClassID SystemClassID() { return m_classId; };
static const GUID& GetClassID()
{
return TWidget::GetClassID();
}
virtual const GUID& ClassID()
{
return GetClassID();
}
virtual QString ClassName() { return m_name; };
virtual QString Category() { return m_category; };
QObject* CreateQObject() const override { return new TWidget(); };
QString GetPaneTitle() override { return m_name; };
unsigned int GetPaneTitleID() const override { return 0; };
EDockingDirection GetDockingDirection() override { return DOCK_FLOAT; };
QRect GetPaneRect() override { return {}; /* KDAB_TODO: ;m_sizeOptions.m_paneRect; */};
bool SinglePane() override { return false; };
bool WantIdleUpdate() override { return true; };
QSize GetMinSize() override { return {}; /*return m_sizeOptions.m_minSize;*/ }
};
#endif // CRYINCLUDE_EDITORCOMMON_QTVIEWPANE_H