Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 52 additions & 28 deletions Editor/Qml/EButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,67 @@ import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Basic

Button {
Item {
enum Style {
Primary,
Secondary,
Disabled,
Outline,
Dashed
Secondary
}

function getBackgroundColor(style, focus)
{
if (style === EButton.Style.Secondary) {
return focus ? ETheme.secondaryFocusColor : ETheme.secondaryColor;
} else if (style === EButton.Style.Disabled) {
return ETheme.disabledColor;
}
// TODO more
return focus ? ETheme.primaryFocusColor : ETheme.primaryColor;
enum Size {
Small,
Middle,
Large
}

enum Shape {
Rect,
Round
}

property string text: ''
property bool disabled: false
property int style: EButton.Style.Primary
property int size: EButton.Size.Middle
property int shape: EButton.Shape.Rect
signal clicked()

// TODO disable onclick when disabled
id: 'root'
implicitWidth: btnWidget.implicitWidth
implicitHeight: btnWidget.implicitHeight

contentItem: Text {
text: parent.text
font.pixelSize: ETheme.contentFontSize
font.family: ETheme.fontFamily
color: ETheme.fontColor
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideNone
}
Button {
id: 'btnWidget'
enabled: !root.disabled
onClicked: root.clicked()
leftPadding: 10
rightPadding: 10
topPadding: 5 + 2 * (root.size - 1)
bottomPadding: 5 + 2 * (root.size - 1)
width: root.width

background: Rectangle {
implicitWidth: 50
color: getBackgroundColor(style, parent.down)
radius: 10
contentItem: Text {
text: root.text
font.pixelSize: ETheme.contentFontSize
font.family: ETheme.fontFamily
color: ETheme.fontColor
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideNone
}

background: Rectangle {
function getBackgroundColor(style, focus, disabled)
{
if (disabled) {
return ETheme.disabledColor;
} else if (style === EButton.Style.Secondary) {
return focus ? ETheme.secondaryFocusColor : ETheme.secondaryColor;
}
return focus ? ETheme.primaryFocusColor : ETheme.primaryColor;
}

color: getBackgroundColor(root.style, parent.down, root.disabled)
radius: 5 + root.shape * 8
}
}
}
61 changes: 39 additions & 22 deletions Editor/Qml/EText.qml
Original file line number Diff line number Diff line change
@@ -1,36 +1,53 @@
import QtQuick
import QtQuick.Controls

Text {
Item {
enum Style {
Title1,
Title2,
Title3,
Content
Content,
Link,
Italic
}

function getFontBold(style)
{
return style !== EText.Style.Content
}
property string text: ''
property string href: ''
property int style: EText.Style.Content

function getFontPixelSize(style)
{
if (style === EText.Style.Title1) {
return ETheme.tiele1FontSize;
} else if (style === EText.Style.Title2) {
return ETheme.title2FontSize;
} else if (style === EText.Style.Title3) {
return ETheme.title3FontSize;
} else {
return ETheme.contentFontSize;
id: 'root'
implicitWidth: textWidget.implicitWidth
implicitHeight: textWidget.implicitHeight

Text {
function getText(text, href, style)
{
return style === EText.Style.Link
? '<a href=\"%1\" style=\"color: %2; text-decoration: none;\">%3</a>'.arg(href).arg(ETheme.linkFontColor).arg(text)
: text;
}
}

property int style: EText.Style.Content
function getFontPixelSize(style)
{
if (style === EText.Style.Title1) {
return ETheme.tiele1FontSize;
} else if (style === EText.Style.Title2) {
return ETheme.title2FontSize;
} else if (style === EText.Style.Title3) {
return ETheme.title3FontSize;
} else {
return ETheme.contentFontSize;
}
}

font.bold: getFontBold(style)
font.pixelSize: getFontPixelSize(style)
font.family: ETheme.fontFamily
color: ETheme.fontColor
id: 'textWidget'
text: getText(root.text, root.href, root.style)
textFormat: root.style === EText.Style.Link ? Text.RichText : Text.PlainText;
font.italic: root.style === EText.Style.Italic
font.bold: root.style < EText.Style.Content;
font.pixelSize: getFontPixelSize(root.style)
font.family: ETheme.fontFamily
color: ETheme.fontColor
onLinkActivated: Qt.openUrlExternally(root.href)
}
}
1 change: 1 addition & 0 deletions Editor/Qml/ETheme.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ QtObject {
property color secondaryFocusColor: Qt.color('#9b6a40')
property color disabledColor: Qt.color('#676563')
property color fontColor: Qt.color('#ecf0f1')
property color linkFontColor: Qt.color('#91b9c4')

property FontLoader normalFont: FontLoader { source: Qt.url('Resource/Font/MiSans-Normal.ttf') }
property FontLoader boldFont: FontLoader { source: Qt.url('Resource/Font/MiSans-Bold.ttf') }
Expand Down
96 changes: 88 additions & 8 deletions Editor/Qml/EWidgetSamples.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ Rectangle {
color: ETheme.bgColor

ScrollView {
id: 'scrollview'
anchors.fill: parent
anchors.margins: 20

ColumnLayout {
anchors.fill: parent
anchors.margins: 20
width: Math.max(implicitWidth, scrollview.availableWidth)

RowLayout {
Layout.leftMargin: 5
Expand All @@ -25,20 +26,87 @@ Rectangle {
Layout.margins: 5

EButton {
text: 'Basic'
text: 'Basic Button'
onClicked: {
console.log('basic button clicked')
}
}

EButton {
style: EButton.Style.Secondary
text: 'Secondary Button'
onClicked: {
console.log('secondary button clicked')
}
}

EButton {
style: EButton.Style.Disabled
text: 'Disabled Button'
disabled: true
onClicked: {
console.log('disabled button clicked')
}
}
}

RowLayout {
Layout.margins: 5

EButton {
text: 'Large Button'
size: EButton.Size.Large
onClicked: {
console.log('large button clicked')
}
}

EButton {
text: 'Middle Button'
size: EButton.Size.Middle
onClicked: {
console.log('middle button clicked')
}
}

EButton {
text: 'Small Button'
size: EButton.Size.Small
onClicked: {
console.log('small button clicked')
}
}
}

RowLayout {
Layout.margins: 5

EButton {
text: 'Rect Button'
shape: EButton.Shape.Rect
onClicked: {
console.log('rect button clicked')
}
}

EButton {
text: 'Round Button'
shape: EButton.Shape.Round
onClicked: {
console.log('round button clicked')
}
}
}

// TODO icon button
RowLayout {
Layout.margins: 5

EButton {
text: 'Block Button'
Layout.fillWidth: true
onClicked: {
console.log('block button clicked')
}
}
}

RowLayout {
Expand Down Expand Up @@ -68,14 +136,26 @@ Rectangle {
text: 'Title3'
style: EText.Style.Title3
}
}

RowLayout {
Layout.leftMargin: 5

EText {
text: 'Content'
text: 'Basic Content'
style: EText.Style.Content
}

// TODO superlink text
// TODO button text
EText {
text: 'Sample Link'
href: 'https://github.com/ExplosionEngine/Explosion'
style: EText.Style.Link
}

EText {
text: 'Italic Content'
style: EText.Style.Italic
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions Engine/Source/Common/Include/Common/Container.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <bitset>
#include <list>
#include <functional>
#include <iterator>

#include <Common/Debug.h>
#include <Common/Concepts.h>
Expand Down
43 changes: 29 additions & 14 deletions Engine/Source/Runtime/Include/Runtime/Component/Transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,46 @@
#include <Runtime/Api.h>

namespace Runtime {
struct RUNTIME_API EClass() Transform final {
EClassBody(Transform)
struct RUNTIME_API EClass() WorldTransform final {
EClassBody(WorldTransform)

Transform();
explicit Transform(const Common::FTransform& inLocalToWorld);
WorldTransform();
explicit WorldTransform(Common::FTransform inLocalToWorld);

EProperty() Common::FTransform localToWorld;
};

struct RUNTIME_API EClass() ChildOfConstraint final {
EClassBody(ChildOfConstraint)
// must be used with Hierarchy and WorldTransform
struct RUNTIME_API EClass() LocalTransform final {
EClassBody(LocalTransform)

ChildOfConstraint();
explicit ChildOfConstraint(Entity inParent, const Common::FTransform& inLocalToParent);
LocalTransform();
explicit LocalTransform(Common::FTransform inLocalToParent);

EProperty() Entity parent;
EProperty() Common::FTransform localToParent;
};

struct RUNTIME_API EClass() CopyConstraint final {
EClassBody(CopyConstraint)
struct RUNTIME_API EClass() Hierarchy final {
EClassBody(Hierarchy)

Hierarchy();

CopyConstraint();
explicit CopyConstraint(Entity inTarget);
EProperty() Entity parent;
EProperty() Entity firstChild;
EProperty() Entity prevBro;
EProperty() Entity nextBro;
};

EProperty() Entity target;
class HierarchyUtils {
public:
using TraverseFunc = std::function<void(Entity, Entity)>;

static bool HasParent(ECRegistry& inRegistry, Entity inTarget);
static bool HasBro(ECRegistry& inRegistry, Entity inTarget);
static bool HasChildren(ECRegistry& inRegistry, Entity inTarget);
static void AttachToParent(ECRegistry& inRegistry, Entity inChild, Entity inParent);
static void DetachFromParent(ECRegistry& inRegistry, Entity inChild);
static void TraverseChildren(ECRegistry& inRegistry, Entity inParent, const TraverseFunc& inFunc);
static void TraverseChildrenRecursively(ECRegistry& inRegistry, Entity inParent, const TraverseFunc& inFunc);
};
}
Loading
Loading