diff --git a/Client/Source/KiwiApp.h b/Client/Source/KiwiApp.h index 098e8547..ac7cbb2f 100644 --- a/Client/Source/KiwiApp.h +++ b/Client/Source/KiwiApp.h @@ -34,8 +34,8 @@ namespace ProjectInfo { const char* const projectName = "Kiwi"; - const char* const versionString = "v1.0.0"; - const int versionNumber = 0x100; + const char* const versionString = "v1.0.1"; + const int versionNumber = 0x101; } namespace kiwi diff --git a/Client/Source/KiwiApp_General/KiwiApp_CommandIDs.h b/Client/Source/KiwiApp_General/KiwiApp_CommandIDs.h index d9f764f0..3239dc8c 100644 --- a/Client/Source/KiwiApp_General/KiwiApp_CommandIDs.h +++ b/Client/Source/KiwiApp_General/KiwiApp_CommandIDs.h @@ -68,7 +68,6 @@ namespace kiwi newBox = 0xf30300, ///< Add a new "box" to the patcher. newMessage = 0xf30301, ///< Add a new "message" object box to the patcher. - newFlonum = 0xf30302, ///< Add a new "flonum" object box to the patcher. newNumber = 0xf30303, ///< Add a new "number" object box to the patcher. newComment = 0xf30304, ///< Add a new "comment" object box to the patcher. newBang = 0xf30305, ///< Add a new "button" object box to the patcher. diff --git a/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_BangView.cpp b/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_BangView.cpp index 840fae94..8e67e40d 100644 --- a/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_BangView.cpp +++ b/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_BangView.cpp @@ -40,14 +40,15 @@ namespace kiwi { return std::make_unique(model); } - BangView::BangView(model::Object & model): - ObjectView(model), - m_signal(model.getSignal<>(model::Bang::Signal::TriggerBang)), - m_connection(m_signal.connect(std::bind(&BangView::signalTriggered, this))), - m_active(false), - m_mouse_down(false) - { - } + BangView::BangView(model::Object & model) + : ObjectView(model) + , m_trigger_signal(model.getSignal<>(model::Bang::Signal::TriggerBang)) + , m_flash_signal(model.getSignal<>(model::Bang::Signal::FlashBang)) + , m_trigger_connection(m_trigger_signal.connect(std::bind(&BangView::signalTriggered, this))) + , m_flash_connection(m_flash_signal.connect(std::bind(&BangView::signalTriggered, this))) + , m_active(false) + , m_mouse_down(false) + {} BangView::~BangView() { @@ -81,7 +82,7 @@ namespace kiwi { m_mouse_down = true; repaint(); - m_signal(); + m_trigger_signal(); } void BangView::mouseUp(juce::MouseEvent const& e) diff --git a/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_BangView.h b/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_BangView.h index 3ab0cdd6..0acc6acc 100644 --- a/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_BangView.h +++ b/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_BangView.h @@ -62,8 +62,10 @@ namespace kiwi { private: // members //! @todo Put border into ObjectView. - flip::Signal<>& m_signal; - flip::SignalConnection m_connection; + flip::Signal<>& m_trigger_signal; + flip::Signal<>& m_flash_signal; + flip::SignalConnection m_trigger_connection; + flip::SignalConnection m_flash_connection; bool m_active; bool m_mouse_down; diff --git a/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberTildeView.cpp b/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberTildeView.cpp index 2ff4766f..933fc7b8 100644 --- a/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberTildeView.cpp +++ b/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberTildeView.cpp @@ -38,14 +38,22 @@ namespace kiwi { return std::make_unique(object_model); } - NumberTildeView::NumberTildeView(model::Object & object_model) : - NumberViewBase(object_model) + NumberTildeView::NumberTildeView(model::Object & object_model) + : NumberViewBase(object_model) { setEditable(false); - setIconColour(findColour(ObjectView::ColourIds::Active)); setInterceptsMouseClicks(false, false); } + void NumberTildeView::drawIcon (juce::Graphics& g) const + { + g.setColour (findColour (ObjectView::ColourIds::Active)); + + g.setFont(22.f); + g.drawFittedText("~", getLocalBounds().withWidth(getHeight()).withX(2), + juce::Justification::centredLeft, 1); + } + void NumberTildeView::parameterChanged(std::string const& name, tool::Parameter const& param) { if (name == "value") diff --git a/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberTildeView.h b/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberTildeView.h index aa043fbe..898b6c6b 100644 --- a/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberTildeView.h +++ b/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberTildeView.h @@ -48,6 +48,8 @@ namespace kiwi { private: // methods + void drawIcon (juce::Graphics& g) const override; + //! @brief Called when the displayed number has just changed. void displayNumberChanged(double new_number) override final; diff --git a/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberView.cpp b/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberView.cpp index 5c6bb194..2d0faa02 100644 --- a/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberView.cpp +++ b/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberView.cpp @@ -40,18 +40,31 @@ namespace kiwi { return std::make_unique(object_model); } - NumberView::NumberView(model::Object & object_model) : - NumberViewBase(object_model), - m_output_message(object_model.getSignal<>(model::Message::Signal::outputMessage)), - m_sensitivity(1), - m_mouse_info() + NumberView::NumberView(model::Object & object_model) + : NumberViewBase(object_model) + , m_output_message(object_model.getSignal<>(model::Message::Signal::outputMessage)) { - setIconColour(findColour(ObjectView::ColourIds::Outline)); setInterceptsMouseClicks(true, true); } NumberView::~NumberView() + {} + + void NumberView::drawIcon (juce::Graphics& g) const { + g.setColour(findColour(ObjectView::ColourIds::Outline)); + + const juce::Rectangle icon_bounds = getLocalBounds() + .withWidth(m_indent - 4).withHeight(getHeight() - 8).translated(2, 4); + + juce::Path corner; + + corner.addTriangle(icon_bounds.getTopLeft().toFloat(), + icon_bounds.getTopRight().toFloat() + + juce::Point(0, (icon_bounds.getHeight() / 2.)), + icon_bounds.getBottomLeft().toFloat()); + + g.fillPath(corner); } void NumberView::mouseDoubleClick(juce::MouseEvent const& e) @@ -63,60 +76,100 @@ namespace kiwi { { e.source.enableUnboundedMouseMovement(true, true); - m_mouse_info.m_mouse_down_value = getDisplayNumber(); - m_mouse_info.m_mouse_down_y = e.y; + m_last_drag_pos = e.position; + m_drag_value = m_value; + + auto const& label = getLabel(); + const auto textArea = label.getBorderSize().subtractedFrom(label.getBounds()); - if (e.mods.isAltDown()) + juce::GlyphArrangement glyphs; + glyphs.addFittedText (label.getFont(), label.getText(), + textArea.getX(), 0., textArea.getWidth(), getHeight(), + juce::Justification::centredLeft, 1, + label.getMinimumHorizontalScale()); + + double decimal_x = getWidth(); + for(int i = 0; i < glyphs.getNumGlyphs(); ++i) { - m_mouse_info.m_is_alt_down = true; - m_mouse_info.m_alt_down_value = getDisplayNumber(); - m_mouse_info.m_alt_down_y = e.y; + auto const& glyph = glyphs.getGlyph(i); + if(glyph.getCharacter() == '.') + { + decimal_x = glyph.getRight(); + } + } + + const bool is_dragging_decimal = e.x > decimal_x; + + m_decimal_drag = is_dragging_decimal ? 6 : 0; + + if(is_dragging_decimal) + { + juce::GlyphArrangement decimals_glyph; + static const juce::String decimals_str("000000"); + + decimals_glyph.addFittedText (label.getFont(), decimals_str, + decimal_x, 0, getWidth(), getHeight(), + juce::Justification::centredLeft, 1, + label.getMinimumHorizontalScale()); + + for(int i = 0; i < decimals_glyph.getNumGlyphs(); ++i) + { + auto const& glyph = decimals_glyph.getGlyph(i); + if(e.x <= glyph.getRight()) + { + m_decimal_drag = i+1; + break; + } + } } } void NumberView::mouseDrag(juce::MouseEvent const& e) { - if (e.getDistanceFromDragStartY() != 0) + setMouseCursor(juce::MouseCursor::NoCursor); + updateMouseCursor(); + + if (e.mouseWasDraggedSinceMouseDown()) { - double new_value = 0; - - if (!m_mouse_info.m_is_alt_down && e.mods.isAltDown()) - { - m_mouse_info.m_is_alt_down = true; - m_mouse_info.m_alt_down_value = getDisplayNumber(); - m_mouse_info.m_alt_down_y = e.y; - } - else if(m_mouse_info.m_is_alt_down && !e.mods.isAltDown()) - { - m_mouse_info.m_mouse_down_value = getDisplayNumber(); - m_mouse_info.m_mouse_down_y = e.y; - m_mouse_info.m_is_alt_down = false; - m_mouse_info.m_is_alt_down = 0; - m_mouse_info.m_alt_down_y = 0; - } + const int decimal = m_decimal_drag + e.mods.isShiftDown(); + const double increment = (decimal == 0) ? 1. : (1. / std::pow(10., decimal)); + const double delta_y = e.y - m_last_drag_pos.y; + m_last_drag_pos = e.position; - if (e.mods.isAltDown()) - { - new_value = m_mouse_info.m_alt_down_value - (m_sensitivity * (e.y - m_mouse_info.m_alt_down_y)) / 100.; - } - else + m_drag_value += increment * -delta_y; + + if(m_drag_value != m_value) { - new_value = m_mouse_info.m_mouse_down_value - m_sensitivity * (e.y - m_mouse_info.m_mouse_down_y); + // truncate value and set + + double new_value = m_drag_value; + + if(decimal > 0) + { + const int sign = (new_value > 0) ? 1 : -1; + unsigned int ui_temp = (new_value * std::pow(10, decimal)) * sign; + new_value = (((double)ui_temp)/std::pow(10, decimal) * sign); + } + else + { + new_value = static_cast(new_value); + } + + setParameter("value", + tool::Parameter(tool::Parameter::Type::Float, {new_value})); + m_output_message(); + repaint(); } - - setParameter("value", tool::Parameter(tool::Parameter::Type::Float, {new_value})); - m_output_message(); - repaint(); } } void NumberView::mouseUp(juce::MouseEvent const& e) { - m_mouse_info.m_mouse_down_value = 0; - m_mouse_info.m_mouse_down_y = 0; - m_mouse_info.m_is_alt_down = false; - m_mouse_info.m_alt_down_value = 0; - m_mouse_info.m_alt_down_y = 0; + setMouseCursor(juce::MouseCursor::NormalCursor); + updateMouseCursor(); + + juce::Desktop::getInstance() + .getMainMouseSource().setScreenPosition(e.getMouseDownScreenPosition().toFloat()); } void NumberView::parameterChanged(std::string const& name, tool::Parameter const& param) diff --git a/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberView.h b/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberView.h index 11a456f8..1c6e2b5a 100644 --- a/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberView.h +++ b/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberView.h @@ -34,17 +34,6 @@ namespace kiwi { //! @brief The view of any textual kiwi object. class NumberView : public NumberViewBase { - private: // members - - struct MouseInfo - { - double m_mouse_down_value = 0; - int m_mouse_down_y = 0; - bool m_is_alt_down = false; - double m_alt_down_value = 0; - int m_alt_down_y = 0; - }; - public: // methods // @brief The declaration method. @@ -61,6 +50,8 @@ namespace kiwi { private: // methods + void drawIcon (juce::Graphics& g) const override; + //! @brief Stores the initial value before draging. void mouseDown(juce::MouseEvent const& e) override final; @@ -81,9 +72,10 @@ namespace kiwi { private: // members - flip::Signal<> & m_output_message; - int m_sensitivity; - MouseInfo m_mouse_info; + flip::Signal<>& m_output_message; + int m_decimal_drag = 0; + juce::Point m_last_drag_pos {}; + double m_drag_value = 0; private: // deleted methods diff --git a/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberViewBase.cpp b/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberViewBase.cpp index f62d1400..08c03281 100644 --- a/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberViewBase.cpp +++ b/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberViewBase.cpp @@ -30,11 +30,10 @@ namespace kiwi { // NUMBER VIEW BASE // // ================================================================================ // - NumberViewBase::NumberViewBase(model::Object & object_model) : - EditableObjectView(object_model), - m_value(0), - m_indent(9), - m_icon_colour(findColour (ObjectView::ColourIds::Outline)) + NumberViewBase::NumberViewBase(model::Object & object_model) + : EditableObjectView(object_model) + , m_value(0) + , m_indent(9) { juce::Label & label = getLabel(); @@ -65,18 +64,12 @@ namespace kiwi { g.setColour (findColour (ObjectView::ColourIds::Outline)); drawOutline(g); - - juce::Path corner; - - g.setColour(m_icon_colour); - - juce::Rectangle triangle_bounds = getLocalBounds().withWidth(m_indent - 4).withHeight(getHeight() - 8).translated(2, 4); - - corner.addTriangle(triangle_bounds.getTopLeft().toFloat(), - triangle_bounds.getTopRight().toFloat() + juce::Point(0, (triangle_bounds.getHeight() / 2.)), - triangle_bounds.getBottomLeft().toFloat()); - - g.fillPath(corner); + drawIcon(g); + } + + void NumberViewBase::drawIcon (juce::Graphics& g) const + { + // nothing by default } void NumberViewBase::resized() @@ -86,11 +79,6 @@ namespace kiwi { getLabel().setBounds(label_bounds); } - void NumberViewBase::setIconColour(juce::Colour colour) - { - m_icon_colour = colour; - } - double NumberViewBase::getDisplayNumber() const { return m_value; @@ -101,7 +89,7 @@ namespace kiwi { m_value = number; juce::String display_value(std::to_string(m_value)); - + display_value = display_value.trimCharactersAtEnd("0"); getLabel().setText(display_value, juce::NotificationType::dontSendNotification); @@ -109,7 +97,7 @@ namespace kiwi { void NumberViewBase::textChanged() { - m_value = getLabel().getText().getFloatValue(); + m_value = getLabel().getText().getDoubleValue(); displayNumberChanged(m_value); } diff --git a/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberViewBase.h b/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberViewBase.h index 8a03f84f..aed12c4c 100644 --- a/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberViewBase.h +++ b/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberViewBase.h @@ -50,9 +50,7 @@ namespace kiwi { //! @brief Returns the displayed text as a number. double getDisplayNumber() const; - //! @brief Sets the triangle icon colour. - //! @details By default colour is outline colour. - void setIconColour(juce::Colour colour); + virtual void drawIcon (juce::Graphics& g) const; private: // methods @@ -78,11 +76,10 @@ namespace kiwi { //! @details Overrides EditableOjectView::createTextEditor. juce::TextEditor* createdTextEditor() override final; - private: // members + protected: // members double m_value; int m_indent; - juce::Colour m_icon_colour; private: // deleted methods diff --git a/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_ObjectView.cpp b/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_ObjectView.cpp index c6341f96..acf2f4c0 100644 --- a/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_ObjectView.cpp +++ b/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_ObjectView.cpp @@ -55,11 +55,11 @@ namespace kiwi void ObjectView::setAttribute(std::string const& name, tool::Parameter const& parameter) { - model::Object & object_model = getModel(); - - object_model.setAttribute(name, parameter); - - model::DocumentManager::commit(object_model); + model::Object& object_model = getModel(); + object_model.setAttribute(name, parameter); + + const auto commit_msg = object_model.getName() + " \"" + name + "\" changed"; + model::DocumentManager::commit(object_model, commit_msg); } void ObjectView::setParameter(std::string const& name, tool::Parameter const& parameter) diff --git a/Client/Source/KiwiApp_Patcher/KiwiApp_PatcherView.cpp b/Client/Source/KiwiApp_Patcher/KiwiApp_PatcherView.cpp index ab048658..4c9d4901 100755 --- a/Client/Source/KiwiApp_Patcher/KiwiApp_PatcherView.cpp +++ b/Client/Source/KiwiApp_Patcher/KiwiApp_PatcherView.cpp @@ -1826,7 +1826,8 @@ namespace kiwi commands.add(CommandIDs::newToggle); commands.add(CommandIDs::newSlider); commands.add(CommandIDs::newMessage); - commands.add(CommandIDs::newComment); + commands.add(CommandIDs::newComment); + commands.add(CommandIDs::newNumber); commands.add(CommandIDs::zoomIn); commands.add(CommandIDs::zoomOut); @@ -1972,6 +1973,14 @@ namespace kiwi result.addDefaultKeypress('s', juce::ModifierKeys::noModifiers); result.setActive(!isLocked()); break; + } + case CommandIDs::newNumber: + { + result.setInfo(TRANS("New Number Box"), TRANS("Add a new number"), CommandCategories::editing, 0); + result.addDefaultKeypress('f', juce::ModifierKeys::noModifiers); + result.addDefaultKeypress('i', juce::ModifierKeys::noModifiers); + result.setActive(!isLocked()); + break; } case CommandIDs::newComment: { @@ -2059,9 +2068,10 @@ namespace kiwi case juce::StandardApplicationCommandIDs::selectAll:{ selectAllObjects(); break; } case CommandIDs::newBox: { createObjectModel("", true); break; } - case CommandIDs::newBang: { createObjectModel("bang", true); break; } - case CommandIDs::newToggle: { createObjectModel("toggle", true); break; } - case CommandIDs::newSlider: { createObjectModel("slider", true); break; } + case CommandIDs::newBang: { createObjectModel("bang", false); break; } + case CommandIDs::newToggle: { createObjectModel("toggle", false); break; } + case CommandIDs::newNumber: { createObjectModel("number", false); break; } + case CommandIDs::newSlider: { createObjectModel("slider", false); break; } case CommandIDs::newComment: { createObjectModel("comment", true); break; } case CommandIDs::newMessage: { createObjectModel("message", true); break; } diff --git a/Client/Source/KiwiApp_Patcher/KiwiApp_PatcherViewIoletHighlighter.cpp b/Client/Source/KiwiApp_Patcher/KiwiApp_PatcherViewIoletHighlighter.cpp index 03ee3ceb..055933e5 100644 --- a/Client/Source/KiwiApp_Patcher/KiwiApp_PatcherViewIoletHighlighter.cpp +++ b/Client/Source/KiwiApp_Patcher/KiwiApp_PatcherViewIoletHighlighter.cpp @@ -77,10 +77,7 @@ namespace kiwi void IoletHighlighter::highlight(ObjectFrame const& object, const size_t index, bool is_inlet) { - const auto& object_model = object.getModel(); - - auto new_name = object_model.getName(); - auto new_text = object_model.getIODescription(m_is_inlet, index); + auto const& object_model = object.getModel(); //! Only hilight if either no pin is currently hilighted //! or hilighted pin is different. diff --git a/Modules/KiwiEngine/KiwiEngine_Object.cpp b/Modules/KiwiEngine/KiwiEngine_Object.cpp index 34582f98..b1db1b60 100644 --- a/Modules/KiwiEngine/KiwiEngine_Object.cpp +++ b/Modules/KiwiEngine/KiwiEngine_Object.cpp @@ -81,14 +81,10 @@ namespace kiwi }); } - model::Object & Object::getObjectModel() + model::Object& Object::getObjectModel() { - flip::Array & objects = m_patcher.getPatcherModel().getObjects(); - - return *std::find_if(objects.begin(), objects.end(), [this](model::Object const & object_model) - { - return object_model.ref() == m_ref; - }); + return m_patcher.getPatcherModel().document() + .object(m_ref); } void Object::parameterChanged(std::string const& param_name, tool::Parameter const& param) @@ -99,20 +95,20 @@ namespace kiwi { } - void Object::setAttribute(std::string const& name, tool::Parameter const& param) + void Object::setAttribute(std::string const& name, tool::Parameter && param) { - deferMain([this, name, param]() - { - getObjectModel().setAttribute(name, param); + deferMain([this, name, param = std::move(param)]() { + + auto& object_model = getObjectModel(); + object_model.setAttribute(name, param); + model::DocumentManager::commit(object_model); - model::DocumentManager::commit(getObjectModel()); }); } - void Object::setParameter(std::string const& name, tool::Parameter const& param) + void Object::setParameter(std::string const& name, tool::Parameter && param) { - deferMain([this, name, param] - { + deferMain([this, name, param = std::move(param)]() { getObjectModel().setParameter(name, param); }); } diff --git a/Modules/KiwiEngine/KiwiEngine_Object.h b/Modules/KiwiEngine/KiwiEngine_Object.h index 9eec2937..3dabd993 100644 --- a/Modules/KiwiEngine/KiwiEngine_Object.h +++ b/Modules/KiwiEngine/KiwiEngine_Object.h @@ -140,11 +140,11 @@ namespace kiwi //! @brief Changes one of the data model's attributes. //! @details For thread safety actual model's modification is called on the main thread. - void setAttribute(std::string const& name, tool::Parameter const& parameter); + void setAttribute(std::string const& name, tool::Parameter && parameter); //! @brief Changes one of the data model's parameter. //! @details For thread safety actual model's modification is called on the main thread. - void setParameter(std::string const& name, tool::Parameter const& parameter); + void setParameter(std::string const& name, tool::Parameter && parameter); private: // methods diff --git a/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Bang.cpp b/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Bang.cpp index a0a98733..13ec8581 100644 --- a/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Bang.cpp +++ b/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Bang.cpp @@ -40,10 +40,11 @@ namespace kiwi { namespace engine { return std::make_unique(model, patcher); } - Bang::Bang(model::Object const& model, Patcher & patcher): - Object(model, patcher), - m_signal(model.getSignal<>(model::Bang::Signal::TriggerBang)), - m_connection(m_signal.connect(std::bind(&Bang::signalTriggered, this))) + Bang::Bang(model::Object const& model, Patcher & patcher) + : Object(model, patcher) + , m_trigger_signal(model.getSignal<>(model::Bang::Signal::TriggerBang)) + , m_flash_signal(model.getSignal<>(model::Bang::Signal::FlashBang)) + , m_connection(m_trigger_signal.connect(std::bind(&Bang::signalTriggered, this))) { } @@ -61,9 +62,16 @@ namespace kiwi { namespace engine { void Bang::receive(size_t index, std::vector const& args) { - if (index == 0) + if (index == 0 && !args.empty()) { - m_signal(); + if(args[0].getString() == "set") + { + m_flash_signal(); + } + else + { + m_trigger_signal(); + } } } diff --git a/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Bang.h b/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Bang.h index b2112019..9fd4893f 100644 --- a/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Bang.h +++ b/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Bang.h @@ -47,7 +47,8 @@ namespace kiwi { namespace engine { private: // members - flip::Signal<> & m_signal; + flip::Signal<>& m_trigger_signal; + flip::Signal<>& m_flash_signal; flip::SignalConnection m_connection; }; diff --git a/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Hub.cpp b/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Hub.cpp index 2f987b86..46f6b382 100644 --- a/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Hub.cpp +++ b/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Hub.cpp @@ -62,11 +62,8 @@ namespace kiwi { namespace engine { { if (index == 0 && !args.empty()) { - setAttribute("message", - tool::Parameter(tool::Parameter::Type::String, - {tool::AtomHelper::toString(args)})); + setAttribute("message", { tool::Parameter::Type::String, {tool::AtomHelper::toString(args)}}); } } }} - diff --git a/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Random.cpp b/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Random.cpp index 4e143b0f..7ef8c638 100644 --- a/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Random.cpp +++ b/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Random.cpp @@ -41,70 +41,73 @@ namespace kiwi { namespace engine { return std::make_unique(model, patcher); } - Random::Random(model::Object const& model, Patcher& patcher): - Object(model, patcher), - m_random_generator(), - m_random_distribution(0, 100) + Random::Random(model::Object const& model, Patcher& patcher) + : Object(model, patcher) { - m_random_generator.seed(1); + auto const& args = model.getArguments(); - std::vector const& args = model.getArguments(); - - if (args.size() > 0 && args[0].isNumber()) - { - setRange(args[0].getInt()); - } - - if (args.size() > 1 && args[1].isNumber()) - { - setSeed(args[1].getInt()); - } + setRange((args.size() > 0 && args[0].isNumber()) ? args[0].getInt() : 0ll); + setSeed((args.size() > 1 && args[1].isNumber()) ? args[1].getInt() : 0ll); } void Random::receive(size_t index, std::vector const& args) { + if(args.empty()) + return; // abort + if (index == 0) { if (args[0].isBang()) { - send(0, {m_random_distribution(m_random_generator)}); + send(0, {getNextRandomValue()}); } - else + else if (args[0].getString() == "seed") { - warning("random inlet 1 only understand bang"); - } - } - else if (index == 1) - { - if (args[0].isNumber()) - { - setRange(args[0].getInt()); + if(args.size() > 1 && args[1].isNumber()) + { + setSeed(args[1].getInt()); + } + else + { + warning("random: seed message must be followed by an integer"); + } } else { - warning("random inlet 2 only understand numbers"); + warning("random: inlet 1 only understands bang or seed message"); } } - else if (index == 2) + else if (index == 1) { if (args[0].isNumber()) { - setSeed(args[0].getInt()); + setRange(args[0].getInt()); } else { - warning("random inlet 2 only understand numbers"); + warning("random: inlet 2 only understands numbers"); } } } - void Random::setRange(int range) + void Random::setRange(int64_t range) { - m_random_distribution.param(std::uniform_int_distribution::param_type(0, std::max(0, range))); + m_random_distribution.param(rnd_distribution_t::param_type(0, std::max(0, range - 1))); + } + + void Random::setSeed(int64_t seed) + { + if(seed == 0) + { + // obtain a seed from the timer + seed = (clock_t::now() - m_start_time).count(); + } + + m_random_generator.seed(seed); } - void Random::setSeed(int seed) + int64_t Random::getNextRandomValue() { - m_random_generator.seed(); + return m_random_distribution(m_random_generator); } }} diff --git a/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Random.h b/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Random.h index cd21fd12..052b1f5d 100644 --- a/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Random.h +++ b/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Random.h @@ -23,6 +23,7 @@ #include +#include #include namespace kiwi { namespace engine { @@ -45,14 +46,19 @@ namespace kiwi { namespace engine { private: // methods - void setRange(int range); + void setRange(int64_t range); + void setSeed(int64_t new_seed); - void setSeed(int new_seed); + int64_t getNextRandomValue(); private: // members - std::mt19937 m_random_generator; - std::uniform_int_distribution m_random_distribution; + using clock_t = std::chrono::high_resolution_clock; + using rnd_distribution_t = std::uniform_int_distribution; + + clock_t::time_point m_start_time { clock_t::now() }; + std::mt19937 m_random_generator {}; + rnd_distribution_t m_random_distribution {0ll, 0ll}; }; }} diff --git a/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Select.cpp b/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Select.cpp index a345732b..f2316bb3 100644 --- a/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Select.cpp +++ b/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Select.cpp @@ -38,46 +38,41 @@ namespace kiwi { namespace engine { return std::make_unique & select_model = DataModel::declare(std::move(select_class), select_model); + auto& flip_class = (DataModel::declare(std::move(kiwi_class), flip_class); } std::unique_ptr Select::create(std::vector const& args) @@ -79,13 +81,15 @@ namespace kiwi { namespace model { } else { - if (index == getArguments().size()) + auto const& args = getArguments(); + + if (index == args.size()) { - description = "Ouptuts bang if input doesn't match"; + description = "Input if doesn't match"; } else { - description = "Outputs bang if input matches " + getArguments()[index].getString(); + description = "Outputs bang if input matches \"" + tool::AtomHelper::toString(args[index]) + "\""; } } diff --git a/README.md b/README.md index 14ac9dcb..4f5dad66 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,8 @@ Kiwi's documentation can be found [here](http://musicoll.github.io/Kiwi). Kiwi's ### Papers -- [JIM 2017](https://jim2017.sciencesconf.org/data/Eliott_Paris2017aa.pdf) (fr). +- [JIM 2017](https://hal.archives-ouvertes.fr/hal-01550190/document) (fr). +- [JIM 2018](https://hal.archives-ouvertes.fr/hal-01791492/document) (fr). --- diff --git a/Ressources/Project/Xcode/Info.plist b/Ressources/Project/Xcode/Info.plist index 6e2eecc1..9e33453b 100755 --- a/Ressources/Project/Xcode/Info.plist +++ b/Ressources/Project/Xcode/Info.plist @@ -15,9 +15,9 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0.0 + 1.0.1 CFBundleVersion - 1.0.0 + 1.0.1 NSHighResolutionCapable NSHumanReadableCopyright diff --git a/Scripts/setup-Win32.iss b/Scripts/setup-Win32.iss index 1578fb46..2d8710e4 100644 --- a/Scripts/setup-Win32.iss +++ b/Scripts/setup-Win32.iss @@ -2,7 +2,7 @@ ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "Kiwi" -#define MyAppVersion "v1.0.0-beta" +#define MyAppVersion "v1.0.1" #define MyAppPublisher "CICM" #define MyAppURL "http://kiwi.mshparisnord.fr/" #define MyAppExeName "Kiwi.exe" @@ -61,4 +61,3 @@ Root: HKCR; Subkey: "{#MyAppName}\shell\open\command"; ValueData: """{app}\{#My [Run] Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent - diff --git a/Scripts/setup-x64.iss b/Scripts/setup-x64.iss index 092da3f3..d51909f6 100644 --- a/Scripts/setup-x64.iss +++ b/Scripts/setup-x64.iss @@ -2,7 +2,7 @@ ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "Kiwi" -#define MyAppVersion "v1.0.0-beta" +#define MyAppVersion "v1.0.1" #define MyAppPublisher "CICM" #define MyAppURL "http://kiwi.mshparisnord.fr/" #define MyAppExeName "Kiwi.exe" @@ -61,4 +61,3 @@ Root: HKCR; Subkey: "{#MyAppName}\shell\open\command"; ValueData: """{app}\{#My [Run] Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent - diff --git a/docs/developper/dev.md b/docs/developper/dev.md index 592ed76a..a7136821 100644 --- a/docs/developper/dev.md +++ b/docs/developper/dev.md @@ -35,7 +35,7 @@ Here is a list of tested compilers depending on your platform. - MacOs: clang 7.3.1 - Windows: msvc 19.0 -- Linus: gcc-4.9 +- Linux: gcc-4.9 ```shell python ./Script/build.py @@ -85,7 +85,7 @@ The api server also uses a json file for its settings. Its easier to use the sam ex: ```json { - "session_port": 1000, + "session_port": 1000, "backend_directory": "server_backend", "open_token": "etienned@o", "kiwi_version": "v1.0.0" diff --git a/docs/software/getting-started.md b/docs/software/getting-started.md index 421af933..31e029b8 100644 --- a/docs/software/getting-started.md +++ b/docs/software/getting-started.md @@ -10,20 +10,19 @@ Kiwi is compatible with the three main operating system. - Macos : version 10.7 and later. - Windows : windows 7 and later. -- Linus : tested with ubuntu 14.04 +- Linux : tested with ubuntu 14.04 ## Installing -Once download is complete, the corresponding archive shall be extracted by double clicking on it. A Kiwi folder containing the application is then created. On macos and linux copy the application to your app folder (Application folder on Mac, /usr/bin on linux). Windows users may execute the installer. +Once download is complete, the corresponding archive shall be extracted by double clicking on it. A Kiwi folder containing the application is then created. On macOS and linux, copy the application to your app folder (Application folder on Mac, /usr/bin on linux). Windows users may execute the installer. -## Lauching Kiwi +## Launching Kiwi -When Kiwi is executed three main windows appear : The Document Browser, the Beacon Dispatcher and Kiwi's console. +When Kiwi is executed two main windows appear : The Document Browser and the Kiwi's console. -
diff --git a/docs/software/objects.md b/docs/software/objects.md index 0d78787b..f6f464ec 100644 --- a/docs/software/objects.md +++ b/docs/software/objects.md @@ -12,15 +12,15 @@ A list of help patches describing how each object works is