Codebase list mozc / a6a82ab
Improve the vertical writing on Mac Next step: Remove GetWindowRectForMainWindowFromPreeditRect which is no longer used anywhere. BUG= TEST= REF_BUG= REF_CL=120674585 REF_TIME=2016-04-25T13:25:07+09:00 REF_TIME_RAW=1461558307 +0900 Hiroyuki Komatsu 8 years ago
2 changed file(s) with 22 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
00 MAJOR=2
11 MINOR=18
2 BUILD=2560
2 BUILD=2561
33 REVISION=102
44 # CAUTION: NACL_DICTIONARY_VERSION is going to be migrated to ENGINE_VERSION.
55 # NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
4646 namespace mac{
4747
4848 namespace {
49 const int kHideWindowDelay = 500; // msec
50 const int kMarginAbovePreedit = 10; // pixel
49 const int kHideWindowDelay = 500; // msec
50 const int kWindowMargin = 10; // pixel
5151
5252 // In Cocoa's coordinate system the origin point is left-bottom and the Y-axis
5353 // points up. But in Mozc's coordinate system the Y-axis points down. So we use
220220 mozc::Point(command_.preedit_rectangle().left(),
221221 command_.preedit_rectangle().top() - GetBaseScreenHeight()),
222222 preedit_size);
223 // Currently preedit_rect doesn't care about the text height -- it
224 // just means the line under the preedit. So here we fix the height.
225 // TODO(mukai): replace this hack by calculating actual text height.
226 preedit_rect.origin.y -= kMarginAbovePreedit;
227 preedit_rect.size.height += kMarginAbovePreedit;
223
224 // This is a hacky way to check vertical writing.
225 // TODO(komatsu): We should use the return value of attributesForCharacterIndex
226 // in GoogleJapaneseInputController.mm as a proper way.
227 const bool is_vertical = (preedit_size.height < preedit_size.width);
228
229 // Expand the rect size to make a margin to the candidate window.
230 if (is_vertical) {
231 // Adjust the margin to the candidate window in the right side.
232 preedit_rect.DeflateRect(0, 0, -kWindowMargin, 0); // (dx, dy, dw, dh)
233 } else {
234 // Adjust the margin to the candidate window in the upper side.
235 preedit_rect.DeflateRect(0, -kWindowMargin, 0, 0); // (dx, dy, dw, dh)
236 }
228237
229238 // Find out the nearest display.
230239 const mozc::Rect display_rect = GetNearestDisplayRect(preedit_rect);
237246 const mozc::Point candidate_zero_point(
238247 candidate_layout->GetColumnRect(COLUMN_CANDIDATE).Left(), 0);
239248
249 const mozc::Point target_point(preedit_rect.Left(), preedit_rect.Bottom());
240250 const mozc::Rect candidate_rect =
241 WindowUtil::GetWindowRectForMainWindowFromPreeditRect(
242 preedit_rect, candidate_window_->GetWindowSize(),
243 candidate_zero_point, display_rect);
251 WindowUtil::GetWindowRectForMainWindowFromTargetPointAndPreedit(
252 target_point, preedit_rect,
253 candidate_window_->GetWindowSize(), candidate_zero_point,
254 display_rect, is_vertical);
244255 candidate_window_->MoveWindow(OriginPointInCocoaCoord(candidate_rect));
245256
246257 // Align infolist window