aseprite/src/base/scoped_value.h
David Capello 17adf56337 Fix issue 356: tooltips cause selecting tools require 1 or more extra mouse clicks
This is an old bug in the ui::Manager. We don't need to "free" (release)
the mouse widget when we re-stack windows order (e.g. because the user
clicked the non top-most window).
2014-04-13 22:47:40 -03:00

34 lines
666 B
C++

// Aseprite Base Library
// Copyright (c) 2014 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef BASE_SCOPED_VALUE_H_INCLUDED
#define BASE_SCOPED_VALUE_H_INCLUDED
#pragma once
namespace base {
template<typename T>
class ScopedValue {
public:
ScopedValue(T& instance, const T& inScopeValue, const T& outScopeValue)
: m_instance(instance)
, m_outScopeValue(outScopeValue) {
m_instance = inScopeValue;
}
~ScopedValue() {
m_instance = m_outScopeValue;
}
private:
T& m_instance;
T m_outScopeValue;
};
} // namespace base
#endif