tdesktop/Telegram/SourceFiles/layout/layout_position.cpp

32 lines
748 B
C++
Raw Normal View History

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 {
namespace {
constexpr auto kMatrixRowShift = 40000;
} // namespace
2021-07-21 21:34:41 +00:00
Layout::Position IndexToPosition(int index) {
return {
(index >= 0) ? (index / kMatrixRowShift) : -1,
(index >= 0) ? (index % kMatrixRowShift) : -1 };
2021-07-21 21:34:41 +00:00
}
int PositionToIndex(int row, int column) {
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