Skip to content

Commit bbee33e

Browse files
authored
Merge pull request #29 from wuwao1/master
fix CListUI::AddAt && CListUI::Remove && CListUI::RemoveAt
2 parents 873e59e + 9160149 commit bbee33e

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

.github/workflows/msbuild.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
6+
name: MSBuild
7+
8+
on:
9+
push:
10+
branches: [ "master" ]
11+
pull_request:
12+
branches: [ "master" ]
13+
14+
env:
15+
# Path to the solution file relative to the root of the project.
16+
SOLUTION_FILE_PATH: .
17+
18+
# Configuration type to build.
19+
# You can convert this to a build matrix if you need coverage of multiple configuration types.
20+
# https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
21+
BUILD_CONFIGURATION: Release
22+
23+
permissions:
24+
contents: read
25+
26+
jobs:
27+
build:
28+
runs-on: windows-latest
29+
30+
steps:
31+
- uses: actions/checkout@v3
32+
33+
- name: Add MSBuild to PATH
34+
uses: microsoft/[email protected]
35+
36+
- name: Restore NuGet packages
37+
working-directory: ${{env.GITHUB_WORKSPACE}}
38+
run: nuget restore ${{env.SOLUTION_FILE_PATH}}
39+
40+
- name: Build
41+
working-directory: ${{env.GITHUB_WORKSPACE}}
42+
# Add additional options to the MSBuild command line here (like platform or verbosity level).
43+
# See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
44+
run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}}

DuiLib/Control/UIList.cpp

+36
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@ namespace DuiLib {
156156
}
157157
}
158158
if (m_iCurSel >= iIndex) m_iCurSel += 1;
159+
160+
std::vector<int> VecTempSelIndex;
161+
for (auto i = 0; i < m_aSelItems.GetSize(); i++)
162+
{
163+
int iSelIndex = (int)m_aSelItems.GetAt(i);
164+
if (iSelIndex >= iIndex)iSelIndex++;
165+
VecTempSelIndex.push_back(iSelIndex);
166+
}
167+
m_aSelItems.Empty();
168+
for (size_t i = 0; i < VecTempSelIndex.size(); i++)
169+
m_aSelItems.Add((void*)VecTempSelIndex[i]);
170+
159171
return true;
160172
}
161173

@@ -177,6 +189,18 @@ namespace DuiLib {
177189
}
178190
}
179191

192+
std::vector<int> VecTempSelIndex;
193+
for (auto i = 0; i < m_aSelItems.GetSize(); i++)
194+
{
195+
int iSelIndex = (int)m_aSelItems.GetAt(i);
196+
if (iSelIndex == iIndex)continue;
197+
if (iSelIndex > iIndex)iSelIndex--;
198+
VecTempSelIndex.push_back(iSelIndex);
199+
}
200+
m_aSelItems.Empty();
201+
for (size_t i = 0; i < VecTempSelIndex.size(); i++)
202+
m_aSelItems.Add((void*)VecTempSelIndex[i]);
203+
180204
if (iIndex == m_iCurSel && m_iCurSel >= 0) {
181205
int iSel = m_iCurSel;
182206
m_iCurSel = -1;
@@ -194,6 +218,18 @@ namespace DuiLib {
194218
if (pListItem) pListItem->SetIndex (i);
195219
}
196220

221+
std::vector<int> VecTempSelIndex;
222+
for (auto i = 0; i < m_aSelItems.GetSize(); i++)
223+
{
224+
int iSelIndex = (int)m_aSelItems.GetAt(i);
225+
if (iSelIndex == iIndex)continue;
226+
if (iSelIndex > iIndex)iSelIndex--;
227+
VecTempSelIndex.push_back(iSelIndex);
228+
}
229+
m_aSelItems.Empty();
230+
for (size_t i = 0; i < VecTempSelIndex.size(); i++)
231+
m_aSelItems.Add((void*)VecTempSelIndex[i]);
232+
197233
if (iIndex == m_iCurSel && m_iCurSel >= 0) {
198234
int iSel = m_iCurSel;
199235
m_iCurSel = -1;

DuiLib/Utils/WinImplBase.h

+6
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ namespace DuiLib {
4646
virtual CControlUI* CreateControl (faw::string_t pstrClass);
4747
LRESULT Invoke (std::function<LRESULT ()> f) { return ::SendMessage (m_hWnd, WM_USER + 0x101, 1, (LPARAM) &f); }
4848
void AsyncInvoke (std::function<LRESULT ()> f) { ::PostMessage (m_hWnd, WM_USER + 0x101, 0, (LPARAM) new decltype (f) (f)); }
49+
template<typename Func, typename... Args>
50+
void AsyncInvoke(Func func, Args... args) {
51+
auto boundFunc = std::bind(func, args...);
52+
auto* funcPtr = new std::function<decltype(func(args...))()>(boundFunc);
53+
::PostMessage(m_hWnd, WM_USER + 0x101, 0, reinterpret_cast<LPARAM>(funcPtr));
54+
}
4955
virtual faw::string_t QueryControlText (faw::string_t lpstrId, faw::string_t lpstrType);
5056

5157
virtual std::optional<LRESULT> MessageHandler (UINT uMsg, WPARAM wParam, LPARAM /*lParam*/);

0 commit comments

Comments
 (0)