Skip to content

Commit

Permalink
Merge pull request #29 from wuwao1/master
Browse files Browse the repository at this point in the history
fix CListUI::AddAt && CListUI::Remove && CListUI::RemoveAt
  • Loading branch information
fawdlstty committed Mar 6, 2024
2 parents 873e59e + 9160149 commit bbee33e
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/msbuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: MSBuild

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

env:
# Path to the solution file relative to the root of the project.
SOLUTION_FILE_PATH: .

# Configuration type to build.
# You can convert this to a build matrix if you need coverage of multiple configuration types.
# https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
BUILD_CONFIGURATION: Release

permissions:
contents: read

jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v3

- name: Add MSBuild to PATH
uses: microsoft/[email protected]

- name: Restore NuGet packages
working-directory: ${{env.GITHUB_WORKSPACE}}
run: nuget restore ${{env.SOLUTION_FILE_PATH}}

- name: Build
working-directory: ${{env.GITHUB_WORKSPACE}}
# Add additional options to the MSBuild command line here (like platform or verbosity level).
# See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}}
36 changes: 36 additions & 0 deletions DuiLib/Control/UIList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ namespace DuiLib {
}
}
if (m_iCurSel >= iIndex) m_iCurSel += 1;

std::vector<int> VecTempSelIndex;
for (auto i = 0; i < m_aSelItems.GetSize(); i++)
{
int iSelIndex = (int)m_aSelItems.GetAt(i);
if (iSelIndex >= iIndex)iSelIndex++;
VecTempSelIndex.push_back(iSelIndex);
}
m_aSelItems.Empty();
for (size_t i = 0; i < VecTempSelIndex.size(); i++)
m_aSelItems.Add((void*)VecTempSelIndex[i]);

return true;
}

Expand All @@ -177,6 +189,18 @@ namespace DuiLib {
}
}

std::vector<int> VecTempSelIndex;
for (auto i = 0; i < m_aSelItems.GetSize(); i++)
{
int iSelIndex = (int)m_aSelItems.GetAt(i);
if (iSelIndex == iIndex)continue;
if (iSelIndex > iIndex)iSelIndex--;
VecTempSelIndex.push_back(iSelIndex);
}
m_aSelItems.Empty();
for (size_t i = 0; i < VecTempSelIndex.size(); i++)
m_aSelItems.Add((void*)VecTempSelIndex[i]);

if (iIndex == m_iCurSel && m_iCurSel >= 0) {
int iSel = m_iCurSel;
m_iCurSel = -1;
Expand All @@ -194,6 +218,18 @@ namespace DuiLib {
if (pListItem) pListItem->SetIndex (i);
}

std::vector<int> VecTempSelIndex;
for (auto i = 0; i < m_aSelItems.GetSize(); i++)
{
int iSelIndex = (int)m_aSelItems.GetAt(i);
if (iSelIndex == iIndex)continue;
if (iSelIndex > iIndex)iSelIndex--;
VecTempSelIndex.push_back(iSelIndex);
}
m_aSelItems.Empty();
for (size_t i = 0; i < VecTempSelIndex.size(); i++)
m_aSelItems.Add((void*)VecTempSelIndex[i]);

if (iIndex == m_iCurSel && m_iCurSel >= 0) {
int iSel = m_iCurSel;
m_iCurSel = -1;
Expand Down
6 changes: 6 additions & 0 deletions DuiLib/Utils/WinImplBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ namespace DuiLib {
virtual CControlUI* CreateControl (faw::string_t pstrClass);
LRESULT Invoke (std::function<LRESULT ()> f) { return ::SendMessage (m_hWnd, WM_USER + 0x101, 1, (LPARAM) &f); }
void AsyncInvoke (std::function<LRESULT ()> f) { ::PostMessage (m_hWnd, WM_USER + 0x101, 0, (LPARAM) new decltype (f) (f)); }
template<typename Func, typename... Args>
void AsyncInvoke(Func func, Args... args) {
auto boundFunc = std::bind(func, args...);
auto* funcPtr = new std::function<decltype(func(args...))()>(boundFunc);
::PostMessage(m_hWnd, WM_USER + 0x101, 0, reinterpret_cast<LPARAM>(funcPtr));
}
virtual faw::string_t QueryControlText (faw::string_t lpstrId, faw::string_t lpstrType);

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

0 comments on commit bbee33e

Please sign in to comment.