| 96 | }; |
| 97 | |
| 98 | class DragDropSource : public visage::Frame { |
| 99 | public: |
| 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 | |
| 130 | private: |
| 131 | bool dragging_ = false; |
| 132 | visage::File source_file_; |
| 133 | }; |
| 134 | |
| 135 | class DragDropTarget : public visage::Frame { |
| 136 | public: |
nothing calls this directly
no outgoing calls
no test coverage detected