Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
FrayxRulez committed Apr 29, 2023
2 parents 1e096ae + 7263944 commit 3c15a14
Show file tree
Hide file tree
Showing 199 changed files with 4,415 additions and 2,707 deletions.
4 changes: 3 additions & 1 deletion Documentation/TDLib-logs.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
When you want to report an issue with the Unigram app, you could be asked to send your logs. Notice: never send a log to an unknown person, send it only to the Unigram developer or the [@tdlib_bot](https://t.me/tdlib_bot).
When you want to report an issue with the Unigram app, you could be asked to send your logs.

⚠️ Never send logs to an unknown person, send them only to Telegram Support (Settings > Ask a Question) or the [@tdlib_bot](https://t.me/tdlib_bot).

### Opening the Diagnostic settings without signing in

Expand Down
264 changes: 139 additions & 125 deletions Telegram.Native/Composition/DirectRectangleClip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,129 +3,143 @@

namespace winrt::Telegram::Native::Composition::implementation
{
float DirectRectangleClip::Left() {
return m_left;
}

void DirectRectangleClip::Left(float value) {
m_left = value;
m_impl->SetLeft(value);
}

float DirectRectangleClip::Top() {
return m_top;
}

void DirectRectangleClip::Top(float value) {
m_top = value;
m_impl->SetTop(value);
}

float DirectRectangleClip::Right() {
return m_right;
}

void DirectRectangleClip::Right(float value) {
m_right = value;
m_impl->SetRight(value);
}

float DirectRectangleClip::Bottom() {
return m_bottom;
}

void DirectRectangleClip::Bottom(float value) {
m_bottom = value;
m_impl->SetBottom(value);
}



float DirectRectangleClip::TopLeft() {
return m_topLeft;
}

void DirectRectangleClip::TopLeft(float value) {
m_topLeft = value;
m_impl->SetTopLeftRadiusX(value);
m_impl->SetTopLeftRadiusY(value);
}

float DirectRectangleClip::TopRight() {
return m_topRight;
}

void DirectRectangleClip::TopRight(float value) {
m_topRight = value;
m_impl->SetTopRightRadiusX(value);
m_impl->SetTopRightRadiusY(value);
}

float DirectRectangleClip::BottomRight() {
return m_bottomRight;
}

void DirectRectangleClip::BottomRight(float value) {
m_bottomRight = value;
m_impl->SetBottomRightRadiusX(value);
m_impl->SetBottomRightRadiusY(value);
}

float DirectRectangleClip::BottomLeft() {
return m_bottomLeft;
}

void DirectRectangleClip::BottomLeft(float value) {
m_bottomLeft = value;
m_impl->SetBottomLeftRadiusX(value);
m_impl->SetBottomLeftRadiusY(value);
}

void DirectRectangleClip::Set(float uniform) {
TopLeft(uniform);
TopRight(uniform);
BottomRight(uniform);
BottomLeft(uniform);
}

void DirectRectangleClip::Set(float topLeft, float topRight, float bottomRight, float bottomLeft) {
TopLeft(topLeft);
TopRight(topRight);
BottomRight(bottomRight);
BottomLeft(bottomLeft);
}

void DirectRectangleClip::AnimateTop(Compositor compositor, float from, float to, double duration) {
m_top = to;

HRESULT hr;
auto device = CompositionDevice::Current();

winrt::com_ptr<IDCompositionAnimation> animation;
hr = device->CreateCubicBezierAnimation(compositor, from, to, duration, animation.put());

if (SUCCEEDED(hr)) {
m_impl->SetTop(animation.get());
}
else {
m_impl->SetTop(to);
}
}

void DirectRectangleClip::AnimateBottom(Compositor compositor, float from, float to, double duration) {
m_bottom = to;

HRESULT hr;
auto device = CompositionDevice::Current();

winrt::com_ptr<IDCompositionAnimation> animation;
hr = device->CreateCubicBezierAnimation(compositor, from, to, duration, animation.put());

if (SUCCEEDED(hr)) {
m_impl->SetBottom(animation.get());
}
else {
m_impl->SetBottom(to);
}
}
float DirectRectangleClip::Left() {
return m_left;
}

void DirectRectangleClip::Left(float value) {
m_left = value;
m_impl->SetLeft(value);
}

float DirectRectangleClip::Top() {
return m_top;
}

void DirectRectangleClip::Top(float value) {
m_top = value;
m_impl->SetTop(value);
}

float DirectRectangleClip::Right() {
return m_right;
}

void DirectRectangleClip::Right(float value) {
m_right = value;
m_impl->SetRight(value);
}

float DirectRectangleClip::Bottom() {
return m_bottom;
}

void DirectRectangleClip::Bottom(float value) {
m_bottom = value;
m_impl->SetBottom(value);
}



float DirectRectangleClip::TopLeft() {
return m_topLeft;
}

void DirectRectangleClip::TopLeft(float value) {
m_topLeft = value;
m_impl->SetTopLeftRadiusX(value);
m_impl->SetTopLeftRadiusY(value);
}

float DirectRectangleClip::TopRight() {
return m_topRight;
}

void DirectRectangleClip::TopRight(float value) {
m_topRight = value;
m_impl->SetTopRightRadiusX(value);
m_impl->SetTopRightRadiusY(value);
}

float DirectRectangleClip::BottomRight() {
return m_bottomRight;
}

void DirectRectangleClip::BottomRight(float value) {
m_bottomRight = value;
m_impl->SetBottomRightRadiusX(value);
m_impl->SetBottomRightRadiusY(value);
}

float DirectRectangleClip::BottomLeft() {
return m_bottomLeft;
}

void DirectRectangleClip::BottomLeft(float value) {
m_bottomLeft = value;
m_impl->SetBottomLeftRadiusX(value);
m_impl->SetBottomLeftRadiusY(value);
}

void DirectRectangleClip::Set(float uniform) {
TopLeft(uniform);
TopRight(uniform);
BottomRight(uniform);
BottomLeft(uniform);
}

void DirectRectangleClip::Set(float topLeft, float topRight, float bottomRight, float bottomLeft) {
TopLeft(topLeft);
TopRight(topRight);
BottomRight(bottomRight);
BottomLeft(bottomLeft);
}

void DirectRectangleClip::SetInset(float uniform) {
Left(uniform);
Top(uniform);
Right(uniform);
Bottom(uniform);
}

void DirectRectangleClip::SetInset(float left, float top, float right, float bottom) {
Left(left);
Top(top);
Right(right);
Bottom(bottom);
}

void DirectRectangleClip::AnimateTop(Compositor compositor, float from, float to, double duration) {
m_top = to;

HRESULT hr;
auto device = CompositionDevice::Current();

winrt::com_ptr<IDCompositionAnimation> animation;
hr = device->CreateCubicBezierAnimation(compositor, from, to, duration, animation.put());

if (SUCCEEDED(hr)) {
m_impl->SetTop(animation.get());
}
else {
m_impl->SetTop(to);
}
}

void DirectRectangleClip::AnimateBottom(Compositor compositor, float from, float to, double duration) {
m_bottom = to;

HRESULT hr;
auto device = CompositionDevice::Current();

winrt::com_ptr<IDCompositionAnimation> animation;
hr = device->CreateCubicBezierAnimation(compositor, from, to, duration, animation.put());

if (SUCCEEDED(hr)) {
m_impl->SetBottom(animation.get());
}
else {
m_impl->SetBottom(to);
}
}
}
3 changes: 3 additions & 0 deletions Telegram.Native/Composition/DirectRectangleClip.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ namespace winrt::Telegram::Native::Composition::implementation
void Set(float uniform);
void Set(float topLeft, float topRight, float bottomRight, float bottomLeft);

void SetInset(float uniform);
void SetInset(float left, float top, float right, float bottom);

void AnimateTop(Compositor compositor, float from, float to, double duration);
void AnimateBottom(Compositor compositor, float from, float to, double duration);

Expand Down
3 changes: 3 additions & 0 deletions Telegram.Native/Composition/DirectRectangleClip.idl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ namespace Telegram.Native.Composition
void Set(Single uniform);
void Set(Single topLeft, Single topRight, Single bottomRight, Single bottomLeft);

void SetInset(Single uniform);
void SetInset(Single left, Single top, Single right, Single bottom);

void AnimateTop(Windows.UI.Composition.Compositor compositor, Single from, Single to, Double duration);
void AnimateBottom(Windows.UI.Composition.Compositor compositor, Single from, Single to, Double duration);
}
Expand Down
36 changes: 36 additions & 0 deletions Telegram.Native/NativeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
#include <winrt/Windows.Data.Xml.Dom.h>
#include <winrt/Windows.UI.Notifications.h>

typedef
BOOL
(APIENTRY* pGetKeyboardLayoutNameW)(
_Out_ LPWSTR pwszKLID
);

using namespace winrt::Windows::Data::Xml::Dom;
using namespace winrt::Windows::UI::Notifications;

Expand Down Expand Up @@ -209,6 +215,36 @@ namespace winrt::Telegram::Native::implementation
return buff;
}

