Skip to content

Commit d98276b

Browse files
committed
#157 Align sprite view & add empty save/load gui function
1 parent 89b4e72 commit d98276b

File tree

5 files changed

+148
-5
lines changed

5 files changed

+148
-5
lines changed

Projects/Editor/Source/Editor/Space/Sprite/CSpaceSprite.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,21 @@ namespace Skylicht
110110

111111
// get base rect for renderer
112112
GUI::SPoint position = base->localPosToCanvas();
113-
core::rectf viewport;
114-
viewport.UpperLeftCorner.set(position.X, position.Y);
115-
viewport.LowerRightCorner.set(position.X + base->width(), position.Y + base->height());
116113

117114
// scale the frame
118115
float sourceSize = core::max_(frame->getWidth(), frame->getHeight());
119116
float renderSize = core::max_(base->width(), base->height());
120117
float scale = sourceSize < renderSize ? 1.0f : renderSize / sourceSize;
121-
118+
119+
// align center of the render control
120+
float sw = frame->getWidth() * scale;
121+
float sh = frame->getHeight() * scale;
122+
float cx = (base->width() - sw) * 0.5f;
123+
float cy = (base->height() - sh) * 0.5f;
124+
122125
// draw the frame
123126
core::matrix4 transform;
124-
transform.setTranslation(core::vector3df(position.X, position.Y, 0.0f));
127+
transform.setTranslation(core::vector3df(position.X + cx, position.Y + cy, 0.0f));
125128
transform.setScale(scale);
126129

127130
CGraphics2D* graphics = CGraphics2D::getInstance();
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
!@
3+
MIT License
4+
5+
Copyright (c) 2019 Skylicht Technology CO., LTD
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8+
(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9+
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19+
20+
This file is part of the "Skylicht Engine".
21+
https://github.com/skylicht-lab/skylicht-engine
22+
!#
23+
*/
24+
25+
#include "pch.h"
26+
#include "CGUIExporter.h"
27+
28+
namespace Skylicht
29+
{
30+
bool CGUIExporter::save(const char* file, CCanvas* canvas)
31+
{
32+
return false;
33+
}
34+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
!@
3+
MIT License
4+
5+
Copyright (c) 2019 Skylicht Technology CO., LTD
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8+
(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9+
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19+
20+
This file is part of the "Skylicht Engine".
21+
https://github.com/skylicht-lab/skylicht-engine
22+
!#
23+
*/
24+
25+
#pragma once
26+
27+
#include "CCanvas.h"
28+
29+
namespace Skylicht
30+
{
31+
class CGUIExporter
32+
{
33+
public:
34+
static bool save(const char* file, CCanvas* canvas);
35+
};
36+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
!@
3+
MIT License
4+
5+
Copyright (c) 2019 Skylicht Technology CO., LTD
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8+
(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9+
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19+
20+
This file is part of the "Skylicht Engine".
21+
https://github.com/skylicht-lab/skylicht-engine
22+
!#
23+
*/
24+
25+
#include "pch.h"
26+
#include "CGUIImporter.h"
27+
28+
namespace Skylicht
29+
{
30+
bool CGUIImporter::load(const char* file, CCanvas* canvas)
31+
{
32+
return false;
33+
}
34+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
!@
3+
MIT License
4+
5+
Copyright (c) 2019 Skylicht Technology CO., LTD
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8+
(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9+
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19+
20+
This file is part of the "Skylicht Engine".
21+
https://github.com/skylicht-lab/skylicht-engine
22+
!#
23+
*/
24+
25+
#pragma once
26+
27+
#include "CCanvas.h"
28+
29+
namespace Skylicht
30+
{
31+
class CGUIImporter
32+
{
33+
public:
34+
static bool load(const char* file, CCanvas* canvas);
35+
};
36+
}

0 commit comments

Comments
 (0)