Add remaining files
[juce-lv2.git] / juce / source / extras / Introjucer / Source / Utility / jucer_ValueSourceHelpers.h
bloba7ea1a121bd89621c8a12364403678498b9b7c06
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-10 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #ifndef __JUCER_VALUEREMAPPERSOURCE_JUCEHEADER__
27 #define __JUCER_VALUEREMAPPERSOURCE_JUCEHEADER__
30 //==============================================================================
31 /**
33 template <typename Type>
34 class NumericValueSource : public Value::ValueSource,
35 public Value::Listener
37 public:
38 NumericValueSource (const Value& sourceValue_)
39 : sourceValue (sourceValue_)
41 sourceValue.addListener (this);
44 void valueChanged (Value&) { sendChangeMessage (true); }
45 var getValue() const { return (Type) sourceValue.getValue(); }
47 void setValue (const var& newValue)
49 const Type newVal = (Type) newValue;
51 if (newVal != (Type) getValue()) // this test is important, because if a property is missing, it won't
52 sourceValue = newVal; // create it (causing an unwanted undo action) when a control sets it to 0
55 //==============================================================================
56 protected:
57 Value sourceValue;
59 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NumericValueSource);
63 #endif // __JUCER_VALUEREMAPPERSOURCE_JUCEHEADER__