Esempio n. 1
0
void ToolbarButton::setCurrentImage (Drawable* const newImage)
{
    if (newImage != currentImage)
    {
        removeChildComponent (currentImage);
        currentImage = newImage;

        if (currentImage != nullptr)
        {
            enablementChanged();
            addAndMakeVisible (currentImage);
            updateDrawable();
        }
    }
}
Esempio n. 2
0
        void on_sourceAdded(const OSSIA::Value* val)
        {
            auto str_val = dynamic_cast<const OSSIA::String*>(val);
            if(!str_val)
                return;

            // Create the sound
            auto sound_obj = new SoundObj{str_val->value};
            sound_obj->setParent(&m_scene);
            m_scene.sounds().insert(sound_obj);
            auto& sound = sound_obj->sound;

            // Create the callbacks and OSC device commands
            auto src_node = *m_sourcesListNode->emplace(m_sourcesListNode->children().cend(), str_val->value);

            // Position
            auto src_pos_node = *src_node->emplace(src_node->children().cend(), "pos");
            add_position(src_pos_node,
                         make_parameter(
                             [&] () { return sound.source().Position(); },
                             [&] (const auto& elt) { sound.source().Position(elt); }
            ));

            // Enablement
            add_child(src_node, "enabled", OSSIA::Value::Type::BOOL,
                      [&,sound_obj] (const OSSIA::Value* val) {
                auto enablement_val = dynamic_cast<const OSSIA::Bool*>(val);
                if(!enablement_val)
                    return;
                sound_obj->enablementChanged(enablement_val->value);
            });

            // Audio file
            add_child(src_node, "file", OSSIA::Value::Type::STRING,
                      [&,sound_obj] (const OSSIA::Value* val) {
                auto filename_val = dynamic_cast<const OSSIA::String*>(val);
                if(!filename_val)
                    return;

                sound_obj->fileChanged(QString::fromStdString(filename_val->value));
            });
        }