Skip to content

Commit

Permalink
added IOsdChildElement, refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
A-tG committed May 1, 2022
1 parent 2f8ff66 commit acfd5b4
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 43 deletions.
17 changes: 11 additions & 6 deletions VoicemeeterOsdProgram/Factories/OsdContentFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ public static void FillOsdWindow(ref OsdControl osd, ref VoicemeeterParameterBas
m_selButtons = null;
}

public static void InitChildElement(IOsdChildElement element, StripElements type)
{
element.IsAlwaysVisible = () =>
{
return !element.IsNeverShow() &&
OptionsStorage.Osd.AlwaysShowElements.Contains(type);
};
element.IsNeverShow = () => OptionsStorage.Osd.NeverShowElements.Contains(type);
}

private static void InitVmParameters()
{
foreach (var p in m_vmParams)
Expand Down Expand Up @@ -191,12 +201,7 @@ private static void InitFader(StripControl strip)
{
var f = strip.FaderCont;
f.OsdParent = strip;
f.IsAlwaysVisible = () =>
{
return !f.IsNeverShow() &&
OptionsStorage.Osd.AlwaysShowElements.Contains(StripElements.Fader);
};
f.IsNeverShow = () => OptionsStorage.Osd.NeverShowElements.Contains(StripElements.Fader);
InitChildElement(f, StripElements.Fader);
}
}
}
36 changes: 5 additions & 31 deletions VoicemeeterOsdProgram/Factories/StripButtonFactory.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Windows;
using VoicemeeterOsdProgram.Options;
using VoicemeeterOsdProgram.Types;
using VoicemeeterOsdProgram.UiControls;
using VoicemeeterOsdProgram.UiControls.OSD.Strip;
Expand Down Expand Up @@ -44,25 +43,15 @@ public static ButtonContainer GetMonoWithReverse(IOsdRootElement parent)
public static ButtonContainer GetSolo(IOsdRootElement parent)
{
var btnCont = GetCommonBtnCont(parent);
btnCont.IsAlwaysVisible = () =>
{
return !btnCont.IsNeverShow() &&
OptionsStorage.Osd.AlwaysShowElements.Contains(StripElements.Solo);
};
btnCont.IsNeverShow = () => OptionsStorage.Osd.NeverShowElements.Contains(StripElements.Solo);
OsdContentFactory.InitChildElement(btnCont, StripElements.Solo);
btnCont.Btn.Style = (Style)btnCont.Resources["SoloBtnStyle"];
return btnCont;
}

public static ButtonContainer GetMute(IOsdRootElement parent)
{
var btnCont = GetCommonBtnCont(parent);
btnCont.IsAlwaysVisible = () =>
{
return !btnCont.IsNeverShow() &&
OptionsStorage.Osd.AlwaysShowElements.Contains(StripElements.Mute);
};
btnCont.IsNeverShow = () => OptionsStorage.Osd.NeverShowElements.Contains(StripElements.Mute);
OsdContentFactory.InitChildElement(btnCont, StripElements.Mute);

var btn = btnCont.Btn;
btn.Style = (Style)btnCont.Resources["MuteBtnStyle"];
Expand All @@ -87,25 +76,15 @@ public static ButtonContainer GetSel(IOsdRootElement parent)
public static ButtonContainer GetBusSelect(IOsdRootElement parent, string name)
{
var btnCont = GetCommonBtnCont(parent);
btnCont.IsAlwaysVisible = () =>
{
return !btnCont.IsNeverShow() &&
OptionsStorage.Osd.AlwaysShowElements.Contains(StripElements.Buses);
};
btnCont.IsNeverShow = () => OptionsStorage.Osd.NeverShowElements.Contains(StripElements.Buses);
OsdContentFactory.InitChildElement(btnCont, StripElements.Buses);
btnCont.Btn.Content = name;
return btnCont;
}

public static ButtonContainer GetEqOn(IOsdRootElement parent)
{
var btnCont = GetCommonBtnCont(parent);
btnCont.IsAlwaysVisible = () =>
{
return !btnCont.IsNeverShow() &&
OptionsStorage.Osd.AlwaysShowElements.Contains(StripElements.EQ);
};
btnCont.IsNeverShow = () => OptionsStorage.Osd.NeverShowElements.Contains(StripElements.EQ);
OsdContentFactory.InitChildElement(btnCont, StripElements.EQ);
var btn = btnCont.Btn;
btn.Content = "EQ";
btn.Style = (Style)btnCont.Resources["EqOnBtnStyle"];
Expand All @@ -122,12 +101,7 @@ private static ButtonContainer GetCommonBtnCont(IOsdRootElement parent)
private static ButtonContainer GetCommonMono(IOsdRootElement parent)
{
var btnCont = GetCommonBtnCont(parent);
btnCont.IsAlwaysVisible = () =>
{
return !btnCont.IsNeverShow() &&
OptionsStorage.Osd.AlwaysShowElements.Contains(StripElements.Mono);
};
btnCont.IsNeverShow = () => OptionsStorage.Osd.NeverShowElements.Contains(StripElements.Mono);
OsdContentFactory.InitChildElement(btnCont, StripElements.Mono);
return btnCont;
}
}
Expand Down
15 changes: 15 additions & 0 deletions VoicemeeterOsdProgram/Types/IOsdChildElement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VoicemeeterOsdProgram.Types
{
public interface IOsdChildElement
{
public Func<bool> IsAlwaysVisible { get; set; }

public Func<bool> IsNeverShow { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
using System;
using VoicemeeterOsdProgram.Core.Types;
using System.Windows;
using VoicemeeterOsdProgram.Types;

namespace VoicemeeterOsdProgram.UiControls.OSD.Strip
{
partial class ButtonContainer
partial class ButtonContainer : IOsdChildElement
{
public Func<bool> IsAlwaysVisible = () => false;
public Func<bool> IsNeverShow = () => false;
public Func<bool> IsAlwaysVisible { get; set; } = () => false;

public Func<bool> IsNeverShow { get; set; } = () => false;

private VoicemeeterNumParam m_vmParam;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
using VoicemeeterOsdProgram.Core.Types;
using System.Windows;
using VoicemeeterOsdProgram.Types;
using System;

namespace VoicemeeterOsdProgram.UiControls.OSD.Strip
{
partial class FaderContainer
partial class FaderContainer : IOsdChildElement
{
public Func<bool> IsAlwaysVisible { get; set; } = () => false;

public Func<bool> IsNeverShow { get; set; } = () => false;

private VoicemeeterNumParam m_vmParam;

public VoicemeeterNumParam VmParameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ namespace VoicemeeterOsdProgram.UiControls.OSD.Strip
public partial class FaderContainer : ContentControl
{
public IOsdRootElement OsdParent;
public Func<bool> IsAlwaysVisible = () => false;
public Func<bool> IsNeverShow = () => false;

private DoubleAnimation m_highlightAnim = new()
{
Expand Down

0 comments on commit acfd5b4

Please sign in to comment.