Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/mpc-hc/AppSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ CAppSettings::CAppSettings()
, nToolbarRightAction4(0)
, nToolbarType(INTERNAL_TOOLBAR)
, strToolbarName(L"")
, nToolbarAlignment(0)
, eAfterPlayback(AfterPlayback::DO_NOTHING)
, fUseDVDPath(false)
, idMenuLang(0)
Expand Down Expand Up @@ -1308,6 +1309,7 @@ void CAppSettings::SaveSettings(bool write_full_history /* = false */)
pApp->WriteProfileInt(IDS_R_PLAYERTOOLBAR, IDS_RS_TOOLBARRIGHTACTION4, nToolbarRightAction4);
pApp->WriteProfileInt(IDS_R_PLAYERTOOLBAR, IDS_RS_TOOLBAR_TYPE, nToolbarType);
pApp->WriteProfileString(IDS_R_PLAYERTOOLBAR, IDS_RS_TOOLBAR_NAME, strToolbarName);
pApp->WriteProfileInt(IDS_R_PLAYERTOOLBAR, IDS_RS_TOOLBAR_ALIGNMENT, nToolbarAlignment);


pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SAVEIMAGE_POSITION, bSaveImagePosition);
Expand Down Expand Up @@ -2259,6 +2261,7 @@ void CAppSettings::LoadSettings()
nToolbarRightAction4 = pApp->GetProfileInt(IDS_R_PLAYERTOOLBAR, IDS_RS_TOOLBARRIGHTACTION4, 0);
nToolbarType = (TOOLBAR_TYPE)pApp->GetProfileInt(IDS_R_PLAYERTOOLBAR, IDS_RS_TOOLBAR_TYPE, INTERNAL_TOOLBAR);
strToolbarName = pApp->GetProfileString(IDS_R_PLAYERTOOLBAR, IDS_RS_TOOLBAR_NAME, L"");
nToolbarAlignment = pApp->GetProfileInt(IDS_R_PLAYERTOOLBAR, IDS_RS_TOOLBAR_ALIGNMENT, 0);


bSaveImagePosition = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SAVEIMAGE_POSITION, TRUE);
Expand Down
1 change: 1 addition & 0 deletions src/mpc-hc/AppSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ class CAppSettings

TOOLBAR_TYPE nToolbarType;
CStringW strToolbarName;
int nToolbarAlignment;

// Logo
int nLogoId;
Expand Down
20 changes: 4 additions & 16 deletions src/mpc-hc/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9129,18 +9129,10 @@ void CMainFrame::OnUpdatePlayPauseStop(CCmdUI* pCmdUI)
pCmdUI->m_nID == ID_PLAY_PLAYPAUSE && (fs == State_Paused || fs == State_Running);

if (pCmdUI->m_nID == ID_PLAY_PLAY) {
CToolBarCtrl& toolbarCtrl = m_wndToolBar.GetToolBarCtrl();
int playbuttonstate = toolbarCtrl.GetState(ID_PLAY_PLAY);
if (fs == State_Running) {
if (!(playbuttonstate & TBSTATE_HIDDEN)) {
toolbarCtrl.SetState(ID_PLAY_PLAY, TBSTATE_HIDDEN);
toolbarCtrl.SetState(ID_PLAY_PAUSE, TBSTATE_ENABLED);
}
m_wndToolBar.SetPlayPauseActiveButton(ID_PLAY_PAUSE);
} else {
if (playbuttonstate & TBSTATE_HIDDEN) {
toolbarCtrl.SetState(ID_PLAY_PLAY, TBSTATE_ENABLED);
toolbarCtrl.SetState(ID_PLAY_PAUSE, TBSTATE_HIDDEN);
}
m_wndToolBar.SetPlayPauseActiveButton(ID_PLAY_PLAY);
}
}

Expand Down Expand Up @@ -9168,12 +9160,8 @@ void CMainFrame::OnUpdatePlayPauseStop(CCmdUI* pCmdUI)
fEnable = (pCmdUI->m_nID == ID_PLAY_PLAY || pCmdUI->m_nID == ID_PLAY_PLAYPAUSE) && !IsPlaylistEmpty();

