/// QasTools: Desktop toolset for the Linux sound system ALSA.
/// \copyright See COPYING file.

#include "state.hpp"
#include <iostream>

namespace MState::Mixer
{

State::State ( Utility::Setup * parent_n )
: Utility::Setup ( parent_n )
, _sliders ( this )
, _switches ( this )
{
  _splitter_sizes.resize ( 2, 0 );
  _splitter_sizes[ 0 ] = 10000; // A value way too high
  _splitter_sizes[ 1 ] = 1;     // A value way too low

  _show_stream.fill ( true );
}

State::~State () = default;

bool
State::set_splitter_sizes ( const QList< int > & list_n )
{
  QList< int > lst = list_n;
  // Sanitize
  if ( lst.size () != 2 ) {
    lst.resize ( 2, 0 );
  }
  for ( int & size : lst ) {
    if ( size <= 0 ) {
      size = 1;
    }
  }
  return change ( _splitter_sizes, lst );
}

bool
State::set_show_stream ( std::size_t snd_dir_n, bool flag_n )
{
  return change ( _show_stream.at ( snd_dir_n ), flag_n );
}

bool
State::set_sort_stream_dir ( bool flag_n )
{
  return change ( _sort_stream_dir, flag_n );
}

} // namespace MState::Mixer
