MCPcopy Create free account
hub / github.com/VitalAudio/visage / DragDropSource

Class DragDropSource

examples/Showcase/examples_frame.cpp:98–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96};
97
98class DragDropSource : public visage::Frame {
99public:
100 void draw(visage::Canvas& canvas) override {
101 canvas.setColor(DarkBackgroundColor);
102 canvas.roundedRectangle(0, 0, width(), height(), height() / 16);
103
104 canvas.setColor(TextColor);
105
106 const visage::Font font(height() / 4, resources::fonts::Lato_Regular_ttf);
107 if (dragging_)
108 canvas.text("Dragging source file", font, visage::Font::kCenter, 0, 0, width(), height());
109 else
110 canvas.text("Drag source", font, visage::Font::kCenter, 0, 0, width(), height());
111 }
112
113 bool isDragDropSource() override { return true; }
114
115 std::string startDragDropSource() override {
116 redraw();
117 dragging_ = true;
118 source_file_ = visage::createTemporaryFile("txt");
119 visage::replaceFileWithText(source_file_, "Example drag and drop source file.");
120 return source_file_.string();
121 }
122
123 void cleanupDragDropSource() override {
124 redraw();
125 dragging_ = false;
126 if (std::filesystem::exists(source_file_))
127 std::filesystem::remove(source_file_);
128 }
129
130private:
131 bool dragging_ = false;
132 visage::File source_file_;
133};
134
135class DragDropTarget : public visage::Frame {
136public:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected