Changeset View
Changeset View
Standalone View
Standalone View
effects/effect_builtins.cpp
Show First 20 Lines • Show All 686 Lines • ▼ Show 20 Line(s) | |||||
687 | 687 | | |||
688 | static inline int index(BuiltInEffect effect) | 688 | static inline int index(BuiltInEffect effect) | ||
689 | { | 689 | { | ||
690 | return static_cast<int>(effect); | 690 | return static_cast<int>(effect); | ||
691 | } | 691 | } | ||
692 | 692 | | |||
693 | Effect *create(BuiltInEffect effect) | 693 | Effect *create(BuiltInEffect effect) | ||
694 | { | 694 | { | ||
695 | const EffectData &effectData = s_effectData.at(index(effect)); | 695 | const EffectData &data = effectData(effect); | ||
696 | if (effectData.createFunction == nullptr) { | 696 | if (data.createFunction == nullptr) { | ||
697 | return nullptr; | 697 | return nullptr; | ||
698 | } | 698 | } | ||
699 | return effectData.createFunction(); | 699 | return data.createFunction(); | ||
700 | } | 700 | } | ||
701 | 701 | | |||
702 | bool available(const QString &name) | 702 | bool available(const QString &name) | ||
703 | { | 703 | { | ||
704 | auto it = std::find_if(s_effectData.begin(), s_effectData.end(), | 704 | auto it = std::find_if(s_effectData.begin(), s_effectData.end(), | ||
705 | [name](const EffectData &data) { | 705 | [name](const EffectData &data) { | ||
706 | return data.name == name; | 706 | return data.name == name; | ||
707 | } | 707 | } | ||
708 | ); | 708 | ); | ||
709 | return it != s_effectData.end(); | 709 | return it != s_effectData.end(); | ||
710 | } | 710 | } | ||
711 | 711 | | |||
712 | bool supported(BuiltInEffect effect) | 712 | bool supported(BuiltInEffect effect) | ||
713 | { | 713 | { | ||
714 | if (effect == BuiltInEffect::Invalid) { | 714 | if (effect == BuiltInEffect::Invalid) { | ||
715 | return false; | 715 | return false; | ||
716 | } | 716 | } | ||
717 | const EffectData &effectData = s_effectData.at(index(effect)); | 717 | const EffectData &data = effectData(effect); | ||
718 | if (effectData.supportedFunction == nullptr) { | 718 | if (data.supportedFunction == nullptr) { | ||
719 | return true; | 719 | return true; | ||
720 | } | 720 | } | ||
721 | return effectData.supportedFunction(); | 721 | return data.supportedFunction(); | ||
722 | } | 722 | } | ||
723 | 723 | | |||
724 | bool checkEnabledByDefault(BuiltInEffect effect) | 724 | bool checkEnabledByDefault(BuiltInEffect effect) | ||
725 | { | 725 | { | ||
726 | if (effect == BuiltInEffect::Invalid) { | 726 | if (effect == BuiltInEffect::Invalid) { | ||
727 | return false; | 727 | return false; | ||
728 | } | 728 | } | ||
729 | const EffectData &effectData = s_effectData.at(index(effect)); | 729 | const EffectData &data = effectData(effect); | ||
730 | if (effectData.enabledFunction == nullptr) { | 730 | if (data.enabledFunction == nullptr) { | ||
731 | return true; | 731 | return true; | ||
732 | } | 732 | } | ||
733 | return effectData.enabledFunction(); | 733 | return data.enabledFunction(); | ||
734 | } | 734 | } | ||
735 | 735 | | |||
736 | bool enabledByDefault(BuiltInEffect effect) | 736 | bool enabledByDefault(BuiltInEffect effect) | ||
737 | { | 737 | { | ||
738 | const EffectData &effectData = s_effectData.at(index(effect)); | 738 | return effectData(effect).enabled; | ||
739 | return effectData.enabled; | | |||
740 | } | 739 | } | ||
741 | 740 | | |||
742 | QStringList availableEffectNames() | 741 | QStringList availableEffectNames() | ||
743 | { | 742 | { | ||
744 | QStringList result; | 743 | QStringList result; | ||
745 | for (const EffectData &data : s_effectData) { | 744 | for (const EffectData &data : s_effectData) { | ||
746 | if (data.name.isEmpty()) { | 745 | if (data.name.isEmpty()) { | ||
747 | continue; | 746 | continue; | ||
Show All 22 Lines | 763 | { | |||
770 | if (it == s_effectData.end()) { | 769 | if (it == s_effectData.end()) { | ||
771 | return BuiltInEffect::Invalid; | 770 | return BuiltInEffect::Invalid; | ||
772 | } | 771 | } | ||
773 | return BuiltInEffect(std::distance(s_effectData.begin(), it)); | 772 | return BuiltInEffect(std::distance(s_effectData.begin(), it)); | ||
774 | } | 773 | } | ||
775 | 774 | | |||
776 | QString nameForEffect(BuiltInEffect effect) | 775 | QString nameForEffect(BuiltInEffect effect) | ||
777 | { | 776 | { | ||
778 | return s_effectData.at(index(effect)).name; | 777 | return effectData(effect).name; | ||
779 | } | 778 | } | ||
780 | 779 | | |||
781 | const EffectData &effectData(BuiltInEffect effect) | 780 | const EffectData &effectData(BuiltInEffect effect) | ||
782 | { | 781 | { | ||
783 | return s_effectData.at(index(effect)); | 782 | return s_effectData.at(index(effect)); | ||
784 | } | 783 | } | ||
785 | 784 | | |||
786 | } // BuiltInEffects | 785 | } // BuiltInEffects | ||
787 | 786 | | |||
788 | } // namespace | 787 | } // namespace |