refactor: convert C++ enums to C++11 enum classes (#18087)
This commit is contained in:
parent
a59dc56fa6
commit
c25c31e018
36 changed files with 199 additions and 204 deletions
|
@ -157,7 +157,7 @@ bool ScopedDisableResize::disable_resize_ = false;
|
|||
|
||||
- (void)performClose:(id)sender {
|
||||
if (shell_->title_bar_style() ==
|
||||
atom::NativeWindowMac::CUSTOM_BUTTONS_ON_HOVER) {
|
||||
atom::NativeWindowMac::TitleBarStyle::CUSTOM_BUTTONS_ON_HOVER) {
|
||||
[[self delegate] windowShouldClose:self];
|
||||
} else if (shell_->IsSimpleFullScreen()) {
|
||||
if ([[self delegate] respondsToSelector:@selector(windowShouldClose:)]) {
|
||||
|
@ -182,7 +182,7 @@ bool ScopedDisableResize::disable_resize_ = false;
|
|||
|
||||
- (void)performMiniaturize:(id)sender {
|
||||
if (shell_->title_bar_style() ==
|
||||
atom::NativeWindowMac::CUSTOM_BUTTONS_ON_HOVER)
|
||||
atom::NativeWindowMac::TitleBarStyle::CUSTOM_BUTTONS_ON_HOVER)
|
||||
[self miniaturize:self];
|
||||
else
|
||||
[super performMiniaturize:sender];
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include "ui/views/widget/native_widget_mac.h"
|
||||
#include "ui/views_bridge_mac/bridged_native_widget_impl.h"
|
||||
|
||||
using TitleBarStyle = atom::NativeWindowMac::TitleBarStyle;
|
||||
|
||||
@implementation AtomNSWindowDelegate
|
||||
|
||||
- (id)initWithShell:(atom::NativeWindowMac*)shell {
|
||||
|
@ -181,7 +183,7 @@
|
|||
shell_->SetResizable(true);
|
||||
// Hide the native toolbar before entering fullscreen, so there is no visual
|
||||
// artifacts.
|
||||
if (shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
|
||||
if (shell_->title_bar_style() == TitleBarStyle::HIDDEN_INSET) {
|
||||
NSWindow* window = shell_->GetNativeWindow().GetNativeNSWindow();
|
||||
[window setToolbar:nil];
|
||||
}
|
||||
|
@ -198,14 +200,14 @@
|
|||
// FIXME(zcbenz): Showing titlebar for hiddenInset window is weird under
|
||||
// fullscreen mode.
|
||||
// Show title if fullscreen_window_title flag is set
|
||||
(shell_->title_bar_style() != atom::NativeWindowMac::HIDDEN_INSET ||
|
||||
(shell_->title_bar_style() != TitleBarStyle::HIDDEN_INSET ||
|
||||
shell_->fullscreen_window_title())) {
|
||||
[window setTitleVisibility:NSWindowTitleVisible];
|
||||
}
|
||||
|
||||
// Restore the native toolbar immediately after entering fullscreen, if we
|
||||
// do this before leaving fullscreen, traffic light buttons will be jumping.
|
||||
if (shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
|
||||
if (shell_->title_bar_style() == TitleBarStyle::HIDDEN_INSET) {
|
||||
base::scoped_nsobject<NSToolbar> toolbar(
|
||||
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
|
||||
[toolbar setShowsBaselineSeparator:NO];
|
||||
|
@ -222,13 +224,13 @@
|
|||
// Restore the titlebar visibility.
|
||||
NSWindow* window = shell_->GetNativeWindow().GetNativeNSWindow();
|
||||
if ((shell_->transparent() || !shell_->has_frame()) &&
|
||||
(shell_->title_bar_style() != atom::NativeWindowMac::HIDDEN_INSET ||
|
||||
(shell_->title_bar_style() != TitleBarStyle::HIDDEN_INSET ||
|
||||
shell_->fullscreen_window_title())) {
|
||||
[window setTitleVisibility:NSWindowTitleHidden];
|
||||
}
|
||||
|
||||
// Turn off the style for toolbar.
|
||||
if (shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
|
||||
if (shell_->title_bar_style() == TitleBarStyle::HIDDEN_INSET) {
|
||||
shell_->SetStyleMask(false, NSWindowStyleMaskFullSizeContentView);
|
||||
[window setTitlebarAppearsTransparent:YES];
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@ namespace atom {
|
|||
|
||||
class NativeWindow;
|
||||
|
||||
enum MessageBoxType {
|
||||
MESSAGE_BOX_TYPE_NONE = 0,
|
||||
MESSAGE_BOX_TYPE_INFORMATION,
|
||||
MESSAGE_BOX_TYPE_WARNING,
|
||||
MESSAGE_BOX_TYPE_ERROR,
|
||||
MESSAGE_BOX_TYPE_QUESTION,
|
||||
enum class MessageBoxType {
|
||||
kNone = 0,
|
||||
kInformation,
|
||||
kWarning,
|
||||
kError,
|
||||
kQuestion,
|
||||
};
|
||||
|
||||
enum MessageBoxOptions {
|
||||
|
|
|
@ -111,13 +111,13 @@ class GtkMessageBox : public NativeWindowObserver {
|
|||
|
||||
GtkMessageType GetMessageType(MessageBoxType type) {
|
||||
switch (type) {
|
||||
case MESSAGE_BOX_TYPE_INFORMATION:
|
||||
case MessageBoxType::kInformation:
|
||||
return GTK_MESSAGE_INFO;
|
||||
case MESSAGE_BOX_TYPE_WARNING:
|
||||
case MessageBoxType::kWarning:
|
||||
return GTK_MESSAGE_WARNING;
|
||||
case MESSAGE_BOX_TYPE_QUESTION:
|
||||
case MessageBoxType::kQuestion:
|
||||
return GTK_MESSAGE_QUESTION;
|
||||
case MESSAGE_BOX_TYPE_ERROR:
|
||||
case MessageBoxType::kError:
|
||||
return GTK_MESSAGE_ERROR;
|
||||
default:
|
||||
return GTK_MESSAGE_OTHER;
|
||||
|
@ -235,7 +235,7 @@ void ShowMessageBox(NativeWindow* parent,
|
|||
|
||||
void ShowErrorBox(const base::string16& title, const base::string16& content) {
|
||||
if (Browser::Get()->is_ready()) {
|
||||
GtkMessageBox(nullptr, MESSAGE_BOX_TYPE_ERROR, {"OK"}, -1, 0, "Error",
|
||||
GtkMessageBox(nullptr, MessageBoxType::kError, {"OK"}, -1, 0, "Error",
|
||||
base::UTF16ToUTF8(title).c_str(),
|
||||
base::UTF16ToUTF8(content).c_str(), "", false,
|
||||
gfx::ImageSkia())
|
||||
|
|
|
@ -38,11 +38,11 @@ NSAlert* CreateNSAlert(NativeWindow* parent_window,
|
|||
[alert setInformativeText:base::SysUTF8ToNSString(detail)];
|
||||
|
||||
switch (type) {
|
||||
case MESSAGE_BOX_TYPE_INFORMATION:
|
||||
case MessageBoxType::kInformation:
|
||||
alert.alertStyle = NSInformationalAlertStyle;
|
||||
break;
|
||||
case MESSAGE_BOX_TYPE_WARNING:
|
||||
case MESSAGE_BOX_TYPE_ERROR:
|
||||
case MessageBoxType::kWarning:
|
||||
case MessageBoxType::kError:
|
||||
// NSWarningAlertStyle shows the app icon while NSCriticalAlertStyle
|
||||
// shows a warning icon with an app icon badge. Since there is no
|
||||
// error variant, lets just use NSCriticalAlertStyle.
|
||||
|
|
|
@ -119,17 +119,17 @@ int ShowTaskDialogUTF16(NativeWindow* parent,
|
|||
} else {
|
||||
// Show icon according to dialog's type.
|
||||
switch (type) {
|
||||
case MESSAGE_BOX_TYPE_INFORMATION:
|
||||
case MESSAGE_BOX_TYPE_QUESTION:
|
||||
case MessageBoxType::kInformation:
|
||||
case MessageBoxType::kQuestion:
|
||||
config.pszMainIcon = TD_INFORMATION_ICON;
|
||||
break;
|
||||
case MESSAGE_BOX_TYPE_WARNING:
|
||||
case MessageBoxType::kWarning:
|
||||
config.pszMainIcon = TD_WARNING_ICON;
|
||||
break;
|
||||
case MESSAGE_BOX_TYPE_ERROR:
|
||||
case MessageBoxType::kError:
|
||||
config.pszMainIcon = TD_ERROR_ICON;
|
||||
break;
|
||||
case MESSAGE_BOX_TYPE_NONE:
|
||||
case MessageBoxType::kNone:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ void ShowMessageBox(NativeWindow* parent,
|
|||
|
||||
void ShowErrorBox(const base::string16& title, const base::string16& content) {
|
||||
atom::UnresponsiveSuppressor suppressor;
|
||||
ShowTaskDialogUTF16(nullptr, MESSAGE_BOX_TYPE_ERROR, {}, -1, 0, 0, L"Error",
|
||||
ShowTaskDialogUTF16(nullptr, MessageBoxType::kError, {}, -1, 0, 0, L"Error",
|
||||
title, content, L"", nullptr, gfx::ImageSkia());
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ class TrayIcon {
|
|||
virtual void SetToolTip(const std::string& tool_tip) = 0;
|
||||
|
||||
// Sets the status icon highlight mode. This only works on macOS.
|
||||
enum HighlightMode {
|
||||
enum class HighlightMode {
|
||||
ALWAYS, // Always highlight the tray icon
|
||||
NEVER, // Never highlight the tray icon
|
||||
SELECTION // Highlight the tray icon when clicked or the menu is opened
|
||||
|
|
|
@ -425,12 +425,13 @@ const CGFloat kVerticalTitleMargin = 2;
|
|||
}
|
||||
|
||||
- (BOOL)shouldHighlight {
|
||||
using HighlightMode = atom::TrayIcon::HighlightMode;
|
||||
switch (highlight_mode_) {
|
||||
case atom::TrayIcon::HighlightMode::ALWAYS:
|
||||
case HighlightMode::ALWAYS:
|
||||
return true;
|
||||
case atom::TrayIcon::HighlightMode::NEVER:
|
||||
case HighlightMode::NEVER:
|
||||
return false;
|
||||
case atom::TrayIcon::HighlightMode::SELECTION:
|
||||
case HighlightMode::SELECTION:
|
||||
BOOL isMenuOpen = menuController_ && [menuController_ isMenuOpen];
|
||||
return forceHighlight_ || inMouseEventSequence_ || isMenuOpen;
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ void PdfViewerHandler::Initialize(const base::ListValue* args) {
|
|||
|
||||
auto zoom_controller =
|
||||
WebContentsZoomController::FromWebContents(web_ui()->GetWebContents());
|
||||
zoom_controller->SetZoomMode(WebContentsZoomController::ZOOM_MODE_MANUAL);
|
||||
zoom_controller->SetZoomMode(WebContentsZoomController::ZoomMode::MANUAL);
|
||||
zoom_controller->SetZoomLevel(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -139,18 +139,18 @@ bool TaskbarHost::SetProgressBar(HWND window,
|
|||
return false;
|
||||
|
||||
bool success;
|
||||
if (value > 1.0 || state == NativeWindow::PROGRESS_INDETERMINATE) {
|
||||
if (value > 1.0 || state == NativeWindow::ProgressState::kIndeterminate) {
|
||||
success = SUCCEEDED(taskbar_->SetProgressState(window, TBPF_INDETERMINATE));
|
||||
} else if (value < 0 || state == NativeWindow::PROGRESS_NONE) {
|
||||
} else if (value < 0 || state == NativeWindow::ProgressState::kNone) {
|
||||
success = SUCCEEDED(taskbar_->SetProgressState(window, TBPF_NOPROGRESS));
|
||||
} else {
|
||||
// Unless SetProgressState set a blocking state (TBPF_ERROR, TBPF_PAUSED)
|
||||
// for the window, a call to SetProgressValue assumes the TBPF_NORMAL
|
||||
// state even if it is not explicitly set.
|
||||
// SetProgressValue overrides and clears the TBPF_INDETERMINATE state.
|
||||
if (state == NativeWindow::PROGRESS_ERROR) {
|
||||
if (state == NativeWindow::ProgressState::kError) {
|
||||
success = SUCCEEDED(taskbar_->SetProgressState(window, TBPF_ERROR));
|
||||
} else if (state == NativeWindow::PROGRESS_PAUSED) {
|
||||
} else if (state == NativeWindow::ProgressState::kPaused) {
|
||||
success = SUCCEEDED(taskbar_->SetProgressState(window, TBPF_PAUSED));
|
||||
} else {
|
||||
success = SUCCEEDED(taskbar_->SetProgressState(window, TBPF_NORMAL));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue