reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

control.cpp (1340B)


      1 /* ReaPack: Package manager for REAPER
      2  * Copyright (C) 2015-2025  Christian Fillion
      3  *
      4  * This program is free software: you can redistribute it and/or modify
      5  * it under the terms of the GNU Lesser General Public License as published by
      6  * the Free Software Foundation, either version 3 of the License, or
      7  * (at your option) any later version.
      8  *
      9  * This program is distributed in the hope that it will be useful,
     10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12  * GNU Lesser General Public License for more details.
     13  *
     14  * You should have received a copy of the GNU Lesser General Public License
     15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     16  */
     17 
     18 #include "control.hpp"
     19 
     20 #include <map>
     21 
     22 void InhibitControl::setRedraw(const bool inhibit)
     23 {
     24   static std::map<HWND, InhibitControl *> s_lock;
     25 
     26   auto owner = s_lock.find(m_handle);
     27 
     28   if(owner != s_lock.end()) {
     29     if(inhibit || owner->second != this)
     30       return;
     31   }
     32   else if(!inhibit)
     33     return;
     34 
     35   SendMessage(m_handle, WM_SETREDRAW, !inhibit, 0);
     36 
     37   if(inhibit)
     38     s_lock.insert({m_handle, this});
     39   else {
     40     s_lock.erase(owner);
     41 #ifdef _WIN32
     42     RedrawWindow(m_handle, nullptr, nullptr,
     43       RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
     44 #endif
     45   }
     46 }