Fix working with layers.

Regression was introduced in df64c97.

New base::flags work correctly only if all mutually exclusive flag
values use mutually exclusive bits (a & b == 0 for exclusive (a, b)).

Closes #3856.
This commit is contained in:
John Preston 2017-09-03 21:36:06 +03:00
parent 8f82880b93
commit 2e374e68c5
13 changed files with 95 additions and 95 deletions

View File

@ -570,12 +570,12 @@ enum ForwardWhatMessages {
};
enum ShowLayerOption {
CloseOtherLayers = 0x00,
KeepOtherLayers = 0x01,
ShowAfterOtherLayers = 0x03,
CloseOtherLayers = (1 << 0),
KeepOtherLayers = (1 << 1),
ShowAfterOtherLayers = (1 << 2),
AnimatedShowLayer = 0x00,
ForceFastShowLayer = 0x04,
AnimatedShowLayer = (1 << 3),
ForceFastShowLayer = (1 << 4),
};
using ShowLayerOptions = base::flags<ShowLayerOption>;
inline constexpr auto is_flag_type(ShowLayerOption) { return true; };

View File

@ -175,11 +175,11 @@ private:
void itemRemoved(HistoryItem *item);
enum class UpdateRowSection {
Default = 0x01,
Filtered = 0x02,
PeerSearch = 0x04,
MessageSearch = 0x08,
All = 0x0F,
Default = (1 << 0),
Filtered = (1 << 1),
PeerSearch = (1 << 2),
MessageSearch = (1 << 3),
All = Default | Filtered | PeerSearch | MessageSearch,
};
using UpdateRowSections = base::flags<UpdateRowSection>;
friend inline constexpr auto is_flag_type(UpdateRowSection) { return true; };

View File

