2021-07-21 21:34:41 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
2021-07-25 22:20:42 +00:00
|
|
|
#include "layout/layout_position.h"
|
2021-07-21 21:34:41 +00:00
|
|
|
|
|
|
|
namespace Layout {
|
2021-07-22 23:11:27 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
constexpr auto kMatrixRowShift = 40000;
|
|
|
|
|
|
|
|
} // namespace
|
2021-07-21 21:34:41 +00:00
|
|
|
|
|
|
|
Layout::Position IndexToPosition(int index) {
|
|
|
|
return {
|
2021-07-22 23:11:27 +00:00
|
|
|
(index >= 0) ? (index / kMatrixRowShift) : -1,
|
|
|
|
(index >= 0) ? (index % kMatrixRowShift) : -1 };
|
2021-07-21 21:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int PositionToIndex(int row, int column) {
|
2021-07-22 23:11:27 +00:00
|
|
|
return row * kMatrixRowShift + column;
|
2021-07-21 21:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int PositionToIndex(const Layout::Position &position) {
|
|
|
|
return PositionToIndex(position.row, position.column);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Layout
|