mirror of
https://github.com/electron/electron.git
synced 2026-05-02 03:00:22 -04:00
feat: programmatically modify traffic light positioning (#22533)
* setter * getter * specs and docs * fixup Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
This commit is contained in:
@@ -814,6 +814,16 @@ void TopLevelWindow::SetVibrancy(v8::Isolate* isolate,
|
||||
window_->SetVibrancy(type);
|
||||
}
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
void TopLevelWindow::SetTrafficLightPosition(const gfx::Point& position) {
|
||||
window_->SetTrafficLightPosition(position);
|
||||
}
|
||||
|
||||
gfx::Point TopLevelWindow::GetTrafficLightPosition() const {
|
||||
return window_->GetTrafficLightPosition();
|
||||
}
|
||||
#endif
|
||||
|
||||
void TopLevelWindow::SetTouchBar(
|
||||
std::vector<gin_helper::PersistentDictionary> items) {
|
||||
window_->SetTouchBar(std::move(items));
|
||||
@@ -1184,6 +1194,12 @@ void TopLevelWindow::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("setAutoHideCursor", &TopLevelWindow::SetAutoHideCursor)
|
||||
#endif
|
||||
.SetMethod("setVibrancy", &TopLevelWindow::SetVibrancy)
|
||||
#if defined(OS_MACOSX)
|
||||
.SetMethod("setTrafficLightPosition",
|
||||
&TopLevelWindow::SetTrafficLightPosition)
|
||||
.SetMethod("getTrafficLightPosition",
|
||||
&TopLevelWindow::GetTrafficLightPosition)
|
||||
#endif
|
||||
.SetMethod("_setTouchBarItems", &TopLevelWindow::SetTouchBar)
|
||||
.SetMethod("_refreshTouchBarItem", &TopLevelWindow::RefreshTouchBarItem)
|
||||
.SetMethod("_setEscapeTouchBarItem",
|
||||
|
||||
@@ -185,6 +185,12 @@ class TopLevelWindow : public gin_helper::TrackableObject<TopLevelWindow>,
|
||||
bool IsVisibleOnAllWorkspaces();
|
||||
void SetAutoHideCursor(bool auto_hide);
|
||||
virtual void SetVibrancy(v8::Isolate* isolate, v8::Local<v8::Value> value);
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
void SetTrafficLightPosition(const gfx::Point& position);
|
||||
gfx::Point GetTrafficLightPosition() const;
|
||||
#endif
|
||||
|
||||
void SetTouchBar(std::vector<gin_helper::PersistentDictionary> items);
|
||||
void RefreshTouchBarItem(const std::string& item_id);
|
||||
void SetEscapeTouchBarItem(gin_helper::PersistentDictionary item);
|
||||
|
||||
@@ -194,6 +194,12 @@ class NativeWindow : public base::SupportsUserData,
|
||||
// Vibrancy API
|
||||
virtual void SetVibrancy(const std::string& type);
|
||||
|
||||
// Traffic Light API
|
||||
#if defined(OS_MACOSX)
|
||||
virtual void SetTrafficLightPosition(const gfx::Point& position) = 0;
|
||||
virtual gfx::Point GetTrafficLightPosition() const = 0;
|
||||
#endif
|
||||
|
||||
// Touchbar API
|
||||
virtual void SetTouchBar(std::vector<gin_helper::PersistentDictionary> items);
|
||||
virtual void RefreshTouchBarItem(const std::string& item_id);
|
||||
|
||||
@@ -153,6 +153,8 @@ class NativeWindowMac : public NativeWindow, public ui::NativeThemeObserver {
|
||||
// Custom traffic light positioning
|
||||
void RepositionTrafficLights();
|
||||
void SetExitingFullScreen(bool flag);
|
||||
void SetTrafficLightPosition(const gfx::Point& position) override;
|
||||
gfx::Point GetTrafficLightPosition() const override;
|
||||
void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
|
||||
|
||||
enum class TitleBarStyle {
|
||||
|
||||
@@ -1552,6 +1552,15 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
|
||||
[effect_view setMaterial:vibrancyType];
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetTrafficLightPosition(const gfx::Point& position) {
|
||||
traffic_light_position_ = position;
|
||||
RepositionTrafficLights();
|
||||
}
|
||||
|
||||
gfx::Point NativeWindowMac::GetTrafficLightPosition() const {
|
||||
return traffic_light_position_;
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetTouchBar(
|
||||
std::vector<gin_helper::PersistentDictionary> items) {
|
||||
if (@available(macOS 10.12.2, *)) {
|
||||
|
||||
Reference in New Issue
Block a user