CharacterMap: select Unicode block for current character
* Scrolling the list of characters now selects the currently visible block in the blocks list. Signed-off-by: Adrien Destugues <pulkomandy@gmail.com> Fixes #3651, part 1
This commit is contained in:
parent
67d659f26e
commit
74d9b875c2
@ -108,6 +108,12 @@ CharacterView::IsShowingBlock(int32 blockIndex) const
|
||||
void
|
||||
CharacterView::ScrollToBlock(int32 blockIndex)
|
||||
{
|
||||
// don't scroll if the selected character is already in view.
|
||||
// this prevents distracting jumps when crossing a block
|
||||
// boundary in the character view.
|
||||
if (IsCharacterVisible(fCurrentCharacter))
|
||||
return;
|
||||
|
||||
if (blockIndex < 0)
|
||||
blockIndex = 0;
|
||||
else if (blockIndex >= (int32)kNumUnicodeBlocks)
|
||||
|
@ -319,6 +319,8 @@ CharacterWindow::MessageReceived(BMessage* message)
|
||||
|
||||
fGlyphView->SetText(glyph);
|
||||
fCodeView->SetText(text);
|
||||
|
||||
fUnicodeBlockView->SelectBlockForCharacter(character);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -118,3 +118,22 @@ UnicodeBlockView::_CreateBlocks()
|
||||
_UpdateBlocks();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
UnicodeBlockView::SelectBlockForCharacter(uint32 character)
|
||||
{
|
||||
// find block containing the character
|
||||
|
||||
// TODO: could use binary search here
|
||||
for (uint32 i = 0; i < kNumUnicodeBlocks; i++) {
|
||||
if (kUnicodeBlocks[i].end < character)
|
||||
continue;
|
||||
if (kUnicodeBlocks[i].start > character) {
|
||||
// Character is not mapped
|
||||
break;
|
||||
}
|
||||
|
||||
Select(i);
|
||||
ScrollToSelection();
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ public:
|
||||
{ return fShowContainedBlocksOnly; }
|
||||
|
||||
bool IsShowingBlock(int32 blockIndex) const;
|
||||
void SelectBlockForCharacter(uint32 character);
|
||||
|
||||
private:
|
||||
void _UpdateBlocks();
|
||||
|
Loading…
Reference in New Issue
Block a user