2 * Copyright (C) 2016-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #include "ViewModeSettings.h"
11 #include "cores/VideoSettings.h"
12 #include "guilib/LocalizeStrings.h"
13 #include "settings/lib/SettingDefinitions.h"
15 struct ViewModeProperties
19 bool hideFromQuickCycle
= false;
20 bool hideFromList
= false;
23 #define HIDE_ITEM true
25 /** The list of all the view modes along with their properties
27 static const ViewModeProperties viewModes
[] =
29 { 630, ViewModeNormal
},
30 { 631, ViewModeZoom
},
31 { 39008, ViewModeZoom120Width
},
32 { 39009, ViewModeZoom110Width
},
33 { 632, ViewModeStretch4x3
},
34 { 633, ViewModeWideZoom
},
35 { 634, ViewModeStretch16x9
},
36 { 644, ViewModeStretch16x9Nonlin
, HIDE_ITEM
, HIDE_ITEM
},
37 { 635, ViewModeOriginal
},
38 { 636, ViewModeCustom
, HIDE_ITEM
}
41 #define NUMBER_OF_VIEW_MODES (sizeof(viewModes) / sizeof(viewModes[0]))
43 /** Gets the index of a view mode
45 * @param viewMode The view mode
46 * @return The index of the view mode in the viewModes array
48 static int GetViewModeIndex(int viewMode
)
52 // Find the current view mode
53 for (i
= 0; i
< NUMBER_OF_VIEW_MODES
; i
++)
55 if (viewModes
[i
].viewMode
== viewMode
)
59 return 0; // An invalid view mode will always return the first view mode
62 /** Gets the next view mode for quick cycling through the modes
64 * @param viewMode The current view mode
65 * @return The next view mode
67 int CViewModeSettings::GetNextQuickCycleViewMode(int viewMode
)
69 // Find the next quick cycle view mode
70 for (size_t i
= GetViewModeIndex(viewMode
) + 1; i
< NUMBER_OF_VIEW_MODES
; i
++)
72 if (!viewModes
[i
].hideFromQuickCycle
)
73 return viewModes
[i
].viewMode
;
76 return ViewModeNormal
;
79 /** Gets the string index for the view mode
81 * @param viewMode The current view mode
82 * @return The string index
84 int CViewModeSettings::GetViewModeStringIndex(int viewMode
)
86 return viewModes
[GetViewModeIndex(viewMode
)].stringIndex
;
89 /** Fills the list with all visible view modes
91 void CViewModeSettings::ViewModesFiller(const std::shared_ptr
<const CSetting
>& setting
,
92 std::vector
<IntegerSettingOption
>& list
,
96 // Add all appropriate view modes to the list control
97 for (const auto &item
: viewModes
)
99 if (!item
.hideFromList
)
100 list
.emplace_back(g_localizeStrings
.Get(item
.stringIndex
), item
.viewMode
);