parent
2f1e1a0e53
commit
2d44fd4d9f
|
@ -4,37 +4,87 @@
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "../Renderer/Painting/ElementStyle.h"
|
||||||
|
|
||||||
class LayerWrapper;
|
class LayerWrapper;
|
||||||
class LeafLayerWrapper;
|
class LeafLayerWrapper;
|
||||||
class FolderLayerWrapper;
|
class FolderLayerWrapper;
|
||||||
|
class ComposedPainterPath;
|
||||||
|
|
||||||
class GraphicElement
|
class GraphicElement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString name="";
|
QString name = "";
|
||||||
|
// TODO: 改为BitmapPath
|
||||||
virtual QPainterPath getPaintObject() const = 0;
|
virtual QPainterPath getPaintObject() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SimpleElement : public GraphicElement
|
class SimpleElement : public GraphicElement
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
QJsonObject jsonSource;
|
QJsonObject jsonSource;
|
||||||
|
// TODO: 改为ComposedPainterPath
|
||||||
QPainterPath painterPath;
|
QPainterPath painterPath;
|
||||||
void loadSvgFile(const QString& filePath);
|
void loadSvgFile(const QString& filePath);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SimpleElement(QJsonObject jsonSource);
|
SimpleElement(QJsonObject jsonSource);
|
||||||
~SimpleElement() = default;
|
~SimpleElement() = default;
|
||||||
QPainterPath getPaintObject() const override;
|
QPainterPath getPaintObject() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GroupElement : public GraphicElement
|
class GroupElement : public GraphicElement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FolderLayerWrapper *sourceLayer;
|
FolderLayerWrapper* sourceLayer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GroupElement() = default;
|
GroupElement() = default;
|
||||||
GroupElement(FolderLayerWrapper *mSourceLayer);
|
GroupElement(FolderLayerWrapper* mSourceLayer);
|
||||||
~GroupElement() = default;
|
~GroupElement() = default;
|
||||||
QPainterPath getPaintObject() const override;
|
QPainterPath getPaintObject() const override;
|
||||||
void setSourceLayer(FolderLayerWrapper *sourceLayer);
|
void setSourceLayer(FolderLayerWrapper* sourceLayer);
|
||||||
|
};
|
||||||
|
|
||||||
|
//******************************** BitmapPath ********************************//
|
||||||
|
|
||||||
|
class BitmapPath
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
QRectF boundingRect;
|
||||||
|
QImage stylesAppliedCache;
|
||||||
|
void applyTransformation(QTransform &transformation);
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* 用painter的引用将它的QImage画到画布上
|
||||||
|
*/
|
||||||
|
virtual void paint(QPainter* painter) const = 0;
|
||||||
|
virtual QImage getStylesAppliedCache() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class FolderBitmapPath : public BitmapPath
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const vector<BitmapPath*> children;
|
||||||
|
virtual QImage getStylesAppliedCache() const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当获取cache的时候应该调用Render的接口
|
||||||
|
*/
|
||||||
|
class ComposedPainterPath : public BitmapPath
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* 因为ElementStyle应该被应用至整个叶子图层节点,所以它应该只用zealed来确定某些Style是否应该被作用于该Path
|
||||||
|
*/
|
||||||
|
struct SinglePath {
|
||||||
|
shared_ptr<QPainterPath> path;
|
||||||
|
bool zealed;
|
||||||
|
};
|
||||||
|
|
||||||
|
const vector<SinglePath> paths;
|
||||||
|
virtual QImage getStylesAppliedCache() const override;
|
||||||
};
|
};
|
|
@ -25,7 +25,8 @@ class LayerWrapper
|
||||||
protected:
|
protected:
|
||||||
shared_ptr<LayerWrapper> parent;
|
shared_ptr<LayerWrapper> parent;
|
||||||
QPointF referencePoint;
|
QPointF referencePoint;
|
||||||
vector<LayerStyle> styles;
|
// vector<LayerStyle> styles;
|
||||||
|
// TODO: 将cache移到子类,对Leaf用ComposedPainterPath,对Folder用FolderBitmapPath
|
||||||
QPainterPath cache;
|
QPainterPath cache;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -38,10 +39,12 @@ class LayerWrapper
|
||||||
double rotation = 0;
|
double rotation = 0;
|
||||||
bool flipHorizontally = 0;
|
bool flipHorizontally = 0;
|
||||||
bool flipVertically = 0;
|
bool flipVertically = 0;
|
||||||
|
// TODO: 将QPainterPath改为BitmapPath
|
||||||
void apply(QPainterPath &cache) const;
|
void apply(QPainterPath &cache) const;
|
||||||
} property;
|
} property;
|
||||||
void setParent(LayerWrapper *newParent);
|
void setParent(LayerWrapper *newParent);
|
||||||
virtual void refresh();
|
virtual void refresh();
|
||||||
|
// TODO: 将QPainterPath改为BitmapPath/QImage,或者直接将其删除,绘制时直接使用BitmapPath的paint方法
|
||||||
QPainterPath getCache();
|
QPainterPath getCache();
|
||||||
LayerWrapper *getParent() const; // invoke by manager, then invoke parent's applyStyles
|
LayerWrapper *getParent() const; // invoke by manager, then invoke parent's applyStyles
|
||||||
LayerWrapper(QJsonObject json, LayerWrapper *parent);
|
LayerWrapper(QJsonObject json, LayerWrapper *parent);
|
||||||
|
@ -71,6 +74,7 @@ class LeafLayerWrapper : public LayerWrapper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GraphicElement *wrappedElement;
|
GraphicElement *wrappedElement;
|
||||||
|
const vector<Renderer::ElementStyle> styles;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void refresh() override;
|
void refresh() override;
|
||||||
|
|
|
@ -21,6 +21,7 @@ int main(int argc, char* argv[])
|
||||||
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
FramelessHelper::Core::setApplicationOSThemeAware();
|
FramelessHelper::Core::setApplicationOSThemeAware();
|
||||||
|
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur);
|
||||||
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
||||||
FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow);
|
FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow);
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
|
|
Loading…
Reference in New Issue