@ -172,8 +172,8 @@ struct HistoryMessageReply : public RuntimeComponent<HistoryMessageReply> {
void itemRemoved(HistoryMessage *holder, HistoryItem *removed);
enum class PaintFlag {
InBubble = 0x01,
Selected = 0x02,
InBubble = (1 << 0),
Selected = (1 << 1),
};
using PaintFlags = base::flags<PaintFlag>;
friend inline constexpr auto is_flag_type(PaintFlag) { return true; };

View File

@ -691,8 +691,8 @@ private:
void countHistoryShowFrom();
enum class TextUpdateEvent {
SaveDraft = 0x01,
SendTyping = 0x02,
SaveDraft = (1 << 0),
SendTyping = (1 << 1),
};
using TextUpdateEvents = base::flags<TextUpdateEvent>;
friend inline constexpr auto is_flag_type(TextUpdateEvent) { return true; };

View File

@ -82,8 +82,8 @@ private:
QSize countFrameSize() const;
enum class StateFlag {
Over = 0x01,
DeleteOver = 0x02,
Over = (1 << 0),
DeleteOver = (1 << 1),
};
using StateFlags = base::flags<StateFlag>;
friend inline constexpr auto is_flag_type(StateFlag) { return true; };

View File

@ -35,45 +35,45 @@ struct PeerUpdate {
PeerData *peer;
enum class Flag : uint32 {
None = 0x00000000U,
None = 0,
// Common flags
NameChanged = 0x00000001U,
UsernameChanged = 0x00000002U,
PhotoChanged = 0x00000004U,
AboutChanged = 0x00000008U,
NotificationsEnabled = 0x00000010U,
SharedMediaChanged = 0x00000020U,
MigrationChanged = 0x00000040U,
PinnedChanged = 0x00000080U,
RestrictionReasonChanged = 0x00000100U,
NameChanged = (1 << 0),
UsernameChanged = (1 << 1),
PhotoChanged = (1 << 2),
AboutChanged = (1 << 3),
NotificationsEnabled = (1 << 4),
SharedMediaChanged = (1 << 5),
MigrationChanged = (1 << 6),
PinnedChanged = (1 << 7),
RestrictionReasonChanged = (1 << 8),
// For chats and channels
InviteLinkChanged = 0x00000200U,
MembersChanged = 0x00000400U,
AdminsChanged = 0x00000800U,
BannedUsersChanged = 0x00001000U,
UnreadMentionsChanged = 0x00002000U,
InviteLinkChanged = (1 << 9),
MembersChanged = (1 << 10),
AdminsChanged = (1 << 11),
BannedUsersChanged = (1 << 12),
UnreadMentionsChanged = (1 << 13),
// For users
UserCanShareContact = 0x00010000U,
UserIsContact = 0x00020000U,
UserPhoneChanged = 0x00040000U,
UserIsBlocked = 0x00080000U,
BotCommandsChanged = 0x00100000U,
UserOnlineChanged = 0x00200000U,
BotCanAddToGroups = 0x00400000U,
UserCommonChatsChanged = 0x00800000U,
UserHasCalls = 0x01000000U,
UserCanShareContact = (1 << 16),
UserIsContact = (1 << 17),
UserPhoneChanged = (1 << 18),
UserIsBlocked = (1 << 19),
BotCommandsChanged = (1 << 20),
UserOnlineChanged = (1 << 21),
BotCanAddToGroups = (1 << 22),
UserCommonChatsChanged = (1 << 23),
UserHasCalls = (1 << 24),
// For chats
ChatCanEdit = 0x00010000U,
ChatCanEdit = (1 << 16),
// For channels
ChannelAmIn = 0x00010000U,
ChannelRightsChanged = 0x00020000U,
ChannelStickersChanged = 0x00040000U,
ChannelPinnedChanged = 0x00080000U,
ChannelAmIn = (1 << 16),
ChannelRightsChanged = (1 << 17),
ChannelStickersChanged = (1 << 18),
ChannelPinnedChanged = (1 << 19),
};
using Flags = base::flags<Flag>;
friend inline constexpr auto is_flag_type(Flag) { return true; }

View File

@ -55,11 +55,11 @@ public:
// Custom shadows.
enum class ShadowsChange {
Moved = 0x01,
Resized = 0x02,
Shown = 0x04,
Hidden = 0x08,
Activate = 0x10,
Moved = (1 << 0),
Resized = (1 << 1),
Shown = (1 << 2),
Hidden = (1 << 3),
Activate = (1 << 4),
};
using ShadowsChanges = base::flags<ShadowsChange>;
friend inline constexpr auto is_flag_type(ShadowsChange) { return true; };

View File

@ -76,8 +76,8 @@ bool _userWorking() {
}
enum class FileOption {
User = 0x01,
Safe = 0x02,
User = (1 << 0),
Safe = (1 << 1),
};
using FileOptions = base::flags<FileOption>;
inline constexpr auto is_flag_type(FileOption) { return true; };

View File

@ -76,10 +76,10 @@ signals:
protected:
enum class StateFlag {
None = 0x00,
Over = 0x01,
Down = 0x02,
Disabled = 0x04,
None = 0,
Over = (1 << 0),
Down = (1 << 1),
Disabled = (1 << 2),
};
using State = base::flags<StateFlag>;

View File

@ -188,18 +188,18 @@ QImage prepareColored(style::color add, QImage image);
QImage prepareOpaque(QImage image);
enum class Option {
None = 0x000,
Smooth = 0x001,
Blurred = 0x002,
Circled = 0x004,
RoundedLarge = 0x008,
RoundedSmall = 0x010,
RoundedTopLeft = 0x020,
RoundedTopRight = 0x040,
RoundedBottomLeft = 0x080,
RoundedBottomRight = 0x100,
Colored = 0x200,
TransparentBackground = 0x400,
None = 0,
Smooth = (1 << 0),
Blurred = (1 << 1),
Circled = (1 << 2),
RoundedLarge = (1 << 3),
RoundedSmall = (1 << 4),
RoundedTopLeft = (1 << 5),
RoundedTopRight = (1 << 6),
RoundedBottomLeft = (1 << 7),
RoundedBottomRight = (1 << 8),
Colored = (1 << 9),
TransparentBackground = (1 << 10),
};
using Options = base::flags<Option>;
inline constexpr auto is_flag_type(Option) { return true; };

View File

@ -129,9 +129,9 @@ public:
struct StateRequest {
enum class Flag {
BreakEverywhere = 0x01,
LookupSymbol = 0x02,
LookupLink = 0x04,
BreakEverywhere = (1 << 0),
LookupSymbol = (1 << 1),
LookupLink = (1 << 2),
};
using Flags = base::flags<Flag>;
friend inline constexpr auto is_flag_type(Flag) { return true; };

View File

@ -30,34 +30,34 @@ QString GetOverride(const QString &familyName);
} // namespace
enum class RectPart {
None = 0,
None = 0,
TopLeft = (1 << 0),
Top = (1 << 1),
TopRight = (1 << 2),
Left = (1 << 3),
Center = (1 << 4),
Right = (1 << 5),
BottomLeft = (1 << 6),
Bottom = (1 << 7),
TopLeft = (1 << 0),
Top = (1 << 1),
TopRight = (1 << 2),
Left = (1 << 3),
Center = (1 << 4),
Right = (1 << 5),
BottomLeft = (1 << 6),
Bottom = (1 << 7),
BottomRight = (1 << 8),
FullTop = TopLeft | Top | TopRight,
FullTop = TopLeft | Top | TopRight,
NoTopBottom = Left | Center | Right,
FullBottom = BottomLeft | Bottom | BottomRight,
NoTop = NoTopBottom | FullBottom,
NoBottom = FullTop | NoTopBottom,
FullBottom = BottomLeft | Bottom | BottomRight,
NoTop = NoTopBottom | FullBottom,
NoBottom = FullTop | NoTopBottom,
FullLeft = TopLeft | Left | BottomLeft,
FullLeft = TopLeft | Left | BottomLeft,
NoLeftRight = Top | Center | Bottom,
FullRight = TopRight | Right | BottomRight,
NoLeft = NoLeftRight | FullRight,
NoRight = FullLeft | NoLeftRight,
FullRight = TopRight | Right | BottomRight,
NoLeft = NoLeftRight | FullRight,
NoRight = FullLeft | NoLeftRight,
CornersMask = TopLeft | TopRight | BottomLeft | BottomRight,
SidesMask = Top | Bottom | Left | Right,
SidesMask = Top | Bottom | Left | Right,
Full = FullTop | NoTop,
Full = FullTop | NoTop,
};
using RectParts = base::flags<RectPart>;
inline constexpr auto is_flag_type(RectPart) { return true; };

View File

@ -25,12 +25,12 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
namespace Window {
enum class GifPauseReason {
Any = 0,
Any = 0,
InlineResults = (1 << 0),
SavedGifs = (1 << 1),
Layer = (1 << 2),
RoundPlaying = (1 << 3),
MediaPreview = (1 << 4),
SavedGifs = (1 << 1),
Layer = (1 << 2),
RoundPlaying = (1 << 3),
MediaPreview = (1 << 4),
};
using GifPauseReasons = base::flags<GifPauseReason>;
inline constexpr bool is_flag_type(GifPauseReason) { return true; };