|
- #pragma once
- #include <map>
-
- #include <app/common.hpp>
- #include <widget/OpaqueWidget.hpp>
- #include <widget/FramebufferWidget.hpp>
- #include <ui/Menu.hpp>
- #include <app/RailWidget.hpp>
- #include <app/ModuleWidget.hpp>
- #include <app/CableWidget.hpp>
- #include <app/PortWidget.hpp>
- #include <app/ParamWidget.hpp>
- #include <history.hpp>
-
-
- namespace rack {
- namespace app {
-
-
- /** Container for ModuleWidget and CableWidget. */
- struct RackWidget : widget::OpaqueWidget {
- struct Internal;
- Internal* internal;
-
- CableWidget* incompleteCable = NULL;
- ParamWidget* touchedParam = NULL;
- int nextCableColorId = 0;
-
- RackWidget();
- ~RackWidget();
-
- void step() override;
- void draw(const DrawArgs& args) override;
-
- void onHover(const HoverEvent& e) override;
- void onHoverKey(const HoverKeyEvent& e) override;
- void onButton(const ButtonEvent& e) override;
- void onDragStart(const DragStartEvent& e) override;
- void onDragEnd(const DragEndEvent& e) override;
- void onDragHover(const DragHoverEvent& e) override;
-
- // Rack methods
-
- widget::Widget* getModuleContainer();
- widget::Widget* getCableContainer();
- math::Vec getMousePos();
-
- /** Completely clear the rack's modules and cables */
- void clear();
- void mergeJson(json_t* rootJ);
- void fromJson(json_t* rootJ);
- void pastePresetClipboardAction();
-
- // Module methods
-
- /** Adds a module and adds it to the Engine, adopting ownership.
- */
- void addModule(ModuleWidget* mw);
- void addModuleAtMouse(ModuleWidget* mw);
- /** Removes the module and transfers ownership to the caller.
- */
- void removeModule(ModuleWidget* mw);
- /** Sets a module's box if non-colliding. Returns true if set */
- bool requestModulePos(ModuleWidget* mw, math::Vec pos);
- /** Moves a module to the closest non-colliding position */
- void setModulePosNearest(ModuleWidget* mw, math::Vec pos);
- void setModulePosForce(ModuleWidget* mw, math::Vec pos);
- ModuleWidget* getModule(int64_t moduleId);
- std::list<ModuleWidget*> getModules();
- bool hasModules();
- void updateModuleOldPositions();
- history::ComplexAction* getModuleDragAction();
-
- // Module selection methods
-
- void updateModuleSelections();
- void deselectModules();
- void selectAllModules();
- bool hasSelectedModules();
- int getNumSelectedModules();
- std::list<ModuleWidget*> getSelectedModules();
- void resetSelectedModulesAction();
- void randomizeSelectedModulesAction();
- void disconnectSelectedModulesAction();
- void cloneSelectedModulesAction();
- void bypassSelectedModulesAction(bool bypassed);
- bool areSelectedModulesBypassed();
- void deleteSelectedModulesAction();
- bool requestSelectedModulePos(math::Vec delta);
- void setSelectedModulesPosNearest(math::Vec delta);
- void appendSelectionContextMenu(ui::Menu* menu);
-
- // Cable methods
-
- void clearCables();
- void clearCablesAction();
- /** Removes all cables connected to the port */
- void clearCablesOnPort(PortWidget* port);
- /** Adds a complete cable and adopts ownership.
- */
- void addCable(CableWidget* cw);
- /** Removes cable and releases ownership to caller.
- */
- void removeCable(CableWidget* cw);
- /** Takes ownership of `cw` and adds it as a child if it isn't already. */
- void setIncompleteCable(CableWidget* cw);
- CableWidget* releaseIncompleteCable();
- /** Returns the most recently added complete cable connected to the given Port, i.e. the top of the stack. */
- CableWidget* getTopCable(PortWidget* port);
- CableWidget* getCable(int64_t cableId);
- std::list<CableWidget*> getCompleteCables();
- /** Returns all cables attached to port, complete or not. */
- std::list<CableWidget*> getCablesOnPort(PortWidget* port);
- };
-
-
- } // namespace app
- } // namespace rack
|