Compare commits
No commits in common. "55f37fd284b9aa9588c7fbc08e8f0b7518f70d05" and "099b957bf746a84d561c9f55528d83427dca9696" have entirely different histories.
55f37fd284
...
099b957bf7
|
@ -38,17 +38,3 @@ QPainterPath GroupElement::getPaintObject() const
|
|||
else
|
||||
return QPainterPath();
|
||||
}
|
||||
|
||||
void BitmapPath::applyTransformation(QTransform& transformation)
|
||||
{
|
||||
}
|
||||
|
||||
QImage FolderBitmapPath::getStylesAppliedCache() const
|
||||
{
|
||||
return QImage();
|
||||
}
|
||||
|
||||
QImage ComposedPainterPath::getStylesAppliedCache() const
|
||||
{
|
||||
return QImage();
|
||||
}
|
||||
|
|
|
@ -3,92 +3,38 @@
|
|||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QPainterPath>
|
||||
#include <QImage>
|
||||
#include <string>
|
||||
|
||||
#include "../Renderer/Painting/ElementStyle.h"
|
||||
|
||||
class LayerWrapper;
|
||||
class LeafLayerWrapper;
|
||||
class FolderLayerWrapper;
|
||||
class ComposedPainterPath;
|
||||
|
||||
class GraphicElement
|
||||
{
|
||||
public:
|
||||
QString name = "";
|
||||
// TODO: 改为BitmapPath
|
||||
public:
|
||||
QString name="";
|
||||
virtual QPainterPath getPaintObject() const = 0;
|
||||
};
|
||||
|
||||
class SimpleElement : public GraphicElement
|
||||
{
|
||||
private:
|
||||
private:
|
||||
QJsonObject jsonSource;
|
||||
// TODO: 改为ComposedPainterPath
|
||||
QPainterPath painterPath;
|
||||
void loadSvgFile(const QString& filePath);
|
||||
|
||||
public:
|
||||
public:
|
||||
SimpleElement(QJsonObject jsonSource);
|
||||
~SimpleElement() = default;
|
||||
QPainterPath getPaintObject() const override;
|
||||
};
|
||||
|
||||
class GroupElement : public GraphicElement
|
||||
{
|
||||
public:
|
||||
FolderLayerWrapper* sourceLayer;
|
||||
public:
|
||||
FolderLayerWrapper *sourceLayer;
|
||||
|
||||
public:
|
||||
public:
|
||||
GroupElement() = default;
|
||||
GroupElement(FolderLayerWrapper* mSourceLayer);
|
||||
GroupElement(FolderLayerWrapper *mSourceLayer);
|
||||
~GroupElement() = default;
|
||||
QPainterPath getPaintObject() const override;
|
||||
void setSourceLayer(FolderLayerWrapper* sourceLayer);
|
||||
};
|
||||
|
||||
//******************************** BitmapPath ********************************//
|
||||
|
||||
using std::vector;
|
||||
using std::shared_ptr;
|
||||
|
||||
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;
|
||||
void setSourceLayer(FolderLayerWrapper *sourceLayer);
|
||||
};
|
|
@ -12,8 +12,6 @@
|
|||
#include <QTreeWidget>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "../Renderer/Painting/ElementStyle.h"
|
||||
using std::shared_ptr;
|
||||
using std::vector;
|
||||
class GraphicElement;
|
||||
|
@ -27,8 +25,7 @@ class LayerWrapper
|
|||
protected:
|
||||
shared_ptr<LayerWrapper> parent;
|
||||
QPointF referencePoint;
|
||||
// vector<LayerStyle> styles;
|
||||
// TODO: 将cache移到子类,对Leaf用ComposedPainterPath,对Folder用FolderBitmapPath
|
||||
vector<LayerStyle> styles;
|
||||
QPainterPath cache;
|
||||
|
||||
public:
|
||||
|
@ -41,12 +38,10 @@ class LayerWrapper
|
|||
double rotation = 0;
|
||||
bool flipHorizontally = 0;
|
||||
bool flipVertically = 0;
|
||||
// TODO: 将QPainterPath改为BitmapPath
|
||||
void apply(QPainterPath &cache) const;
|
||||
} property;
|
||||
void setParent(LayerWrapper *newParent);
|
||||
virtual void refresh();
|
||||
// TODO: 将QPainterPath改为BitmapPath/QImage,或者直接将其删除,绘制时直接使用BitmapPath的paint方法
|
||||
QPainterPath getCache();
|
||||
LayerWrapper *getParent() const; // invoke by manager, then invoke parent's applyStyles
|
||||
LayerWrapper(QJsonObject json, LayerWrapper *parent);
|
||||
|
@ -76,7 +71,6 @@ class LeafLayerWrapper : public LayerWrapper
|
|||
{
|
||||
public:
|
||||
GraphicElement *wrappedElement;
|
||||
const vector<Renderer::ElementStyle> styles;
|
||||
|
||||
public:
|
||||
void refresh() override;
|
||||
|
|
|
@ -43,13 +43,11 @@ std::vector<glm::vec2> generatePathBuffer(const QPainterPath& path)
|
|||
break;
|
||||
case QPainterPath::LineToElement:
|
||||
qDebug() << "LineToElement";
|
||||
{
|
||||
glm::vec2 end = glm::vec2(element.x, element.y);
|
||||
glm::vec2 mid = (pathBuffer.back() + end) / 2.f;
|
||||
pathBuffer.push_back(mid);
|
||||
pathBuffer.push_back(mid);
|
||||
pathBuffer.push_back(end);
|
||||
}
|
||||
glm::vec2 end = glm::vec2(element.x, element.y);
|
||||
glm::vec2 mid = (pathBuffer.back() + end) / 2.f;
|
||||
pathBuffer.push_back(mid);
|
||||
pathBuffer.push_back(mid);
|
||||
pathBuffer.push_back(end);
|
||||
break;
|
||||
case QPainterPath::CurveToElement:
|
||||
qDebug() << "CurveToElement";
|
||||
|
|
|
@ -21,7 +21,6 @@ int main(int argc, char* argv[])
|
|||
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||
QApplication a(argc, argv);
|
||||
FramelessHelper::Core::setApplicationOSThemeAware();
|
||||
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur);
|
||||
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
||||
FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow);
|
||||
MainWindow w;
|
||||
|
|
Loading…
Reference in New Issue