diff options
author | AlwinEsch <alwin.esch@web.de> | 2015-05-16 01:25:06 +0200 |
---|---|---|
committer | AchimTuran <wisler@kodi.tv> | 2015-07-19 18:54:29 +0200 |
commit | 00fbb189e7fe5ff8887ab66cb8a95193fc27150b (patch) | |
tree | 6b6f8d8d69572c46866f9bf3906fc71f67f74076 | |
parent | 1824cc84cc3cedb5ce5662e657f339fb686856ba (diff) |
[adsp] Add adsp mode processing chain settings dialog
-rw-r--r-- | addons/skin.confluence/720p/DialogAudioDSPManager.xml | 599 | ||||
-rw-r--r-- | project/VS2010Express/XBMC.vcxproj | 2 | ||||
-rw-r--r-- | project/VS2010Express/XBMC.vcxproj.filters | 5 | ||||
-rw-r--r-- | xbmc/cores/AudioEngine/DSPAddons/ActiveAEDSP.cpp | 12 | ||||
-rw-r--r-- | xbmc/dialogs/GUIDialogContextMenu.h | 1 | ||||
-rw-r--r-- | xbmc/guilib/GUIWindowManager.cpp | 5 | ||||
-rw-r--r-- | xbmc/guilib/WindowIDs.h | 1 | ||||
-rw-r--r-- | xbmc/input/ButtonTranslator.cpp | 1 | ||||
-rw-r--r-- | xbmc/settings/dialogs/GUIDialogAudioDSPManager.cpp | 1103 | ||||
-rw-r--r-- | xbmc/settings/dialogs/GUIDialogAudioDSPManager.h | 90 | ||||
-rw-r--r-- | xbmc/settings/dialogs/Makefile | 3 |
11 files changed, 1820 insertions, 2 deletions
diff --git a/addons/skin.confluence/720p/DialogAudioDSPManager.xml b/addons/skin.confluence/720p/DialogAudioDSPManager.xml new file mode 100644 index 0000000000..70446276bb --- /dev/null +++ b/addons/skin.confluence/720p/DialogAudioDSPManager.xml @@ -0,0 +1,599 @@ +<?xml version="1.0" encoding="UTF-8"?> +<window type="dialog"> + <zorder>1</zorder> + <defaultcontrol>9000</defaultcontrol> + <include>dialogeffect</include> + <allowoverlay>no</allowoverlay> + <coordinates> + <left>40</left> + <top>40</top> + </coordinates> + <controls> + <include>BehindDialogFadeOut</include> + <control type="image"> + <left>0</left> + <top>0</top> + <width>1200</width> + <height>640</height> + <texture border="40">$VAR[SelectBack]</texture> + <texture>dialogheader.png</texture> + </control> + <control type="group"> + <left>0</left> + <top>0</top> + <width>1200</width> + <height>40</height> + <control type="button"> + <description>dialog close button</description> + <left>1120</left> + <top>15</top> + <width>64</width> + <height>32</height> + <label>-</label> + <font>-</font> + <onclick>PreviousMenu</onclick> + <texturefocus>DialogCloseButton-focus.png</texturefocus> + <texturenofocus>DialogCloseButton.png</texturenofocus> + <visible>system.getbool(input.enablemouse)</visible> + <include>VisibleFadeEffect</include> + </control> + <control type="image"> + <description>dialog header image</description> + <centerleft>600</centerleft> + <top>16</top> + <width>1140</width> + <height>40</height> + <texture>dialogheader.png</texture> + </control> + <control type="label"> + <description>window header label</description> + <left>0</left> + <top>20</top> + <width>1200</width> + <height>30</height> + <font>font13_title</font> + <label>$LOCALIZE[15020]</label> + <align>center</align> + <aligny>center</aligny> + <textcolor>selected</textcolor> + <shadowcolor>black</shadowcolor> + </control> + </control> + <control type="list" id="9000"> + <description>processing mode selection list</description> + <left>30</left> + <top>70</top> + <width>1140</width> + <height>40</height> + <onup>9001</onup> + <ondown>200</ondown> + <onleft>9000</onleft> + <onright>9000</onright> + <orientation>horizontal</orientation> + <scrolltime tween="sine" easing="out">200</scrolltime> + <itemlayout width="228" height="40"> + <control type="image"> + <left>0</left> + <top>0</top> + <width>228</width> + <height>40</height> + <texture border="5">button-nofocus.png</texture> + </control> + <control type="label"> + <posx>5</posx> + <posy>0</posy> + <width>218</width> + <height>40</height> + <textcolor>grey3</textcolor> + <font>font13_title</font> + <aligny>center</aligny> + <align>center</align> + <info>ListItem.Label</info> + <scroll>false</scroll> + <scrollspeed>0</scrollspeed> + </control> + </itemlayout> + <focusedlayout width="228" height="40"> + <control type="image"> + <left>0</left> + <top>0</top> + <width>228</width> + <height>40</height> + <texture border="5">button-focus2.png</texture> + <animation effect="fade" start="100" end="50" time="0" condition="!Control.HasFocus(9000)">conditional</animation> + </control> + <control type="label"> + <posx>5</posx> + <posy>0</posy> + <width>218</width> + <height>40</height> + <textcolor>white</textcolor> + <font>font13_title</font> + <aligny>center</aligny> + <align>center</align> + <info>ListItem.Label</info> + <scroll>false</scroll> + <scrollspeed>0</scrollspeed> + </control> + </focusedlayout> + <content> + <description>processing mode selection list</description> + <item id="91"> + <label>1. $LOCALIZE[15057]</label> + <label2>$LOCALIZE[15114]</label2> + <visible>true</visible> + <onclick>noop</onclick> + <property name="currentMode">InputResampling</property> + </item> + <item id="92"> + <label>2. $LOCALIZE[15058]</label> + <label2>$LOCALIZE[15113]</label2> + <visible>true</visible> + <onclick>noop</onclick> + <property name="currentMode">Preprocessing</property> + </item> + <item id="93"> + <label>3. $LOCALIZE[15059]</label> + <label2>$LOCALIZE[15115]</label2> + <visible>true</visible> + <onclick>noop</onclick> + <property name="currentMode">Masterprocessing</property> + </item> + <item id="94"> + <label>4. $LOCALIZE[15060]</label> + <label2>$LOCALIZE[15117]</label2> + <visible>true</visible> + <onclick>noop</onclick> + <property name="currentMode">Postprocessing</property> + </item> + <item id="95"> + <label>5. $LOCALIZE[15061]</label> + <label2>$LOCALIZE[15116]</label2> + <visible>true</visible> + <onclick>noop</onclick> + <property name="currentMode">OutputResampling</property> + </item> + </content> + </control> + <control type="group"> + <description>white borders and mode description</description> + <left>30</left> + <top>109</top> + <width>1140</width> + <height>500</height> + <control type="image"> + <description>blue border</description> + <posx>0</posx> + <posy>0</posy> + <width>1140</width> + <height>500</height> + <texture border="5">button-focus3.png</texture> + <colordiffuse>80FFFFFF</colordiffuse> + </control> + <control type="label"> + <description>current mode description label</description> + <left>10</left> + <top>0</top> + <width>1120</width> + <height>30</height> + <font>font12</font> + <align>left</align> + <aligny>center</aligny> + <textcolor>white</textcolor> + <selectedcolor>selected</selectedcolor> + <label>$INFO[Container(9000).ListItem.Label2]</label> + </control> + </control> + <control type="group" id="200"> + <description>available- and active mode lists</description> + <left>30</left> + <top>150</top> + <width>1140</width> + <height>500</height> + <ondown>9001</ondown> + <onup>9000</onup> + <control type="group"> + <description>available modes group</description> + <left>0</left> + <top>0</top> + <width>570</width> + <height>360</height> + <control type="label"> + <description>blue available modes</description> + <left>25</left> + <top>2</top> + <width>550</width> + <height>30</height> + <font>font12_title</font> + <label>$LOCALIZE[15050] ($INFO[Container(20).NumItems])</label> + <align>center</align> + <aligny>center</aligny> + <textcolor>blue</textcolor> + <shadowcolor>black</shadowcolor> + </control> + <control type="image"> + <description>available modes list border</description> + <left>25</left> + <top>30</top> + <width>538</width> + <height>350</height> + <texture border="5">button-nofocus.png</texture> + </control> + <control type="scrollbar" id="60"> + <description>scrollbar for available modes list</description> + <left>5</left> + <top>30</top> + <width>25</width> + <height>350</height> + <texturesliderbackground border="0,14,0,14">ScrollBarV.png</texturesliderbackground> + <texturesliderbar border="0,14,0,14">ScrollBarV_bar.png</texturesliderbar> + <texturesliderbarfocus border="0,14,0,14">ScrollBarV_bar_focus.png</texturesliderbarfocus> + <textureslidernib>ScrollBarNib.png</textureslidernib> + <textureslidernibfocus>ScrollBarNib.png</textureslidernibfocus> + <onleft>61</onleft> + <onright>20</onright> + <showonepage>false</showonepage> + <orientation>vertical</orientation> + </control> + <control type="list" id="20"> + <description>available modes list</description> + <left>30</left> + <top>35</top> + <width>528</width> + <height>345</height> + <onup>9000</onup> + <ondown>9001</ondown> + <onleft>60</onleft> + <onright>21</onright> + <pagecontrol>60</pagecontrol> + <scrolltime>200</scrolltime> + <itemlayout height="46" width="528"> + <control type="image"> + <left>0</left> + <top>3</top> + <width>528</width> + <height>40</height> + <texture border="5">button-nofocus.png</texture> + </control> + <control type="image"> + <left>15</left> + <top>8</top> + <width>30</width> + <height>30</height> + <texture aligny="center" align="left">$INFO[ListItem.Property(Icon)]</texture> + <aspectratio>keep</aspectratio> + <visible>!StringCompare(ListItem.Property(Icon),"")</visible> + </control> + <control type="image"> + <left>15</left> + <top>8</top> + <width>30</width> + <height>30</height> + <texture aligny="center" align="left">DefaultAudioDSP.png</texture> + <aspectratio>keep</aspectratio> + <visible>StringCompare(ListItem.Property(Icon),"")</visible> + </control> + <control type="label"> + <description>active addon name and mode name</description> + <left>80</left> + <top>3</top> + <width>435</width> + <height>40</height> + <font>font12</font> + <align>left</align> + <aligny>center</aligny> + <textcolor>white</textcolor> + <scroll>false</scroll> + <selectedcolor>selected</selectedcolor> + <label>$INFO[ListItem.Property(AddonName)]: $INFO[ListItem.Property(Name)]</label> + </control> + </itemlayout> + <focusedlayout height="66" width="528"> + <control type="image"> + <left>0</left> + <top>3</top> + <width>528</width> + <height>60</height> + <texture border="5">button-focus2.png</texture> + <animation effect="fade" start="100" end="30" time="0" condition="!Control.HasFocus(20)">conditional</animation> + </control> + <control type="image"> + <left>5</left> + <top>8</top> + <width>50</width> + <height>50</height> + <texture aligny="center" align="left">$INFO[ListItem.Property(Icon)]</texture> + <aspectratio>keep</aspectratio> + <visible>!StringCompare(ListItem.Property(Icon),"")</visible> + </control> + <control type="image"> + <left>5</left> + <top>8</top> + <height>50</height> + <width>50</width> + <texture aligny="center" align="left">DefaultAudioDSP.png</texture> + <aspectratio>keep</aspectratio> + <visible>StringCompare(ListItem.Property(Icon),"")</visible> + </control> + <control type="label"> + <description>addon name and mode name on focus</description> + <left>80</left> + <top>3</top> + <width>435</width> + <height>40</height> + <font>font12</font> + <align>left</align> + <aligny>center</aligny> + <textcolor>white</textcolor> + <scroll>false</scroll> + <selectedcolor>selected</selectedcolor> + <label>$INFO[ListItem.Property(AddonName)]: $INFO[ListItem.Property(Name)]</label> + </control> + <control type="label"> + <description>ADSP-Mode description on focus</description> + <left>80</left> + <top>33</top> + <width>435</width> + <height>30</height> + <font>font12</font> + <align>left</align> + <aligny>center</aligny> + <textcolor>grey2</textcolor> + <scroll>false</scroll> + <selectedcolor>selected</selectedcolor> + <label>$INFO[ListItem.Property(Description)]</label> + <visible>!Control.HasFocus(20)</visible> + </control> + <control type="label"> + <description>ADSP-Mode description on focus</description> + <left>80</left> + <top>33</top> + <width>435</width> + <height>30</height> + <font>font12</font> + <align>left</align> + <aligny>center</aligny> + <textcolor>grey2</textcolor> + <scroll>true</scroll> + <scrollsuffix>> <</scrollsuffix> + <selectedcolor>selected</selectedcolor> + <label>$INFO[ListItem.Property(Description)]</label> + <visible>Control.HasFocus(20)</visible> + </control> + </focusedlayout> + </control> + </control> + <control type="group"> + <left>568</left> + <top>0</top> + <width>570</width> + <height>360</height> + <control type="label"> + <description>blue active modes</description> + <left>10</left> + <top>2</top> + <width>550</width> + <height>30</height> + <font>font12_title</font> + <label>$LOCALIZE[15051] ($INFO[Container(21).NumItems])</label> + <align>center</align> + <aligny>center</aligny> + <textcolor>blue</textcolor> + <shadowcolor>black</shadowcolor> + </control> + <control type="image"> + <description>active modes list border</description> + <left>10</left> + <top>30</top> + <width>538</width> + <height>350</height> + <texture border="5">button-nofocus.png</texture> + </control> + <control type="scrollbar" id="61"> + <description>scrollbar for active modes list</description> + <left>542</left> + <top>30</top> + <width>25</width> + <height>350</height> + <texturesliderbackground border="0,14,0,14">ScrollBarV.png</texturesliderbackground> + <texturesliderbar border="0,14,0,14">ScrollBarV_bar.png</texturesliderbar> + <texturesliderbarfocus border="0,14,0,14">ScrollBarV_bar_focus.png</texturesliderbarfocus> + <textureslidernib>ScrollBarNib.png</textureslidernib> + <textureslidernibfocus>ScrollBarNib.png</textureslidernibfocus> + <onleft>21</onleft> + <onright>60</onright> + <showonepage>false</showonepage> + <orientation>vertical</orientation> + </control> + <control type="list" id="21"> + <description>active modes list</description> + <left>15</left> + <top>35</top> + <width>538</width> + <height>345</height> + <onup>9000</onup> + <ondown>9001</ondown> + <onleft>20</onleft> + <onright>61</onright> + <pagecontrol>61</pagecontrol> + <scrolltime>200</scrolltime> + <itemlayout height="46" width="528"> + <control type="image"> + <left>0</left> + <top>3</top> + <width>528</width> + <height>40</height> + <texture border="5">button-nofocus.png</texture> + </control> + <control type="image"> + <left>15</left> + <top>8</top> + <width>30</width> + <height>30</height> + <texture aligny="center" align="left">$INFO[ListItem.Property(Icon)]</texture> + <aspectratio>keep</aspectratio> + <visible>!StringCompare(ListItem.Property(Icon),"")</visible> + </control> + <control type="image"> + <left>15</left> + <top>8</top> + <width>30</width> + <height>30</height> + <texture aligny="center" align="left">DefaultAudioDSP.png</texture> + <aspectratio>keep</aspectratio> + <visible>StringCompare(ListItem.Property(Icon),"")</visible> + </control> + <control type="label"> + <description>active addon name and mode name</description> + <left>80</left> + <top>3</top> + <width>435</width> + <height>40</height> + <font>font12</font> + <align>left</align> + <aligny>center</aligny> + <textcolor>white</textcolor> + <scroll>false</scroll> + <selectedcolor>selected</selectedcolor> + <label>$INFO[ListItem.Property(Number)]. $INFO[ListItem.Property(AddonName)]: $INFO[ListItem.Property(Name)]</label> + </control> + </itemlayout> + <focusedlayout height="66" width="528"> + <control type="image"> + <left>0</left> + <top>3</top> + <width>528</width> + <height>60</height> + <texture border="5">button-focus2.png</texture> + <animation effect="fade" start="100" end="30" time="0" condition="!Control.HasFocus(21)">conditional</animation> + </control> + <control type="image"> + <left>5</left> + <top>8</top> + <width>50</width> + <height>50</height> + <texture aligny="center" align="left">$INFO[ListItem.Property(Icon)]</texture> + <aspectratio>keep</aspectratio> + <visible>!StringCompare(ListItem.Property(Icon),"")</visible> + </control> + <control type="image"> + <left>5</left> + <top>8</top> + <height>50</height> + <width>50</width> + <texture aligny="center" align="left">DefaultAudioDSP.png</texture> + <aspectratio>keep</aspectratio> + <visible>StringCompare(ListItem.Property(Icon),"")</visible> + </control> + <control type="label"> + <description>addon name and mode name on focus</description> + <left>80</left> + <top>3</top> + <width>435</width> + <height>40</height> + <font>font12</font> + <align>left</align> + <aligny>center</aligny> + <textcolor>white</textcolor> + <scroll>false</scroll> + <selectedcolor>selected</selectedcolor> + <label>$INFO[ListItem.Property(Number)]. $INFO[ListItem.Property(AddonName)]: $INFO[ListItem.Property(Name)]</label> + <visible>true</visible> + </control> + <control type="label"> + <description>ADSP-Mode description on focus</description> + <left>80</left> + <top>33</top> + <width>435</width> + <height>30</height> + <font>font12</font> + <align>left</align> + <aligny>center</aligny> + <textcolor>grey2</textcolor> + <scroll>false</scroll> + <selectedcolor>selected</selectedcolor> + <label>$INFO[ListItem.Property(Description)]</label> + <visible>!Control.HasFocus(21)</visible> + </control> + <control type="label"> + <description>ADSP-Mode description on focus</description> + <left>80</left> + <top>33</top> + <width>435</width> + <height>30</height> + <font>font12</font> + <align>left</align> + <aligny>center</aligny> + <textcolor>grey2</textcolor> + <scroll>true</scroll> + <scrollsuffix>> <</scrollsuffix> + <selectedcolor>selected</selectedcolor> + <label>$INFO[ListItem.Property(Description)]</label> + <visible>Control.HasFocus(21)</visible> + </control> + </focusedlayout> + </control> + </control> + </control> + <control type="group" id="9001"> + <left>55</left> + <top>528</top> + <width>1090</width> + <control type="radiobutton" id="22"> + <description>Default RadioButton</description> + <left>0</left> + <top>15</top> + <height>40</height> + <width>280</width> + <onup>200</onup> + <ondown>9000</ondown> + <onleft>24</onleft> + <onright>23</onright> + <textwidth>252</textwidth> + <font>font13</font> + <textcolor>grey2</textcolor> + <focusedcolor>white</focusedcolor> + <texturefocus border="5">button-focus2.png</texturefocus> + <texturenofocus border="5">button-nofocus.png</texturenofocus> + <label>15064</label> + <include>ButtonCommonValues</include> + </control> + <control type="button" id="23"> + <description>Apply changes button</description> + <left>288</left> + <top>15</top> + <height>40</height> + <width>250</width> + <onup>200</onup> + <ondown>9000</ondown> + <onleft>22</onleft> + <onright>24</onright> + <font>font13</font> + <disabledcolor>15FFFFFF</disabledcolor> + <textcolor>grey3</textcolor> + <focusedcolor>white</focusedcolor> + <texturefocus border="5">button-focus2.png</texturefocus> + <label>14070</label> + <align>center</align> + </control> + <control type="button" id="24"> + <description>Clear active modes button</description> + <left>841</left> + <top>15</top> + <height>40</height> + <width>250</width> + <onup>200</onup> + <ondown>9000</ondown> + <onleft>23</onleft> + <onright>22</onright> + <font>font13</font> + <disabledcolor>30FFFFFF</disabledcolor> + <textcolor>grey3</textcolor> + <focusedcolor>white</focusedcolor> + <texturefocus border="5">button-focus2.png</texturefocus> + <label>15066</label> + <align>center</align> + </control> + </control> + </controls> +</window> diff --git a/project/VS2010Express/XBMC.vcxproj b/project/VS2010Express/XBMC.vcxproj index 179cfc69bc..f4465991ce 100644 --- a/project/VS2010Express/XBMC.vcxproj +++ b/project/VS2010Express/XBMC.vcxproj @@ -787,6 +787,7 @@ <ClCompile Include="..\..\xbmc\SectionLoader.cpp" /> <ClCompile Include="..\..\xbmc\settings\AdvancedSettings.cpp" /> <ClCompile Include="..\..\xbmc\settings\AudioDSPSettings.cpp" /> + <ClCompile Include="..\..\xbmc\settings\dialogs\GUIDialogAudioDSPManager.cpp" /> <ClCompile Include="..\..\xbmc\settings\dialogs\GUIDialogContentSettings.cpp" /> <ClCompile Include="..\..\xbmc\settings\dialogs\GUIDialogSettingsBase.cpp" /> <ClCompile Include="..\..\xbmc\settings\dialogs\GUIDialogSettingsManagerBase.cpp" /> @@ -1034,6 +1035,7 @@ <ClInclude Include="..\..\xbmc\profiles\windows\GUIWindowSettingsProfile.h" /> <ClInclude Include="..\..\xbmc\pvr\timers\PVRTimerType.h" /> <ClInclude Include="..\..\xbmc\settings\AudioDSPSettings.h" /> + <ClInclude Include="..\..\xbmc\settings\dialogs\GUIDialogAudioDSPManager.h" /> <ClInclude Include="..\..\xbmc\settings\dialogs\GUIDialogContentSettings.h" /> <ClInclude Include="..\..\xbmc\settings\dialogs\GUIDialogSettingsBase.h" /> <ClInclude Include="..\..\xbmc\settings\dialogs\GUIDialogSettingsManagerBase.h" /> diff --git a/project/VS2010Express/XBMC.vcxproj.filters b/project/VS2010Express/XBMC.vcxproj.filters index 2bc94026fa..ba51b16613 100644 --- a/project/VS2010Express/XBMC.vcxproj.filters +++ b/project/VS2010Express/XBMC.vcxproj.filters @@ -3098,6 +3098,9 @@ <Filter>music</Filter> </ClCompile> <ClCompile Include="..\..\xbmc\filesystem\NFSDirectory.cpp" /> + <ClCompile Include="..\..\xbmc\settings\dialogs\GUIDialogAudioDSPManager.cpp"> + <Filter>settings\dialogs</Filter> + </ClCompile> <ClCompile Include="..\..\xbmc\test\TestUtil.cpp"> <Filter>test</Filter> </ClCompile> @@ -6049,6 +6052,8 @@ </ClInclude> <ClInclude Include="..\..\xbmc\network\dacp\dacp.h"> <Filter>network\dacp</Filter> + <ClInclude Include="..\..\xbmc\settings\dialogs\GUIDialogAudioDSPManager.h"> + <Filter>settings\dialogs</Filter> </ClInclude> <ClInclude Include="..\..\xbmc\addons\ImageResource.h"> <Filter>addons</Filter> diff --git a/xbmc/cores/AudioEngine/DSPAddons/ActiveAEDSP.cpp b/xbmc/cores/AudioEngine/DSPAddons/ActiveAEDSP.cpp index 0f9fef4598..f36ff99d9c 100644 --- a/xbmc/cores/AudioEngine/DSPAddons/ActiveAEDSP.cpp +++ b/xbmc/cores/AudioEngine/DSPAddons/ActiveAEDSP.cpp @@ -45,6 +45,7 @@ extern "C" { #include "settings/MediaSettings.h" #include "settings/MediaSourceSettings.h" #include "settings/Settings.h" +#include "settings/dialogs/GUIDialogAudioDSPManager.h" #include "utils/StringUtils.h" #include "utils/JobManager.h" @@ -282,7 +283,16 @@ void CActiveAEDSP::OnSettingAction(const CSetting *setting) return; const std::string &settingId = setting->GetId(); - if (settingId == "audiooutput.dspresetdb") + if (settingId == "audiooutput.dspsettings") + { + if (IsActivated()) + { + CGUIDialogAudioDSPManager *dialog = (CGUIDialogAudioDSPManager *)g_windowManager.GetWindow(WINDOW_DIALOG_AUDIO_DSP_MANAGER); + if (dialog) + dialog->Open(); + } + } + else if (settingId == "audiooutput.dspresetdb") { if (CGUIDialogYesNo::ShowAndGetInput(19098, 36440, 750, 0)) { diff --git a/xbmc/dialogs/GUIDialogContextMenu.h b/xbmc/dialogs/GUIDialogContextMenu.h index 1cf08e2f24..19d65e959e 100644 --- a/xbmc/dialogs/GUIDialogContextMenu.h +++ b/xbmc/dialogs/GUIDialogContextMenu.h @@ -132,6 +132,7 @@ enum CONTEXT_BUTTON { CONTEXT_BUTTON_CANCELLED = 0, CONTEXT_BUTTON_EDIT_SORTTITLE, CONTEXT_BUTTON_UNDELETE, CONTEXT_BUTTON_DELETE_ALL, + CONTEXT_BUTTON_HELP, CONTEXT_BUTTON_USER1, CONTEXT_BUTTON_USER2, CONTEXT_BUTTON_USER3, diff --git a/xbmc/guilib/GUIWindowManager.cpp b/xbmc/guilib/GUIWindowManager.cpp index 6587e2f7c8..45e8a839e8 100644 --- a/xbmc/guilib/GUIWindowManager.cpp +++ b/xbmc/guilib/GUIWindowManager.cpp @@ -136,6 +136,7 @@ #include "dialogs/GUIDialogPlayEject.h" #include "dialogs/GUIDialogMediaFilter.h" #include "video/dialogs/GUIDialogSubtitles.h" +#include "settings/dialogs/GUIDialogAudioDSPManager.h" #ifdef HAS_KARAOKE #include "music/karaoke/GUIDialogKaraokeSongSelector.h" @@ -276,6 +277,8 @@ void CGUIWindowManager::CreateWindows() Add(new CGUIDialogPVRChannelsOSD); Add(new CGUIDialogPVRGuideOSD); + Add(new ActiveAE::CGUIDialogAudioDSPManager); + Add(new CGUIDialogSelect); Add(new CGUIDialogMusicInfo); Add(new CGUIDialogOK); @@ -372,6 +375,8 @@ bool CGUIWindowManager::DestroyWindows() Delete(WINDOW_DIALOG_PVR_OSD_GUIDE); Delete(WINDOW_DIALOG_OSD_TELETEXT); + Delete(WINDOW_DIALOG_AUDIO_DSP_MANAGER); + Delete(WINDOW_DIALOG_TEXT_VIEWER); Delete(WINDOW_DIALOG_PLAY_EJECT); Delete(WINDOW_STARTUP_ANIM); diff --git a/xbmc/guilib/WindowIDs.h b/xbmc/guilib/WindowIDs.h index 2548e2b32b..5d663aaf3a 100644 --- a/xbmc/guilib/WindowIDs.h +++ b/xbmc/guilib/WindowIDs.h @@ -104,6 +104,7 @@ #define WINDOW_DIALOG_EXT_PROGRESS 10151 #define WINDOW_DIALOG_MEDIA_FILTER 10152 #define WINDOW_DIALOG_SUBTITLES 10153 +#define WINDOW_DIALOG_AUDIO_DSP_MANAGER 10154 #define WINDOW_MUSIC_PLAYLIST 10500 #define WINDOW_MUSIC_FILES 10501 diff --git a/xbmc/input/ButtonTranslator.cpp b/xbmc/input/ButtonTranslator.cpp index 7c3ab02555..3200586303 100644 --- a/xbmc/input/ButtonTranslator.cpp +++ b/xbmc/input/ButtonTranslator.cpp @@ -353,6 +353,7 @@ static const ActionMapping windows[] = {"visualisationpresetlist" , WINDOW_DIALOG_VIS_PRESET_LIST}, {"osdvideosettings" , WINDOW_DIALOG_VIDEO_OSD_SETTINGS}, {"osdaudiosettings" , WINDOW_DIALOG_AUDIO_OSD_SETTINGS}, + {"audiodspmanager" , WINDOW_DIALOG_AUDIO_DSP_MANAGER}, {"videobookmarks" , WINDOW_DIALOG_VIDEO_BOOKMARKS}, {"filebrowser" , WINDOW_DIALOG_FILE_BROWSER}, {"networksetup" , WINDOW_DIALOG_NETWORK_SETUP}, diff --git a/xbmc/settings/dialogs/GUIDialogAudioDSPManager.cpp b/xbmc/settings/dialogs/GUIDialogAudioDSPManager.cpp new file mode 100644 index 0000000000..5ec7da844c --- /dev/null +++ b/xbmc/settings/dialogs/GUIDialogAudioDSPManager.cpp @@ -0,0 +1,1103 @@ +/* + * Copyright (C) 2012-2015 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "GUIDialogAudioDSPManager.h" + +#include "FileItem.h" +#include "cores/AudioEngine/DSPAddons/ActiveAEDSP.h" +#include "dialogs/GUIDialogTextViewer.h" +#include "dialogs/GUIDialogOK.h" +#include "dialogs/GUIDialogBusy.h" +#include "dialogs/GUIDialogYesNo.h" +#include "guilib/GUIWindowManager.h" +#include "guilib/LocalizeStrings.h" +#include "guilib/GUIListContainer.h" +#include "guilib/GUIRadioButtonControl.h" +#include "input/Key.h" +#include "utils/StringUtils.h" + +#define CONTROL_LIST_AVAILABLE 20 +#define CONTROL_LIST_ACTIVE 21 +#define CONTROL_RADIO_BUTTON_CONTINOUS_SAVING 22 +#define CONTROL_BUTTON_APPLY_CHANGES 23 +#define CONTROL_BUTTON_CLEAR_ACTIVE_MODES 24 +#define CONTROL_LIST_MODE_SELECTION 9000 + +#define LIST_AVAILABLE 0 +#define LIST_ACTIVE 1 + +#define LIST_INPUT_RESAMPLE 0 +#define LIST_PRE_PROCESS 1 +#define LIST_MASTER_PROCESS 2 +#define LIST_POST_PROCESS 3 +#define LIST_OUTPUT_RESAMPLE 4 + +using namespace std; +using namespace ActiveAE; + +typedef struct +{ + const char* sModeType; + int iModeType; +} DSP_MODE_TYPES; + +static const DSP_MODE_TYPES dsp_mode_types[] = { + { "preprocessing", AE_DSP_MODE_TYPE_PRE_PROCESS }, + { "inputresampling", AE_DSP_MODE_TYPE_INPUT_RESAMPLE }, + { "masterprocessing", AE_DSP_MODE_TYPE_MASTER_PROCESS }, + { "outputresampling", AE_DSP_MODE_TYPE_OUTPUT_RESAMPLE }, + { "postprocessing", AE_DSP_MODE_TYPE_POST_PROCESS }, + { "undefined", AE_DSP_MODE_TYPE_UNDEFINED } +}; + +CGUIDialogAudioDSPManager::CGUIDialogAudioDSPManager(void) + : CGUIDialog(WINDOW_DIALOG_AUDIO_DSP_MANAGER, "DialogAudioDSPManager.xml") +{ + m_bMovingMode = false; + m_bContainsChanges = false; + m_bContinousSaving = true; + m_iSelected[LIST_AVAILABLE] = 0; + m_iSelected[LIST_ACTIVE] = 0; + + for (int ii = 0; ii < AE_DSP_MODE_TYPE_MAX; ii++) + { + m_activeItems[ii] = new CFileItemList; + m_availableItems[ii] = new CFileItemList; + } + + m_iCurrentType = AE_DSP_MODE_TYPE_MASTER_PROCESS; +} + +CGUIDialogAudioDSPManager::~CGUIDialogAudioDSPManager(void) +{ + for (int ii = 0; ii < AE_DSP_MODE_TYPE_MAX; ii++) + { + delete m_activeItems[ii]; + delete m_availableItems[ii]; + } +} + +bool CGUIDialogAudioDSPManager::OnActionMove(const CAction &action) +{ + bool bReturn(false); + int iActionId = action.GetID(); + + if (GetFocusedControlID() == CONTROL_LIST_ACTIVE) + { + if (iActionId == ACTION_MOUSE_MOVE) + { + int iSelected = m_activeViewControl.GetSelectedItem(); + if (m_iSelected[LIST_ACTIVE] < iSelected) + { + iActionId = ACTION_MOVE_DOWN; + } + else if (m_iSelected[LIST_ACTIVE] > iSelected) + { + iActionId = ACTION_MOVE_UP; + } + else + { + return bReturn; + } + } + + if (iActionId == ACTION_MOVE_DOWN || iActionId == ACTION_MOVE_UP || + iActionId == ACTION_PAGE_DOWN || iActionId == ACTION_PAGE_UP) + { + bReturn = true; + CGUIDialog::OnAction(action); + + int iSelected = m_activeViewControl.GetSelectedItem(); + if (!m_bMovingMode) + { + if (iSelected != m_iSelected[LIST_ACTIVE]) + { + m_iSelected[LIST_ACTIVE] = iSelected; + } + } + else + { + bool bMoveUp = iActionId == ACTION_PAGE_UP || iActionId == ACTION_MOVE_UP; + unsigned int iLines = bMoveUp ? abs(m_iSelected[LIST_ACTIVE] - iSelected) : 1; + bool bOutOfBounds = bMoveUp ? m_iSelected[LIST_ACTIVE] <= 0 : m_iSelected[LIST_ACTIVE] >= m_activeItems[m_iCurrentType]->Size() - 1; + if (bOutOfBounds) + { + bMoveUp = !bMoveUp; + iLines = m_activeItems[m_iCurrentType]->Size() - 1; + } + + string strNumber; + for (unsigned int iLine = 0; iLine < iLines; iLine++) + { + unsigned int iNewSelect = bMoveUp ? m_iSelected[LIST_ACTIVE] - 1 : m_iSelected[LIST_ACTIVE] + 1; + if (m_activeItems[m_iCurrentType]->Get(iNewSelect)->GetProperty("Number").asString() != "-") + { + strNumber = StringUtils::Format("%i", m_iSelected[LIST_ACTIVE]+1); + m_activeItems[m_iCurrentType]->Get(iNewSelect)->SetProperty("Number", strNumber); + strNumber = StringUtils::Format("%i", iNewSelect+1); + m_activeItems[m_iCurrentType]->Get(m_iSelected[LIST_ACTIVE])->SetProperty("Number", strNumber); + } + m_activeItems[m_iCurrentType]->Swap(iNewSelect, m_iSelected[LIST_ACTIVE]); + m_iSelected[LIST_ACTIVE] = iNewSelect; + } + + SET_CONTROL_FOCUS(CONTROL_LIST_ACTIVE, 0); + + m_activeViewControl.SetItems(*m_activeItems[m_iCurrentType]); + m_activeViewControl.SetSelectedItem(m_iSelected[LIST_ACTIVE]); + } + } + } + + return bReturn; +} + +bool CGUIDialogAudioDSPManager::OnAction(const CAction& action) +{ + return OnActionMove(action) || + CGUIDialog::OnAction(action); +} + +void CGUIDialogAudioDSPManager::OnInitWindow() +{ + CGUIDialog::OnInitWindow(); + + m_iSelected[LIST_AVAILABLE] = 0; + m_iSelected[LIST_ACTIVE] = 0; + m_bMovingMode = false; + m_bContainsChanges = false; + + CGUIRadioButtonControl *radioButton = dynamic_cast<CGUIRadioButtonControl*>(GetControl(CONTROL_RADIO_BUTTON_CONTINOUS_SAVING)); + CGUIButtonControl *applyButton = dynamic_cast<CGUIButtonControl*>(GetControl(CONTROL_BUTTON_APPLY_CHANGES)); + if (!radioButton || !applyButton) + { + helper_LogError(__FUNCTION__); + return; + } + + SET_CONTROL_SELECTED(GetID(), CONTROL_RADIO_BUTTON_CONTINOUS_SAVING, m_bContinousSaving); + applyButton->SetEnabled(!m_bContinousSaving); + + Update(); + SetSelectedModeType(); +} + +void CGUIDialogAudioDSPManager::OnDeinitWindow(int nextWindowID) +{ + if (m_bContainsChanges) + { + if (m_bContinousSaving) + { + SaveList(); + } + else + { + bool canceled; + if (CGUIDialogYesNo::ShowAndGetInput(g_localizeStrings.Get(19098), g_localizeStrings.Get(15079), canceled, "", "")) +// if (CGUIDialogYesNo::ShowAndGetInput(19098, 15079, -1, -1)) + { + SaveList(); + } + else + { + m_bContinousSaving = false; + } + } + } + + Clear(); + + CGUIDialog::OnDeinitWindow(nextWindowID); +} + +bool CGUIDialogAudioDSPManager::OnClickListAvailable(CGUIMessage &message) +{ + int iAction = message.GetParam1(); + int iItem = m_availableViewControl.GetSelectedItem(); + + /* Check file item is in list range and get his pointer */ + if (iItem < 0 || iItem >= (int)m_availableItems[m_iCurrentType]->Size()) return true; + + /* Process actions */ + if (iAction == ACTION_SELECT_ITEM || iAction == ACTION_CONTEXT_MENU || iAction == ACTION_MOUSE_LEFT_CLICK || iAction == ACTION_MOUSE_RIGHT_CLICK) + { + /* Show Contextmenu */ + OnPopupMenu(iItem, LIST_AVAILABLE); + + return true; + } + + return false; +} + +bool CGUIDialogAudioDSPManager::OnClickListActive(CGUIMessage &message) +{ + if (!m_bMovingMode) + { + int iAction = message.GetParam1(); + int iItem = m_activeViewControl.GetSelectedItem(); + + /* Check file item is in list range and get his pointer */ + if (iItem < 0 || iItem >= (int)m_activeItems[m_iCurrentType]->Size()) return true; + + /* Process actions */ + if (iAction == ACTION_SELECT_ITEM || iAction == ACTION_CONTEXT_MENU || iAction == ACTION_MOUSE_LEFT_CLICK || iAction == ACTION_MOUSE_RIGHT_CLICK) + { + /* Show Contextmenu */ + OnPopupMenu(iItem, LIST_ACTIVE); + + return true; + } + } + else + { + CFileItemPtr pItem = m_activeItems[m_iCurrentType]->Get(m_iSelected[LIST_ACTIVE]); + if (pItem) + { + pItem->Select(false); + pItem->SetProperty("Changed", true); + m_bMovingMode = false; + m_bContainsChanges = true; + + if (m_bContinousSaving) + { + SaveList(); + } + + CGUIListContainer *modeList = dynamic_cast<CGUIListContainer*>(GetControl(CONTROL_LIST_MODE_SELECTION)); + CGUIButtonControl *applyButton = dynamic_cast<CGUIButtonControl*>(GetControl(CONTROL_BUTTON_APPLY_CHANGES)); + CGUIButtonControl *clearActiveModesButton = dynamic_cast<CGUIButtonControl*>(GetControl(CONTROL_BUTTON_CLEAR_ACTIVE_MODES)); + if (!modeList || !applyButton || !clearActiveModesButton) + { + helper_LogError(__FUNCTION__); + return false; + } + + // reenable all buttons and mode selection list + modeList->SetEnabled(true); + clearActiveModesButton->SetEnabled(true); + if (!m_bContinousSaving) + { + applyButton->SetEnabled(true); + } + + return true; + } + } + + return false; +} + +bool CGUIDialogAudioDSPManager::OnClickRadioContinousSaving(CGUIMessage &message) +{ + CGUIRadioButtonControl *radioButton = dynamic_cast<CGUIRadioButtonControl*>(GetControl(CONTROL_RADIO_BUTTON_CONTINOUS_SAVING)); + CGUIButtonControl *applyChangesButton = dynamic_cast<CGUIButtonControl*>(GetControl(CONTROL_BUTTON_APPLY_CHANGES)); + + if (!radioButton || !applyChangesButton) + { + helper_LogError(__FUNCTION__); + return false; + } + + if (!radioButton->IsSelected()) + { + applyChangesButton->SetEnabled(true); + m_bContinousSaving = false; + } + else + { + m_bContinousSaving = true; + applyChangesButton->SetEnabled(false); + } + + return true; +} + +bool CGUIDialogAudioDSPManager::OnClickApplyChanges(CGUIMessage &message) +{ + SaveList(); + return true; +} + +bool CGUIDialogAudioDSPManager::OnClickClearActiveModes(CGUIMessage &message) +{ + if (m_activeItems[m_iCurrentType]->Size() > 0) + { + for (int iItem = 0; iItem < m_activeItems[m_iCurrentType]->Size(); iItem++) + { + CFileItemPtr pItem = m_activeItems[m_iCurrentType]->Get(iItem); + if (pItem) + { + // remove mode from active mode list and add it to available mode list + CFileItemPtr newItem(dynamic_cast<CFileItem*>(pItem->Clone())); + newItem->SetProperty("ActiveMode", false); + newItem->SetProperty("Changed", true); + m_availableItems[m_iCurrentType]->Add(newItem); + } + } + m_activeItems[m_iCurrentType]->Clear(); + + // reorder available mode list, so that the mode order is always consistent + m_availableItems[m_iCurrentType]->ClearSortState(); + m_availableItems[m_iCurrentType]->Sort(SortByLabel, SortOrderAscending); + + // update active and available mode list + m_availableViewControl.SetItems(*m_availableItems[m_iCurrentType]); + m_activeViewControl.SetItems(*m_activeItems[m_iCurrentType]); + + m_bContainsChanges = true; + if (m_bContinousSaving) + { + SaveList(); + } + } + + return true; +} + +bool CGUIDialogAudioDSPManager::OnMessageClick(CGUIMessage &message) +{ + int iControl = message.GetSenderId(); + switch(iControl) + { + case CONTROL_LIST_AVAILABLE: + return OnClickListAvailable(message); + case CONTROL_LIST_ACTIVE: + return OnClickListActive(message); + case CONTROL_RADIO_BUTTON_CONTINOUS_SAVING: + return OnClickRadioContinousSaving(message); + case CONTROL_BUTTON_CLEAR_ACTIVE_MODES: + return OnClickClearActiveModes(message); + case CONTROL_BUTTON_APPLY_CHANGES: + return OnClickApplyChanges(message); + default: + return false; + } +} + +bool CGUIDialogAudioDSPManager::OnMessage(CGUIMessage& message) +{ + unsigned int iMessage = message.GetMessage(); + + switch (iMessage) + { + case GUI_MSG_CLICKED: + return OnMessageClick(message); + + case GUI_MSG_ITEM_SELECT: + { + int focusedControl = GetFocusedControlID(); + if (focusedControl == CONTROL_LIST_MODE_SELECTION) + { + CGUIListContainer *modeListPtr = dynamic_cast<CGUIListContainer*>(GetControl(CONTROL_LIST_MODE_SELECTION)); + + if (modeListPtr) + { + CGUIListItemPtr modeListItem = modeListPtr->GetListItem(0); // get current selected list item + if (modeListItem) + { + string currentModeString = modeListItem->GetProperty("currentMode").asString(); + int newModeType = helper_TranslateModeType(currentModeString); + + if (m_iCurrentType != newModeType) + { + m_iCurrentType = newModeType; + SetSelectedModeType(); + } + } + } + } + } + } + + return CGUIDialog::OnMessage(message); +} + +void CGUIDialogAudioDSPManager::OnWindowLoaded(void) +{ + g_graphicsContext.Lock(); + + m_availableViewControl.Reset(); + m_availableViewControl.SetParentWindow(GetID()); + m_availableViewControl.AddView(GetControl(CONTROL_LIST_AVAILABLE)); + + m_activeViewControl.Reset(); + m_activeViewControl.SetParentWindow(GetID()); + m_activeViewControl.AddView(GetControl(CONTROL_LIST_ACTIVE)); + + g_graphicsContext.Unlock(); + + CGUIDialog::OnWindowLoaded(); +} + +void CGUIDialogAudioDSPManager::OnWindowUnload(void) +{ + CGUIDialog::OnWindowUnload(); + + m_availableViewControl.Reset(); + m_activeViewControl.Reset(); +} + +bool CGUIDialogAudioDSPManager::OnPopupMenu(int iItem, int listType) +{ + // popup the context menu + // grab our context menu + CContextButtons buttons; + int listSize = 0; + CFileItemPtr pItem; + + if (listType == LIST_ACTIVE) + { + listSize = m_activeItems[m_iCurrentType]->Size(); + pItem = m_activeItems[m_iCurrentType]->Get(iItem); + } + else if (listType == LIST_AVAILABLE) + { + listSize = m_availableItems[m_iCurrentType]->Size(); + pItem = m_availableItems[m_iCurrentType]->Get(iItem); + } + + if (!pItem) + { + return false; + } + + // mark the item + if (iItem >= 0 && iItem < listSize) + { + pItem->Select(true); + } + else + { + return false; + } + + if (listType == LIST_ACTIVE) + { + if (listSize > 1) + { + buttons.Add(CONTEXT_BUTTON_MOVE, 116); /* Move mode up or down */ + } + buttons.Add(CONTEXT_BUTTON_ACTIVATE, 24021); /* Used to deactivate addon process type */ + } + else if (listType == LIST_AVAILABLE) + { + if (m_activeItems[m_iCurrentType]->Size() > 0 && (m_iCurrentType == AE_DSP_MODE_TYPE_INPUT_RESAMPLE || m_iCurrentType == AE_DSP_MODE_TYPE_OUTPUT_RESAMPLE)) + { + buttons.Add(CONTEXT_BUTTON_ACTIVATE, 15080); /* Used to swap addon resampling process type */ + } + else + { + buttons.Add(CONTEXT_BUTTON_ACTIVATE, 24022); /* Used to activate addon process type */ + } + } + + if (pItem->GetProperty("SettingsDialog").asInteger() != 0) + { + buttons.Add(CONTEXT_BUTTON_SETTINGS, 15078); /* Used to activate addon process type help description*/ + } + + if (pItem->GetProperty("Help").asInteger() > 0) + { + buttons.Add(CONTEXT_BUTTON_HELP, 15062); /* Used to activate addon process type help description*/ + } + + int choice = CGUIDialogContextMenu::ShowAndGetChoice(buttons); + + // deselect our item + if (iItem >= 0 && iItem < listSize) + { + pItem->Select(false); + } + + if (choice < 0) + { + return false; + } + + return OnContextButton(iItem, (CONTEXT_BUTTON)choice, listType); +} + +bool CGUIDialogAudioDSPManager::OnContextButton(int itemNumber, CONTEXT_BUTTON button, int listType) +{ + CFileItemPtr pItem; + int listSize = 0; + if (listType == LIST_ACTIVE) + { + pItem = m_activeItems[m_iCurrentType]->Get(itemNumber); + listSize = m_activeItems[m_iCurrentType]->Size(); + } + else if (listType == LIST_AVAILABLE) + { + pItem = m_availableItems[m_iCurrentType]->Get(itemNumber); + listSize = m_availableItems[m_iCurrentType]->Size(); + } + + /* Check file item is in list range and get his pointer */ + if (!pItem || itemNumber < 0 || itemNumber >= listSize) + { + return false; + } + + if (button == CONTEXT_BUTTON_HELP) + { + /*! + * Open audio dsp addon mode help text dialog + */ + AE_DSP_ADDON addon; + if (CActiveAEDSP::Get().GetAudioDSPAddon((int)pItem->GetProperty("AddonId").asInteger(), addon)) + { + CGUIDialogTextViewer* pDlgInfo = (CGUIDialogTextViewer*)g_windowManager.GetWindow(WINDOW_DIALOG_TEXT_VIEWER); + pDlgInfo->SetHeading(g_localizeStrings.Get(15062) + " - " + pItem->GetProperty("Name").asString()); + pDlgInfo->SetText(addon->GetString((uint32_t)pItem->GetProperty("Help").asInteger())); + pDlgInfo->DoModal(); + } + } + else if (button == CONTEXT_BUTTON_ACTIVATE) + { + /*! + * Deactivate selected processing mode + */ + if (pItem->GetProperty("ActiveMode").asBoolean()) + { + // remove mode from active mode list and add it to available mode list + CFileItemPtr newItem(dynamic_cast<CFileItem*>(pItem->Clone())); + newItem->SetProperty("ActiveMode", false); + newItem->SetProperty("Changed", true); + m_activeItems[m_iCurrentType]->Remove(itemNumber); + m_availableItems[m_iCurrentType]->Add(newItem); + } + else + { + /*! + * Activate selected processing mode + */ + if ((m_iCurrentType == AE_DSP_MODE_TYPE_INPUT_RESAMPLE || m_iCurrentType == AE_DSP_MODE_TYPE_OUTPUT_RESAMPLE) && m_activeItems[m_iCurrentType]->Size() > 0) + { // if there is already an active resampler, now we remove it + CFileItemPtr activeResampler = m_activeItems[m_iCurrentType]->Get(0); + if (activeResampler) + { + CFileItemPtr newItem(dynamic_cast<CFileItem*>(activeResampler->Clone())); + newItem->SetProperty("ActiveMode", false); + newItem->SetProperty("Changed", true); + + m_availableItems[m_iCurrentType]->Add(newItem); + // clear active list, because only one active resampling mode is supported by ActiveAEDSP + m_activeItems[m_iCurrentType]->Clear(); + } + } + + // remove mode from available mode list and add it to active mode list + CFileItemPtr newItem(dynamic_cast<CFileItem*>(pItem->Clone())); + + newItem->SetProperty("Number", (int)m_activeItems[m_iCurrentType]->Size() +1); + newItem->SetProperty("Changed", true); + newItem->SetProperty("ActiveMode", true); + + m_availableItems[m_iCurrentType]->Remove(itemNumber); + m_activeItems[m_iCurrentType]->Add(newItem); + } + + m_bContainsChanges = true; + if (m_bContinousSaving) + { + SaveList(); + } + + // reorder available mode list, so that the mode order is always consistent + m_availableItems[m_iCurrentType]->ClearSortState(); + m_availableItems[m_iCurrentType]->Sort(SortByLabel, SortOrderAscending); + + // update active and available mode list + Renumber(); + m_availableViewControl.SetItems(*m_availableItems[m_iCurrentType]); + m_activeViewControl.SetItems(*m_activeItems[m_iCurrentType]); + } + else if (button == CONTEXT_BUTTON_MOVE) + { + m_bMovingMode = true; + pItem->Select(true); + + CGUIListContainer *modeList = dynamic_cast<CGUIListContainer*>(GetControl(CONTROL_LIST_MODE_SELECTION)); + CGUIButtonControl *applyButton = dynamic_cast<CGUIButtonControl*>(GetControl(CONTROL_BUTTON_APPLY_CHANGES)); + CGUIButtonControl *clearActiveModesButton = dynamic_cast<CGUIButtonControl*>(GetControl(CONTROL_BUTTON_CLEAR_ACTIVE_MODES)); + if (!modeList || !applyButton || !clearActiveModesButton) + { + helper_LogError(__FUNCTION__); + return false; + } + + // if we are in MovingMode all buttons and mode selection list will be disabled! + modeList->SetEnabled(false); + clearActiveModesButton->SetEnabled(false); + if (!m_bContinousSaving) + { + applyButton->SetEnabled(false); + } + } + else if (button == CONTEXT_BUTTON_SETTINGS) + { + int hookId = (int)pItem->GetProperty("SettingsDialog").asInteger(); + if (hookId > 0) + { + AE_DSP_ADDON addon; + if (CActiveAEDSP::Get().GetAudioDSPAddon((int)pItem->GetProperty("AddonId").asInteger(), addon)) + { + AE_DSP_MENUHOOK hook; + AE_DSP_MENUHOOK_DATA hookData; + + hook.category = AE_DSP_MENUHOOK_ALL; + hook.iHookId = hookId; + hook.iRelevantModeId = (unsigned int)pItem->GetProperty("AddonModeNumber").asInteger(); + hookData.category = AE_DSP_MENUHOOK_ALL; + hookData.data.iStreamId = -1; + + /*! + * @note the addon dialog becomes always opened on the back of Kodi ones for this reason a + * "<animation effect="fade" start="100" end="0" time="400" condition="Window.IsVisible(Addon)">Conditional</animation>" + * on skin is needed to hide dialog. + */ + addon->CallMenuHook(hook, hookData); + } + } + else + { + CGUIDialogOK::ShowAndGetInput(19033, 0, 15040, 0); + } + } + + return true; +} + +void CGUIDialogAudioDSPManager::Update() +{ + CGUIDialogBusy* pDlgBusy = (CGUIDialogBusy*)g_windowManager.GetWindow(WINDOW_DIALOG_BUSY); + if (!pDlgBusy) + { + helper_LogError(__FUNCTION__); + return; + } + pDlgBusy->Show(); + + Clear(); + + AE_DSP_MODELIST modes; + CActiveAEDSPDatabase db; + if (!db.Open()) + { + pDlgBusy->Close(); + CLog::Log(LOGERROR, "DSP Manager - %s - Could not open DSP database for update!", __FUNCTION__); + return; + } + + for (int iModeType = 0; iModeType < AE_DSP_MODE_TYPE_MAX; iModeType++) + { + modes.clear(); + db.GetModes(modes, iModeType); + + // No modes available, nothing to do. + if (!modes.empty()) + { + AE_DSP_MENUHOOK_CAT menuHook = helper_GetMenuHookCategory(iModeType); + int continuesNo = 1; + for (unsigned int iModePtr = 0; iModePtr < modes.size(); iModePtr++) + { + CFileItem *listItem = helper_CreateModeListItem(modes[iModePtr].first, menuHook, &continuesNo); + if (listItem) + { + CFileItemPtr pItem(listItem); + + if (pItem->GetProperty("ActiveMode").asBoolean()) + { + m_activeItems[iModeType]->Add(pItem); + } + else + { + m_availableItems[iModeType]->Add(pItem); + } + } + g_windowManager.ProcessRenderLoop(false); + } + + m_availableItems[iModeType]->Sort(SortByLabel, SortOrderAscending); + if (iModeType == AE_DSP_MODE_TYPE_MASTER_PROCESS) + { + m_activeItems[iModeType]->Sort(SortByLabel, SortOrderAscending); + } + + } + } + + db.Close(); + + pDlgBusy->Close(); +} + +void CGUIDialogAudioDSPManager::SetSelectedModeType(void) +{ + /* lock our display, as this window is rendered from the player thread */ + g_graphicsContext.Lock(); + if (m_iCurrentType > AE_DSP_MODE_TYPE_UNDEFINED && m_iCurrentType < AE_DSP_MODE_TYPE_MAX && !m_bMovingMode) + { + m_availableViewControl.SetCurrentView(CONTROL_LIST_AVAILABLE); + m_activeViewControl.SetCurrentView(CONTROL_LIST_ACTIVE); + + m_availableViewControl.SetItems(*m_availableItems[m_iCurrentType]); + m_activeViewControl.SetItems(*m_activeItems[m_iCurrentType]); + } + + g_graphicsContext.Unlock(); +} + +void CGUIDialogAudioDSPManager::Clear(void) +{ + m_availableViewControl.Clear(); + m_activeViewControl.Clear(); + + for (int ii = 0; ii < AE_DSP_MODE_TYPE_MAX; ii++) + { + m_activeItems[ii]->Clear(); + m_availableItems[ii]->Clear(); + } +} + +void CGUIDialogAudioDSPManager::SaveList(void) +{ + if (!m_bContainsChanges) + return; + + /* display the progress dialog */ + CGUIDialogBusy* pDlgBusy = (CGUIDialogBusy*)g_windowManager.GetWindow(WINDOW_DIALOG_BUSY); + if (!pDlgBusy) + { + helper_LogError(__FUNCTION__); + return; + } + pDlgBusy->Show(); + + /* persist all modes */ + if (UpdateDatabase(pDlgBusy)) + { + CActiveAEDSP::Get().TriggerModeUpdate(); + + m_bContainsChanges = false; + SetItemsUnchanged(); + } + + pDlgBusy->Close(); +} + +bool CGUIDialogAudioDSPManager::UpdateDatabase(CGUIDialogBusy* pDlgBusy) +{ + CActiveAEDSPDatabase db; + if (!db.Open()) + { + CLog::Log(LOGERROR, "DSP Manager - %s - Could not open DSP database for update!", __FUNCTION__); + return false; + } + + // calculate available items + int maxItems = 0; + for (int i = 0; i < AE_DSP_MODE_TYPE_MAX; i++) + { + maxItems += m_activeItems[i]->Size() + m_availableItems[i]->Size(); + } + + int processedItems = 0; + for (int i = 0; i < AE_DSP_MODE_TYPE_MAX; i++) + { + for (int iListPtr = 0; iListPtr < m_activeItems[i]->Size(); iListPtr++) + { + CFileItemPtr pItem = m_activeItems[i]->Get(iListPtr); + if (pItem->GetProperty("Changed").asBoolean()) + { + bool success = db.UpdateMode( i, + pItem->GetProperty("ActiveMode").asBoolean(), + (int)pItem->GetProperty("AddonId").asInteger(), + (int)pItem->GetProperty("AddonModeNumber").asInteger(), + (int)pItem->GetProperty("Number").asInteger()); + + if (!success) + { + CLog::Log(LOGERROR, "DSP Manager - Could not update DSP database for active mode %i - %s!", + (int)pItem->GetProperty("AddonModeNumber").asInteger(), + pItem->GetProperty("Name").asString().c_str()); + } + } + + processedItems++; + if (pDlgBusy) + { + pDlgBusy->SetProgress((float)(processedItems * 100 / maxItems)); + + if (pDlgBusy->IsCanceled()) + { + return false; + } + } + + g_windowManager.ProcessRenderLoop(false); + } + + for (int iListPtr = 0; iListPtr < m_availableItems[i]->Size(); iListPtr++) + { + CFileItemPtr pItem = m_availableItems[i]->Get(iListPtr); + if (pItem && pItem->GetProperty("Changed").asBoolean()) + { + bool success = db.UpdateMode( i, + pItem->GetProperty("ActiveMode").asBoolean(), + (int)pItem->GetProperty("AddonId").asInteger(), + (int)pItem->GetProperty("AddonModeNumber").asInteger(), + (int)pItem->GetProperty("Number").asInteger()); + + if (!success) + { + CLog::Log(LOGERROR, "DSP Manager - Could not update DSP database for available mode %i - %s!", + (int)pItem->GetProperty("AddonModeNumber").asInteger(), + pItem->GetProperty("Name").asString().c_str()); + } + } + + processedItems++; + if (pDlgBusy) + { + pDlgBusy->SetProgress((float)(processedItems * 100 / maxItems)); + + if (pDlgBusy->IsCanceled()) + { + return false; + } + } + + g_windowManager.ProcessRenderLoop(false); + } + } + db.Close(); + return true; +} + +void CGUIDialogAudioDSPManager::SetItemsUnchanged() +{ + for (int i = 0; i < AE_DSP_MODE_TYPE_MAX; i++) + { + for (int iItemPtr = 0; iItemPtr < m_activeItems[i]->Size(); iItemPtr++) + { + CFileItemPtr pItem = m_activeItems[i]->Get(iItemPtr); + if (pItem) + pItem->SetProperty("Changed", false); + } + + for (int iItemPtr = 0; iItemPtr < m_availableItems[i]->Size(); iItemPtr++) + { + CFileItemPtr pItem = m_availableItems[i]->Get(iItemPtr); + if (pItem) + pItem->SetProperty("Changed", false); + } + } +} + +void CGUIDialogAudioDSPManager::Renumber(void) +{ + int iNextModeNumber(0); + string strNumber; + CFileItemPtr pItem; + + for (int iModePtr = 0; iModePtr < m_activeItems[m_iCurrentType]->Size(); iModePtr++) + { + pItem = m_activeItems[m_iCurrentType]->Get(iModePtr); + strNumber = StringUtils::Format("%i", ++iNextModeNumber); + pItem->SetProperty("Number", strNumber); + } +} + + +//! ---- Helper functions ---- + +void CGUIDialogAudioDSPManager::helper_LogError(const char *function) +{ + CLog::Log(LOGERROR, "DSP Manager - %s - GUI value error", function); +} + +int CGUIDialogAudioDSPManager::helper_TranslateModeType(string ModeString) +{ + int iType = AE_DSP_MODE_TYPE_UNDEFINED; + for (unsigned int ii = 0; ii < ARRAY_SIZE(dsp_mode_types) && iType == AE_DSP_MODE_TYPE_UNDEFINED; ii++) + { + if (StringUtils::EqualsNoCase(ModeString, dsp_mode_types[ii].sModeType)) + { + iType = dsp_mode_types[ii].iModeType; + } + } + + return iType; +} + +CFileItem *CGUIDialogAudioDSPManager::helper_CreateModeListItem(CActiveAEDSPModePtr &ModePointer, AE_DSP_MENUHOOK_CAT &MenuHook, int *ContinuesNo) +{ + CFileItem *pItem = NULL; + + if (!ContinuesNo) + { + return pItem; + } + + // start to get Addon and Mode properties + const int AddonID = ModePointer->AddonID(); + + string addonName; + if (!CActiveAEDSP::Get().GetAudioDSPAddonName(AddonID, addonName)) + { + return pItem; + } + + AE_DSP_ADDON addon; + if (!CActiveAEDSP::Get().GetAudioDSPAddon(AddonID, addon)) + { + return pItem; + } + + string modeName = addon->GetString(ModePointer->ModeName()); + + string description; + if (ModePointer->ModeDescription() > -1) + { + description = addon->GetString(ModePointer->ModeDescription()); + } + else + { + description = g_localizeStrings.Get(15063); + } + + bool isActive = ModePointer->IsEnabled(); + int number = ModePointer->ModePosition(); + int dialogId = helper_GetDialogId(ModePointer, MenuHook, addon, addonName); + // end to get Addon and Mode properties + + if (isActive) + { + if (number <= 0) + { + number = *ContinuesNo; + (*ContinuesNo)++; + } + + string str = StringUtils::Format("%i:%i:%i:%s", + number, + AddonID, + ModePointer->AddonModeNumber(), + ModePointer->AddonModeName().c_str()); + + pItem = new CFileItem(str); + } + else + { + pItem = new CFileItem(modeName); + } + + // set list item properties + pItem->SetProperty("ActiveMode", isActive); + pItem->SetProperty("Number", number); + pItem->SetProperty("Name", modeName); + pItem->SetProperty("Description", description); + pItem->SetProperty("Help", ModePointer->ModeHelp()); + pItem->SetProperty("Icon", ModePointer->IconOwnModePath()); + pItem->SetProperty("SettingsDialog", dialogId); + pItem->SetProperty("AddonId", AddonID); + pItem->SetProperty("AddonModeNumber", ModePointer->AddonModeNumber()); + pItem->SetProperty("AddonName", addonName); + pItem->SetProperty("Changed", false); + + return pItem; +} + +int CGUIDialogAudioDSPManager::helper_GetDialogId(CActiveAEDSPModePtr &ModePointer, AE_DSP_MENUHOOK_CAT &MenuHook, AE_DSP_ADDON &Addon, string AddonName) +{ + int dialogId = 0; + + if (ModePointer->HasSettingsDialog()) + { + AE_DSP_MENUHOOKS hooks; + + // Find first general settings dialog about mode + if (CActiveAEDSP::Get().GetMenuHooks(ModePointer->AddonID(), AE_DSP_MENUHOOK_SETTING, hooks)) + { + for (unsigned int i = 0; i < hooks.size() && dialogId == 0; i++) + { + if (hooks[i].iRelevantModeId == ModePointer->AddonModeNumber()) + { + dialogId = hooks[i].iHookId; + } + } + } + + // If nothing was present, check for playback settings + if (dialogId == 0 && CActiveAEDSP::Get().GetMenuHooks(ModePointer->AddonID(), MenuHook, hooks)) + { + for (unsigned int i = 0; i < hooks.size() && (dialogId == 0 || dialogId != -1); i++) + { + if (hooks[i].iRelevantModeId == ModePointer->AddonModeNumber()) + { + if (!hooks[i].bNeedPlayback) + { + dialogId = hooks[i].iHookId; + } + else + { + dialogId = -1; + } + } + } + } + + if (dialogId == 0) + CLog::Log(LOGERROR, "DSP Dialog Manager - %s - Present marked settings dialog of mode %s on addon %s not found", + __FUNCTION__, + Addon->GetString(ModePointer->ModeName()).c_str(), + AddonName.c_str()); + } + + return dialogId; +} + +AE_DSP_MENUHOOK_CAT CGUIDialogAudioDSPManager::helper_GetMenuHookCategory(int CurrentType) +{ + AE_DSP_MENUHOOK_CAT menuHook = AE_DSP_MENUHOOK_ALL; + switch (CurrentType) + { + case AE_DSP_MODE_TYPE_PRE_PROCESS: + menuHook = AE_DSP_MENUHOOK_PRE_PROCESS; + break; + case AE_DSP_MODE_TYPE_MASTER_PROCESS: + menuHook = AE_DSP_MENUHOOK_MASTER_PROCESS; + break; + case AE_DSP_MODE_TYPE_POST_PROCESS: + menuHook = AE_DSP_MENUHOOK_POST_PROCESS; + break; + case AE_DSP_MODE_TYPE_INPUT_RESAMPLE: + case AE_DSP_MODE_TYPE_OUTPUT_RESAMPLE: + menuHook = AE_DSP_MENUHOOK_RESAMPLE; + break; + default: + menuHook = AE_DSP_MENUHOOK_ALL; + break; + }; + + return menuHook; +} diff --git a/xbmc/settings/dialogs/GUIDialogAudioDSPManager.h b/xbmc/settings/dialogs/GUIDialogAudioDSPManager.h new file mode 100644 index 0000000000..df024d23c0 --- /dev/null +++ b/xbmc/settings/dialogs/GUIDialogAudioDSPManager.h @@ -0,0 +1,90 @@ +#pragma once +/* + * Copyright (C) 2012-2015 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "addons/include/kodi_adsp_types.h" +#include "cores/AudioEngine/DSPAddons/ActiveAEDSPMode.h" +#include "dialogs/GUIDialogContextMenu.h" +#include "guilib/GUIDialog.h" +#include "view/GUIViewControl.h" + +class CGUIDialogBusy; + +namespace ActiveAE +{ + class CGUIDialogAudioDSPManager : public CGUIDialog + { + public: + CGUIDialogAudioDSPManager(void); + virtual ~CGUIDialogAudioDSPManager(void); + virtual bool OnMessage(CGUIMessage& message); + virtual bool OnAction(const CAction& action); + virtual void OnWindowLoaded(void); + virtual void OnWindowUnload(void); + virtual bool HasListItems() const { return true; }; + + protected: + virtual void OnInitWindow(); + virtual void OnDeinitWindow(int nextWindowID); + + virtual bool OnPopupMenu(int iItem, int listType); + virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button, int listType); + + virtual bool OnActionMove(const CAction &action); + + virtual bool OnMessageClick(CGUIMessage &message); + + bool OnClickListAvailable(CGUIMessage &message); + bool OnClickListActive(CGUIMessage &message); + bool OnClickRadioContinousSaving(CGUIMessage &message); + bool OnClickApplyChanges(CGUIMessage &message); + bool OnClickClearActiveModes(CGUIMessage &message); + + void SetItemsUnchanged(void); + + private: + void Clear(void); + void Update(void); + void SaveList(void); + void Renumber(void); + bool UpdateDatabase(CGUIDialogBusy* pDlgBusy); + void SetSelectedModeType(void); + + //! helper function prototypes + static void helper_LogError(const char *function); + static int helper_TranslateModeType(std::string ModeString); + static CFileItem *helper_CreateModeListItem(CActiveAEDSPModePtr &ModePointer, AE_DSP_MENUHOOK_CAT &MenuHook, int *ContinuesNo); + static int helper_GetDialogId(CActiveAEDSPModePtr &ModePointer, AE_DSP_MENUHOOK_CAT &MenuHook, AE_DSP_ADDON &Addon, std::string AddonName); + static AE_DSP_MENUHOOK_CAT helper_GetMenuHookCategory(int CurrentType); + + bool m_bMovingMode; + bool m_bContainsChanges; + bool m_bContinousSaving; // if true, all settings are directly saved + + int m_iCurrentType; + int m_iSelected[AE_DSP_MODE_TYPE_MAX]; + + CFileItemList* m_activeItems[AE_DSP_MODE_TYPE_MAX]; + CFileItemList* m_availableItems[AE_DSP_MODE_TYPE_MAX]; + + CGUIViewControl m_availableViewControl; + CGUIViewControl m_activeViewControl; + }; +} diff --git a/xbmc/settings/dialogs/Makefile b/xbmc/settings/dialogs/Makefile index 4f382e1648..0e4c899e35 100644 --- a/xbmc/settings/dialogs/Makefile +++ b/xbmc/settings/dialogs/Makefile @@ -1,4 +1,5 @@ -SRCS=GUIDialogContentSettings.cpp \ +SRCS=GUIDialogAudioDSPManager.cpp \ + GUIDialogContentSettings.cpp \ GUIDialogSettingsBase.cpp \ GUIDialogSettingsManagerBase.cpp \ GUIDialogSettingsManualBase.cpp \ |