mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-12-02 22:28:14 +00:00
[idd] helper: implement mode deletion
Some checks failed
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / module (push) Has been cancelled
build / host-linux (push) Has been cancelled
build / host-windows-cross (push) Has been cancelled
build / host-windows-native (push) Has been cancelled
build / idd (push) Has been cancelled
build / obs (clang) (push) Has been cancelled
build / obs (gcc) (push) Has been cancelled
build / docs (push) Has been cancelled
Some checks failed
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / module (push) Has been cancelled
build / host-linux (push) Has been cancelled
build / host-windows-cross (push) Has been cancelled
build / host-windows-native (push) Has been cancelled
build / idd (push) Has been cancelled
build / obs (clang) (push) Has been cancelled
build / obs (gcc) (push) Has been cancelled
build / docs (push) Has been cancelled
This commit is contained in:
@@ -57,11 +57,20 @@ void CConfigWindow::updateFont()
|
|||||||
|
|
||||||
for (HWND child : std::initializer_list<HWND>({
|
for (HWND child : std::initializer_list<HWND>({
|
||||||
*m_version, *m_modeGroup, *m_modeBox, *m_widthLabel, *m_heightLabel, *m_refreshLabel,
|
*m_version, *m_modeGroup, *m_modeBox, *m_widthLabel, *m_heightLabel, *m_refreshLabel,
|
||||||
*m_modeWidth, *m_modeHeight, *m_modeRefresh, *m_modeUpdate,
|
*m_modeWidth, *m_modeHeight, *m_modeRefresh, *m_modeUpdate, *m_modeDelete,
|
||||||
}))
|
}))
|
||||||
SendMessage(child, WM_SETFONT, (WPARAM)m_font.Get(), 1);
|
SendMessage(child, WM_SETFONT, (WPARAM)m_font.Get(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CConfigWindow::updateModeList()
|
||||||
|
{
|
||||||
|
m_modeBox->addItem(L"<add new>", -1);
|
||||||
|
|
||||||
|
auto &modes = *m_modes;
|
||||||
|
for (size_t i = 0; i < modes.size(); ++i)
|
||||||
|
m_modeBox->addItem(modes[i].toString(), i);
|
||||||
|
}
|
||||||
|
|
||||||
LRESULT CConfigWindow::handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT CConfigWindow::handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (uMsg)
|
switch (uMsg)
|
||||||
@@ -95,13 +104,7 @@ LRESULT CConfigWindow::onCreate()
|
|||||||
|
|
||||||
m_modeBox.reset(new CListBox(WS_CHILD | WS_VISIBLE | WS_VSCROLL | LBS_NOTIFY, m_hwnd));
|
m_modeBox.reset(new CListBox(WS_CHILD | WS_VISIBLE | WS_VSCROLL | LBS_NOTIFY, m_hwnd));
|
||||||
if (m_modes)
|
if (m_modes)
|
||||||
{
|
updateModeList();
|
||||||
m_modeBox->addItem(L"<add new>", -1);
|
|
||||||
|
|
||||||
auto &modes = *m_modes;
|
|
||||||
for (size_t i = 0; i < modes.size(); ++i)
|
|
||||||
m_modeBox->addItem(modes[i].toString(), i);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_widthLabel.reset(new CStaticWidget(L"Width:", WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE, m_hwnd));
|
m_widthLabel.reset(new CStaticWidget(L"Width:", WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE, m_hwnd));
|
||||||
m_heightLabel.reset(new CStaticWidget(L"Height:", WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE, m_hwnd));
|
m_heightLabel.reset(new CStaticWidget(L"Height:", WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE, m_hwnd));
|
||||||
@@ -112,7 +115,9 @@ LRESULT CConfigWindow::onCreate()
|
|||||||
m_modeRefresh.reset(new CEditWidget(WS_CHILD | WS_VISIBLE | ES_LEFT, m_hwnd));
|
m_modeRefresh.reset(new CEditWidget(WS_CHILD | WS_VISIBLE | ES_LEFT, m_hwnd));
|
||||||
|
|
||||||
m_modeUpdate.reset(new CButton(L"Save", WS_CHILD | WS_VISIBLE, m_hwnd));
|
m_modeUpdate.reset(new CButton(L"Save", WS_CHILD | WS_VISIBLE, m_hwnd));
|
||||||
|
m_modeDelete.reset(new CButton(L"Delete", WS_CHILD | WS_VISIBLE, m_hwnd));
|
||||||
EnableWindow(*m_modeUpdate, FALSE);
|
EnableWindow(*m_modeUpdate, FALSE);
|
||||||
|
EnableWindow(*m_modeDelete, FALSE);
|
||||||
|
|
||||||
updateFont();
|
updateFont();
|
||||||
|
|
||||||
@@ -139,18 +144,18 @@ LRESULT CConfigWindow::onResize(DWORD width, DWORD height)
|
|||||||
pos.pinBottomLeft(*m_modeHeight, 75, 72, 50, 20);
|
pos.pinBottomLeft(*m_modeHeight, 75, 72, 50, 20);
|
||||||
pos.pinBottomLeft(*m_modeRefresh, 75, 48, 50, 20);
|
pos.pinBottomLeft(*m_modeRefresh, 75, 48, 50, 20);
|
||||||
pos.pinBottomLeft(*m_modeUpdate, 24, 20, 50, 24);
|
pos.pinBottomLeft(*m_modeUpdate, 24, 20, 50, 24);
|
||||||
|
pos.pinBottomLeft(*m_modeDelete, 75, 20, 50, 24);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd)
|
void CConfigWindow::onModeListSelectChange()
|
||||||
{
|
{
|
||||||
if (hwnd == *m_modeBox && code == LBN_SELCHANGE && m_modes)
|
|
||||||
{
|
|
||||||
int sel = m_modeBox->getSel();
|
int sel = m_modeBox->getSel();
|
||||||
if (sel == LB_ERR)
|
if (sel == LB_ERR)
|
||||||
{
|
{
|
||||||
EnableWindow(*m_modeUpdate, FALSE);
|
EnableWindow(*m_modeUpdate, FALSE);
|
||||||
return 0;
|
EnableWindow(*m_modeDelete, FALSE);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = m_modeBox->getData(sel);
|
int index = m_modeBox->getData(sel);
|
||||||
@@ -162,13 +167,15 @@ LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd)
|
|||||||
m_modeHeight->setNumericValue(mode.height);
|
m_modeHeight->setNumericValue(mode.height);
|
||||||
m_modeRefresh->setNumericValue(mode.refresh);
|
m_modeRefresh->setNumericValue(mode.refresh);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
m_modeWidth->setValue(L"");
|
|
||||||
m_modeHeight->setValue(L"");
|
|
||||||
m_modeRefresh->setValue(L"");
|
|
||||||
}
|
|
||||||
EnableWindow(*m_modeUpdate, TRUE);
|
EnableWindow(*m_modeUpdate, TRUE);
|
||||||
|
EnableWindow(*m_modeDelete, index >= 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd)
|
||||||
|
{
|
||||||
|
if (hwnd == *m_modeBox && code == LBN_SELCHANGE && m_modes)
|
||||||
|
{
|
||||||
|
onModeListSelectChange();
|
||||||
}
|
}
|
||||||
else if (hwnd == *m_modeUpdate && code == BN_CLICKED && m_modes)
|
else if (hwnd == *m_modeUpdate && code == BN_CLICKED && m_modes)
|
||||||
{
|
{
|
||||||
@@ -199,5 +206,22 @@ LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd)
|
|||||||
if (result != ERROR_SUCCESS)
|
if (result != ERROR_SUCCESS)
|
||||||
DEBUG_ERROR_HR(result, "Failed to save modes");
|
DEBUG_ERROR_HR(result, "Failed to save modes");
|
||||||
}
|
}
|
||||||
|
else if (hwnd == *m_modeDelete && code == BN_CLICKED && m_modes)
|
||||||
|
{
|
||||||
|
int sel = m_modeBox->getSel();
|
||||||
|
if (sel == LB_ERR)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
int index = m_modeBox->getData(sel);
|
||||||
|
m_modeBox->clear();
|
||||||
|
m_modes->erase(m_modes->begin() + index);
|
||||||
|
|
||||||
|
LRESULT result = m_settings.setModes(*m_modes);
|
||||||
|
if (result != ERROR_SUCCESS)
|
||||||
|
DEBUG_ERROR_HR(result, "Failed to save modes");
|
||||||
|
|
||||||
|
updateModeList();
|
||||||
|
onModeListSelectChange();
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ class CConfigWindow : public CWindow
|
|||||||
std::unique_ptr<CEditWidget> m_modeRefresh;
|
std::unique_ptr<CEditWidget> m_modeRefresh;
|
||||||
|
|
||||||
std::unique_ptr<CButton> m_modeUpdate;
|
std::unique_ptr<CButton> m_modeUpdate;
|
||||||
|
std::unique_ptr<CButton> m_modeDelete;
|
||||||
|
|
||||||
std::function<void()> m_onDestroy;
|
std::function<void()> m_onDestroy;
|
||||||
double m_scale;
|
double m_scale;
|
||||||
@@ -38,6 +39,8 @@ class CConfigWindow : public CWindow
|
|||||||
std::optional<std::vector<DisplayMode>> m_modes;
|
std::optional<std::vector<DisplayMode>> m_modes;
|
||||||
|
|
||||||
void updateFont();
|
void updateFont();
|
||||||
|
void updateModeList();
|
||||||
|
void onModeListSelectChange();
|
||||||
|
|
||||||
virtual LRESULT handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) override;
|
virtual LRESULT handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) override;
|
||||||
virtual LRESULT onCreate() override;
|
virtual LRESULT onCreate() override;
|
||||||
|
|||||||
@@ -50,3 +50,8 @@ void CListBox::setSel(int index)
|
|||||||
if (!ListBox_SetCurSel(m_hwnd, index))
|
if (!ListBox_SetCurSel(m_hwnd, index))
|
||||||
DEBUG_ERROR("listbox: failed to set selection to %d", index);
|
DEBUG_ERROR("listbox: failed to set selection to %d", index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CListBox::clear()
|
||||||
|
{
|
||||||
|
ListBox_ResetContent(m_hwnd);
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,4 +12,5 @@ public:
|
|||||||
int getSel();
|
int getSel();
|
||||||
int getData(int index);
|
int getData(int index);
|
||||||
void setSel(int index);
|
void setSel(int index);
|
||||||
|
void clear();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user