From 488d43339cdd3c2cf399eaca026d085f9339582e Mon Sep 17 00:00:00 2001
From: dsizzle <dcieslak@yahoo.com>
Date: Wed, 26 Nov 2014 19:41:48 +0000
Subject: [PATCH] 3651: Added IsBlockVisible function to prevent scrolling of
view when a block is selected in the block list, but it's already visible.
---
src/apps/charactermap/CharacterView.cpp | 17 +++++++++++++++--
src/apps/charactermap/CharacterView.h | 1 +
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/apps/charactermap/CharacterView.cpp b/src/apps/charactermap/CharacterView.cpp
index aa13eae..3f311e3 100644
a
|
b
|
CharacterView::IsShowingBlock(int32 blockIndex) const
|
109 | 109 | void |
110 | 110 | CharacterView::ScrollToBlock(int32 blockIndex) |
111 | 111 | { |
112 | | // don't scroll if the selected character is already in view. |
| 112 | // don't scroll if the selected block is already in view. |
113 | 113 | // this prevents distracting jumps when crossing a block |
114 | 114 | // boundary in the character view. |
115 | | if (IsCharacterVisible(fCurrentCharacter)) |
| 115 | if (IsBlockVisible(blockIndex)) |
116 | 116 | return; |
117 | 117 | |
118 | 118 | if (blockIndex < 0) |
… |
… |
CharacterView::IsCharacterVisible(uint32 c) const
|
142 | 142 | } |
143 | 143 | |
144 | 144 | |
| 145 | bool |
| 146 | CharacterView::IsBlockVisible(int32 block) const |
| 147 | { |
| 148 | int32 topBlock = _BlockAt(BPoint(Bounds().left, Bounds().top)); |
| 149 | int32 bottomBlock = _BlockAt(BPoint(Bounds().right, Bounds().bottom)); |
| 150 | |
| 151 | if (block >= topBlock && block <= bottomBlock) |
| 152 | return true; |
| 153 | |
| 154 | return false; |
| 155 | } |
| 156 | |
| 157 | |
145 | 158 | /*static*/ void |
146 | 159 | CharacterView::UnicodeToUTF8(uint32 c, char* text, size_t textSize) |
147 | 160 | { |
diff --git a/src/apps/charactermap/CharacterView.h b/src/apps/charactermap/CharacterView.h
index 8c08d50..fc5e618 100644
a
|
b
|
public:
|
33 | 33 | void ScrollToBlock(int32 blockIndex); |
34 | 34 | void ScrollToCharacter(uint32 c); |
35 | 35 | bool IsCharacterVisible(uint32 c) const; |
| 36 | bool IsBlockVisible(int32 block) const; |
36 | 37 | |
37 | 38 | static void UnicodeToUTF8(uint32 c, char* text, |
38 | 39 | size_t textSize); |