mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added layout utils file.
This commit is contained in:
parent
c4d8d52aed
commit
85ce179f58
3 changed files with 49 additions and 0 deletions
|
@ -704,6 +704,8 @@ PRIVATE
|
||||||
lang/lang_numbers_animation.h
|
lang/lang_numbers_animation.h
|
||||||
lang/lang_translator.cpp
|
lang/lang_translator.cpp
|
||||||
lang/lang_translator.h
|
lang/lang_translator.h
|
||||||
|
layout/layout_utils.cpp
|
||||||
|
layout/layout_utils.h
|
||||||
main/main_account.cpp
|
main/main_account.cpp
|
||||||
main/main_account.h
|
main/main_account.h
|
||||||
main/main_app_config.cpp
|
main/main_app_config.cpp
|
||||||
|
|
26
Telegram/SourceFiles/layout/layout_utils.cpp
Normal file
26
Telegram/SourceFiles/layout/layout_utils.cpp
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
#include "layout/layout_utils.h"
|
||||||
|
|
||||||
|
namespace Layout {
|
||||||
|
|
||||||
|
Layout::Position IndexToPosition(int index) {
|
||||||
|
return {
|
||||||
|
(index >= 0) ? (index / MatrixRowShift) : -1,
|
||||||
|
(index >= 0) ? (index % MatrixRowShift) : -1 };
|
||||||
|
}
|
||||||
|
|
||||||
|
int PositionToIndex(int row, int column) {
|
||||||
|
return row * MatrixRowShift + column;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PositionToIndex(const Layout::Position &position) {
|
||||||
|
return PositionToIndex(position.row, position.column);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Layout
|
21
Telegram/SourceFiles/layout/layout_utils.h
Normal file
21
Telegram/SourceFiles/layout/layout_utils.h
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Layout {
|
||||||
|
|
||||||
|
struct Position {
|
||||||
|
int row = -1;
|
||||||
|
int column = -1;
|
||||||
|
};
|
||||||
|
|
||||||
|
[[nodiscard]] Position IndexToPosition(int index);
|
||||||
|
[[nodiscard]] int PositionToIndex(int row, int column);
|
||||||
|
[[nodiscard]] int PositionToIndex(const Position &position);
|
||||||
|
|
||||||
|
} // namespace Layout
|
Loading…
Add table
Reference in a new issue