hstring NativeUtils::GetKeyboardCulture()
{
// TODO: I'm not sure about how much expensive this call it.
// At the moment it isn't used extremely often, but we should
// consider caching it (problem is how to invalidate the cache)
static const LibraryInstance user32(L"User32.dll");
static const auto getKeyboardLayoutName = user32.GetMethod<pGetKeyboardLayoutNameW>("GetKeyboardLayoutNameW");

WCHAR name[KL_NAMELENGTH];
if (getKeyboardLayoutName(name))
{
// The layout name looks something like this: 00000410
// Where the first 4 bytes are most likely flags
// And the second half is the actually the LCID as a HEX string
unsigned int lcid = std::stoul(name + 4, nullptr, 16);

WCHAR locale[LOCALE_NAME_MAX_LENGTH];
int length = LCIDToLocaleName(lcid, locale, LOCALE_NAME_MAX_LENGTH, 0);

if (length > 0)
{
// The string is null terminated
return hstring(locale, length - 1);
}
}

// TODO: probably better this than an empty string.
return L"en-US";
}

bool NativeUtils::IsFileReadable(hstring path)
{
DWORD desired_access = GENERIC_READ;
Expand Down
1 change: 1 addition & 0 deletions Telegram.Native/NativeUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace winrt::Telegram::Native::implementation
//static int32_t GetDirectionality(char16 value);

static hstring GetCurrentCulture();
static hstring GetKeyboardCulture();

static bool IsFileReadable(hstring path);

Expand Down
2 changes: 2 additions & 0 deletions Telegram.Native/NativeUtils.idl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ namespace Telegram.Native

static String GetCurrentCulture();

static String GetKeyboardCulture();

static Boolean IsFileReadable(String path);

static Boolean IsMediaSupported();
Expand Down
Loading

0 comments on commit 3c15a14

Please sign in to comment.