Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Reputeless committed Sep 23, 2023
1 parent e28779e commit 9d0d5ad
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,11 @@ namespace s3d

if (size != 0)
{
UINT i, j;
UINT page_start = 0;
//ClearPrint();
//Print << U"dwSelection: " << cand_list->dwSelection;
//Print << U"dwCount: " << cand_list->dwCount;
//Print << U"dwPageStart: " << cand_list->dwPageStart;
//Print << U"dwPageSize: " << cand_list->dwPageSize;

{
videodata->candidateState.candidates.clear();
Expand All @@ -541,40 +544,37 @@ namespace s3d
videodata->candidateState.pageSize = cand_list->dwPageSize;
}

if ((LANG() == LANG_CHS) && IME_GetId(videodata, 0))
{
const UINT maxcandchar = 18;
size_t cchars = 0;

for (i = 0; i < (UINT)videodata->candidateState.count; ++i)
{
size_t len = std::wcslen((LPWSTR)((DWORD_PTR)cand_list + cand_list->dwOffset[i])) + 1;

if (maxcandchar < (len + cchars))
{
if (cand_list->dwSelection < i)
{
break;
}

page_start = i;
cchars = len;
}
else
{
cchars += len;
}
}

videodata->ime_candpgsize = (i - page_start);
}
else
{
videodata->ime_candpgsize = std::min(cand_list->dwPageSize == 0 ? MaxCandidatesCount : cand_list->dwPageSize, MaxCandidatesCount);
page_start = (cand_list->dwSelection / videodata->ime_candpgsize) * videodata->ime_candpgsize;
}
//if ((LANG() == LANG_CHS) && IME_GetId(videodata, 0))
//{
// const UINT maxcandchar = 18;
// size_t cchars = 0;

// for (i = 0; i < (UINT)videodata->candidateState.count; ++i)
// {
// size_t len = std::wcslen((LPWSTR)((DWORD_PTR)cand_list + cand_list->dwOffset[i])) + 1;
//
// if (maxcandchar < (len + cchars))
// {
// if (cand_list->dwSelection < i)
// {
// break;
// }

// page_start = i;
// cchars = len;
// }
// else
// {
// cchars += len;
// }
// }

// videodata->ime_candpgsize = (i - page_start);
//}

UINT k = 0;

for (i = page_start, j = 0; ((DWORD)i < cand_list->dwCount) && (j < videodata->ime_candpgsize); ++i, ++j)
for (UINT i = cand_list->dwPageStart; ((DWORD)i < cand_list->dwCount) && (k < cand_list->dwPageSize); ++i, ++k)
{
const LPCWSTR candidate = (LPCWSTR)((DWORD_PTR)cand_list + cand_list->dwOffset[i]);

Expand Down
31 changes: 26 additions & 5 deletions Siv3D/src/Siv3D/SimpleGUI/SivSimpleGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ namespace s3d
constexpr ColorF CandidateWindowFrameColor{ 0.75 };
constexpr ColorF CandidateSelectedBackgroundColor{ 0.55, 0.85, 1.0 };
constexpr ColorF CandidateTextColor{ 0.11 };
constexpr ColorF CandidateMinimapColor{ 0.67 };
constexpr double CandidateMargin = 4.0;
constexpr double CandidatePadding = 10.0;
constexpr double CandidatePadding = 12.0;
constexpr double CandidateMinimapWidth = 20.0;

[[nodiscard]]
inline constexpr ColorF GetTextColor(bool enabled) noexcept
Expand Down Expand Up @@ -2071,7 +2073,7 @@ namespace s3d
}

return boxWidth;
}() + (CandidatePadding * 2);
}() + (CandidatePadding * 2 + CandidateMinimapWidth);

const double candidateItemHeight = (font.height() + CandidateMargin);

Expand Down Expand Up @@ -2107,7 +2109,7 @@ namespace s3d
}

return boxWidth;
}() + (CandidatePadding * 2);
}() + (CandidatePadding * 2 + CandidateMinimapWidth);

const double candidateItemHeight = (font.height() + CandidateMargin);

Expand All @@ -2127,20 +2129,39 @@ namespace s3d

if (selected)
{
RectF{ itemPos, boxWidth, candidateItemHeight }
RectF{ itemPos, (boxWidth - CandidateMinimapWidth), candidateItemHeight }
.stretched(-1, 0)
.draw(CandidateSelectedBackgroundColor);
}

if (candidate)
{
font(candidate).draw(itemPos.movedBy(CandidatePadding, (CandidateMargin * 0.5)), CandidateTextColor);
font(candidate).draw(itemPos.movedBy(CandidatePadding, (CandidateMargin * 0.5 - 1.0)), CandidateTextColor);
}

++currentIndex;
}
}

// minimap
{
if (cadidateState.pageStartIndex != 0)
{
const Vec2 scrollPos{ (pos.x + boxWidth - CandidateMinimapWidth * 0.5 - 1), (pos.y + 0 * candidateItemHeight + 11) };
scrollPos.asCircle(3.5).draw(CandidateMinimapColor);
scrollPos.movedBy(0, 8).asCircle(2.8).draw(CandidateMinimapColor);
scrollPos.movedBy(0, 15).asCircle(2.25).draw(CandidateMinimapColor);
}

if ((cadidateState.pageStartIndex + cadidateState.pageSize) != cadidateState.count)
{
const Vec2 scrollPos{ (pos.x + boxWidth - CandidateMinimapWidth * 0.5 - 1), (pos.y + cadidateState.pageSize * candidateItemHeight - 9) };
scrollPos.asCircle(3.5).draw(CandidateMinimapColor);
scrollPos.movedBy(0, -8).asCircle(2.8).draw(CandidateMinimapColor);
scrollPos.movedBy(0, -15).asCircle(2.25).draw(CandidateMinimapColor);
}
}

# endif
}

Expand Down

0 comments on commit 9d0d5ad

Please sign in to comment.