cuticle/ui/frame.h

132 lines
2.2 KiB
C
Raw Normal View History

2024-06-26 20:47:26 +03:00
#ifndef _CUTICLE_FRAME_H
#define _CUTICLE_FRAME_H
#include<vector>
#include<set>
#include<wx/frame.h>
#include<wx/panel.h>
#include<wx/aui/aui.h>
#include<wx/button.h>
#include<wx/spinctrl.h>
#include<wx/statusbr.h>
#include<wx/toolbar.h>
#include<wx/checkbox.h>
#include<hi/node.h>
#include<hi/img.h>
struct NodeGraph;
struct ImageViewer;
struct CompositionSettings;
struct Timeline;
struct Frame : wxFrame {
wxAuiManager aui;
ImageViewer *viewer;
NodeGraph *graph;
CompositionSettings *compsets;
Timeline *timeline;
wxStatusBar *stba;
wxToolBar *tlba;
Frame();
virtual ~Frame();
};
struct GrNode : wxPanel {
struct Port {
wxString name;
enum class Type {
NONE, FILE_OPEN, COLOR, VEC1, VEC2, VEC3, VEC4, TEXT, SAMPLE, FILE_SAVE, MIC_SOURCE, WINDOW_SOURCE
} type;
};
std::vector<Port> sinks;
std::vector<Port> sources;
wxString name;
CHiPubNode *logical;
GrNode(NodeGraph*);
virtual ~GrNode();
bool MouseOverPort(wxPoint p, bool &source, int &i);
void MakeKeyframe(int i);
virtual void Fit() override;
};
struct ctTimeCtrl;
struct CompositionSettings : wxPanel {
ctTimeCtrl *duration;
wxCheckBox *durationEnable;
wxButton *btnPerform;
CompositionSettings(Frame*);
virtual ~CompositionSettings() = default;
};
struct ImageViewer : wxPanel {
wxPoint pos;
wxImage img;
wxBitmap bm;
size_t bufW, bufH;
uint8_t *buf = nullptr;
float siez = 512;
wxPoint drag;
ImageViewer(Frame*);
virtual ~ImageViewer() = default;
void SetImage(CHiImage *img);
void ResizeImage(float);
};
struct NodeGraph : wxPanel {
struct Link {
GrNode *input;
int i;
GrNode *output;
int o;
struct Comparator {
bool operator ()(const Link &a, const Link &b) {
if(a.input != b.input) return a.input < b.input;
else if(a.i != b.i) return a.i < b.i;
else if(a.output != b.output) return a.output < b.output;
else return a.o < b.o;
}
};
};
GrNode *attacheeNode = NULL;
int attacheePort;
int attacheePortIsSource;
GrNode *dragged = NULL;
wxPoint dragPos;
CHiNodeGraph *backendNG = NULL;
std::vector<GrNode*> gnodes;
std::vector<Link> links;
NodeGraph(Frame*);
virtual ~NodeGraph();
void Alinken(Link l);
void Dirtify(GrNode *g);
bool DetectCycles(GrNode*);
};
#endif