if (pCmdUI->m_nID == ID_PLAY_PLAY) {
CToolBarCtrl& toolbarCtrl = m_wndToolBar.GetToolBarCtrl();
int playbuttonstate = toolbarCtrl.GetState(ID_PLAY_PLAY);
if (playbuttonstate & TBSTATE_HIDDEN) {
toolbarCtrl.SetState(ID_PLAY_PLAY, TBSTATE_ENABLED);
toolbarCtrl.SetState(ID_PLAY_PAUSE, TBSTATE_HIDDEN);
}
// Ensure play button is visible when no media is loaded
m_wndToolBar.SetPlayPauseActiveButton(ID_PLAY_PLAY);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/mpc-hc/MainFrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@ class CMainFrame : public CFrameWnd, public CDropClient
protected: // control bar embedded members
friend class CMainFrameControls;
friend class CPPageToolBarLayout;
friend class CPPageToolBar;
CMainFrameControls m_controls;
friend class CPlayerBar; // it notifies m_controls of panel re-dock

Expand Down
17 changes: 17 additions & 0 deletions src/mpc-hc/PPageToolBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ void CPPageToolBar::DoDataExchange(CDataExchange* pDX)
DDX_Control(pDX, IDC_COMBO7, m_cmbRightAction3);
DDX_Control(pDX, IDC_COMBO8, m_cmbRightAction4);
DDX_Control(pDX, IDC_COMBO9, m_cmbActiveTheme);
DDX_Control(pDX, IDC_COMBO10, m_cmbToolbarAlignment);

}

Expand Down Expand Up @@ -145,6 +146,11 @@ BOOL CPPageToolBar::OnInitDialog()
AddCmdToAction(s.nToolbarRightAction4, m_cmbRightAction4);
PopulateThemes();

m_cmbToolbarAlignment.AddString(ResStr(IDS_TOOLBAR_ALIGNMENT_LEFT));
m_cmbToolbarAlignment.AddString(ResStr(IDS_TOOLBAR_ALIGNMENT_CENTER));
m_cmbToolbarAlignment.AddString(ResStr(IDS_TOOLBAR_ALIGNMENT_RIGHT));
m_cmbToolbarAlignment.SetCurSel(s.nToolbarAlignment);

UpdateData(FALSE);

return TRUE;
Expand Down Expand Up @@ -282,6 +288,17 @@ BOOL CPPageToolBar::OnApply()
persistAction(s.nToolbarRightAction3, m_cmbRightAction3);
persistAction(s.nToolbarRightAction4, m_cmbRightAction4);

int nOldToolbarAlignment = s.nToolbarAlignment;
s.nToolbarAlignment = m_cmbToolbarAlignment.GetCurSel();

// Trigger layout recalculation if alignment changed
if (nOldToolbarAlignment != s.nToolbarAlignment) {
if (CMainFrame* pMainFrame = AfxGetMainFrame()) {
// Force the toolbar to recalculate its control positions
pMainFrame->m_wndToolBar.ArrangeControls();
pMainFrame->RecalcLayout();
}
}

return __super::OnApply();
}
Expand Down
1 change: 1 addition & 0 deletions src/mpc-hc/PPageToolBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class CPPageToolBar : public CMPCThemePPageBase
protected:
CMPCThemeSpinButtonCtrl m_DefaultToolbarSizeCtrl;
CMPCThemeComboBox m_cmbActiveTheme;
CMPCThemeComboBox m_cmbToolbarAlignment;
CMPCThemeComboBox m_cmbAction1, m_cmbAction2, m_cmbAction3, m_cmbAction4;
CMPCThemeComboBox m_cmbRightAction1, m_cmbRightAction2, m_cmbRightAction3, m_cmbRightAction4;

Expand Down
55 changes: 21 additions & 34 deletions src/mpc-hc/PPageToolBarLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ void CPPageToolBarLayout::LoadToolBarButtons() {
for (int i = 0; i < tbctrl.GetButtonCount(); i++) {
TBBUTTON button;
tbctrl.GetButton(i, &button);
if (button.fsStyle != TBBS_SEPARATOR && supportedButtons.count(button.idCommand)) {
// Skip separators and pause button (play/pause share same position)
if (button.fsStyle != TBBS_SEPARATOR &&
supportedButtons.count(button.idCommand) &&
button.idCommand != ID_PLAY_PAUSE) {
int index = m_list_active.InsertItem(LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM, i, tb.GetStringFromID(button.idCommand), 0, 0, DescriptiveIcon(button.idCommand), button.idCommand);
idsAdded.insert(button.idCommand);
}
Expand All @@ -84,7 +87,8 @@ void CPPageToolBarLayout::LoadToolBarButtons() {

std::map<int, WORD> idsSortedByIndex;
for (auto &[id, bInfo] : supportedButtons) {
if (0 == idsAdded.count(id) && bInfo.style != TBBS_SEPARATOR) {
// Skip separators and pause button (play/pause share same position)
if (0 == idsAdded.count(id) && bInfo.style != TBBS_SEPARATOR && id != ID_PLAY_PAUSE) {
idsSortedByIndex[bInfo.svgIndex] = id;
}
}
Expand Down Expand Up @@ -252,40 +256,14 @@ void CPPageToolBarLayout::OnUpdateDown(CCmdUI* pCmdUI) {
}


bool CPPageToolBarLayout::InsertButton(int beforeID, int buttonID) {
bool CPPageToolBarLayout::InsertButton(int beforeID, int buttonID, int existingStyle) {
CPlayerToolBar& tb = AfxGetMainFrame()->m_wndToolBar;
CToolBarCtrl& tbctrl = tb.GetToolBarCtrl();

for (int i = 0; i < tbctrl.GetButtonCount(); i++) {
TBBUTTON tButton;
tbctrl.GetButton(i, &tButton);
if (tButton.idCommand == beforeID) {
if (beforeID == ID_VOLUME_MUTE) {
i -= 1; //this is to force inserting before the hidden spacer
}
TBBUTTON button = tb.GetStandardButton(buttonID);
tbctrl.InsertButton(i, &button);
tb.ToolbarChange();
return true;
}
}
return false;
return tb.InsertButtonSafe(beforeID, buttonID, existingStyle);
}

bool CPPageToolBarLayout::DeleteButton(int buttonID) {
CPlayerToolBar& tb = AfxGetMainFrame()->m_wndToolBar;
CToolBarCtrl& tbctrl = tb.GetToolBarCtrl();

for (int i = 0; i < tbctrl.GetButtonCount(); i++) {
TBBUTTON tButton;
tbctrl.GetButton(i, &tButton);
if (tButton.idCommand == buttonID) {
tbctrl.DeleteButton(i);
tb.ToolbarChange();
return true;
}
}
return false;
return tb.DeleteButtonSafe(buttonID);
}

bool CPPageToolBarLayout::IsValidInsertPos(int destRow) {
Expand All @@ -304,12 +282,17 @@ bool CPPageToolBarLayout::IsValidInsertPos(int destRow) {
}
if (supportedButtons[tidCommand].positionLocked == CPlayerToolBar::LOCK_LEFT) {
return false;
} else {
}

// Check if prior item is locked to the right
if (destRow > 0) {
int priorIdCommand = (int)m_list_active.GetItemData(destRow - 1);
if (supportedButtons.count(priorIdCommand) == 0 || CPlayerToolBar::LOCK_RIGHT == supportedButtons[priorIdCommand].positionLocked) {
return false;
}
}
// If destRow == 0, prior item is leftSeparator which is LOCK_LEFT, but that's okay - we can insert after it

return true;
}

Expand Down Expand Up @@ -406,8 +389,10 @@ bool CPPageToolBarLayout::OrderButton(ButtonPosition pos) {
m_list_active.SetItemState(insertRow, LVIS_SELECTED, LVIS_SELECTED);
m_list_active.SetSelectionMark(insertRow);

// Capture style before delete for move operation
int buttonStyle = tb.GetButtonStyle(tb.CommandToIndex(buttonID));
DeleteButton(buttonID);
InsertButton(beforeID, buttonID);
InsertButton(beforeID, buttonID, buttonStyle);
break;
}
}
Expand All @@ -423,8 +408,10 @@ bool CPPageToolBarLayout::OrderButton(ButtonPosition pos) {

m_list_active.DeleteItem(selectedRow);

// Capture style before delete for move operation
int buttonStyle = tb.GetButtonStyle(tb.CommandToIndex(buttonID));
DeleteButton(buttonID);
InsertButton(beforeID, buttonID);
InsertButton(beforeID, buttonID, buttonStyle);
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/mpc-hc/PPageToolBarLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class CPPageToolBarLayout : public CMPCThemePPageBase
void LoadToolBarButtons();
virtual BOOL OnInitDialog() override;
virtual BOOL OnApply() override;
bool InsertButton(int beforeID, int buttonID);
bool InsertButton(int beforeID, int buttonID, int existingStyle = -1);
bool DeleteButton(int buttonID);
bool IsValidInsertPos(int destRow);
bool LeftSelectedButtonLocked();
Expand Down
Loading