Add Marker tool to Stylus tools
Add a Marker tool option to Stylus tools. Clicking on the Marker tool currently has no effect, except changing the tray icon. Full marker functionality will be added in the following CL. Screenshot: https://screenshot.googleplex.com/BZyZaQiPkQqq354 Bug: 342104047 Change-Id: If0f1962b9218d6f82bca1fc4cd8abd5e9c1eec43 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5717688 Reviewed-by: Michele Fan <michelefan@chromium.org> Reviewed-by: Xiaoqian Dai <xdai@chromium.org> Reviewed-by: Alex Newcomer <newcomer@chromium.org> Commit-Queue: Sanja Perisic <sanjaperisic@chromium.org> Cr-Commit-Position: refs/heads/main@{#1334158}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
e117dea97d
commit
1aaff5176e
@ -2196,6 +2196,8 @@ component("ash") {
|
||||
"system/palette/tools/laser_pointer_mode.h",
|
||||
"system/palette/tools/magnifier_mode.cc",
|
||||
"system/palette/tools/magnifier_mode.h",
|
||||
"system/palette/tools/marker_mode.cc",
|
||||
"system/palette/tools/marker_mode.h",
|
||||
"system/pcie_peripheral/pcie_peripheral_notification_controller.cc",
|
||||
"system/pcie_peripheral/pcie_peripheral_notification_controller.h",
|
||||
"system/phonehub/app_stream_connection_error_dialog.cc",
|
||||
|
@ -36,6 +36,16 @@ AnnotationSourceWatcher::~AnnotationSourceWatcher() {
|
||||
capture_mode_controller_ = nullptr;
|
||||
}
|
||||
|
||||
void AnnotationSourceWatcher::NotifyMarkerClicked(aura::Window* current_root) {
|
||||
// TODO(b/342104047): implement functionality
|
||||
}
|
||||
void AnnotationSourceWatcher::NotifyMarkerEnabled(aura::Window* current_root) {
|
||||
// TODO(b/342104047): implement functionality
|
||||
}
|
||||
void AnnotationSourceWatcher::NotifyMarkerDisabled() {
|
||||
// TODO(b/342104047): implement functionality
|
||||
}
|
||||
|
||||
void AnnotationSourceWatcher::OnRecordingStarted(aura::Window* current_root) {
|
||||
if (!capture_mode_controller_->ShouldAllowAnnotating()) {
|
||||
return;
|
||||
|
@ -35,6 +35,10 @@ class ASH_EXPORT AnnotationSourceWatcher : public CaptureModeObserver,
|
||||
AnnotationSourceWatcher& operator=(const AnnotationSourceWatcher&) = delete;
|
||||
~AnnotationSourceWatcher() override;
|
||||
|
||||
void NotifyMarkerClicked(aura::Window* current_root);
|
||||
void NotifyMarkerEnabled(aura::Window* current_root);
|
||||
void NotifyMarkerDisabled();
|
||||
|
||||
// CaptureModeObserver:
|
||||
void OnRecordingStarted(aura::Window* current_root) override;
|
||||
void OnRecordingEnded() override;
|
||||
|
@ -42,6 +42,9 @@ class ASH_EXPORT AnnotatorController : public AnnotatorControllerBase {
|
||||
~AnnotatorController() override;
|
||||
|
||||
bool is_annotator_enabled() const { return annotator_enabled_; }
|
||||
AnnotationSourceWatcher* annotation_source_watcher() {
|
||||
return annotation_source_watcher_.get();
|
||||
}
|
||||
|
||||
// Sets the annotator tool.
|
||||
virtual void SetAnnotatorTool(const AnnotatorTool& tool);
|
||||
|
@ -2219,6 +2219,9 @@ You can also use the keyboard shortcut. First, highlight text, then press <ph na
|
||||
<message name="IDS_ASH_STYLUS_TOOLS_MAGNIFIER_MODE" desc="Title of the magnification mode in the stylus tools. Clicking this button opens up a magnifier. The magnifier remains active until the user turns it off by tapping the same button again.">
|
||||
Magnifying glass
|
||||
</message>
|
||||
<message name="IDS_ASH_STYLUS_TOOLS_MARKER_MODE" desc="Title of the marker mode in the stylus tools. Clicking this button turns the mouse into a marker. The marker remains active until the user turns it off by tapping the same button again.">
|
||||
Marker tool
|
||||
</message>
|
||||
<message name="IDS_ASH_STYLUS_TOOLS_TITLE" desc="The title of the stylus tools dialog in the ash shelf.">
|
||||
Stylus tools
|
||||
</message>
|
||||
|
@ -0,0 +1 @@
|
||||
e3280fb3d40f847e428003cfffc8d351baea312e
|
@ -19,6 +19,8 @@ PaletteTrayOptions PaletteToolIdToPaletteTrayOptions(PaletteToolId tool_id) {
|
||||
return PALETTE_MAGNIFY;
|
||||
case PaletteToolId::ENTER_CAPTURE_MODE:
|
||||
return PALETTE_ENTER_CAPTURE_MODE;
|
||||
case PaletteToolId::MARKER_MODE:
|
||||
return PALETTE_MARKER_MODE;
|
||||
}
|
||||
|
||||
NOTREACHED_IN_MIGRATION();
|
||||
|
@ -20,6 +20,7 @@ enum class PaletteToolId {
|
||||
LASER_POINTER,
|
||||
MAGNIFY,
|
||||
ENTER_CAPTURE_MODE,
|
||||
MARKER_MODE,
|
||||
};
|
||||
|
||||
// Usage of each pen palette option. This enum is used to back an UMA histogram
|
||||
@ -35,6 +36,7 @@ enum PaletteTrayOptions {
|
||||
PALETTE_LASER_POINTER,
|
||||
PALETTE_METALAYER,
|
||||
PALETTE_ENTER_CAPTURE_MODE,
|
||||
PALETTE_MARKER_MODE,
|
||||
PALETTE_OPTIONS_COUNT
|
||||
};
|
||||
|
||||
|
@ -7,12 +7,14 @@
|
||||
#include <memory>
|
||||
|
||||
#include "ash/assistant/util/assistant_util.h"
|
||||
#include "ash/constants/ash_features.h"
|
||||
#include "ash/system/palette/palette_tool_manager.h"
|
||||
#include "ash/system/palette/palette_utils.h"
|
||||
#include "ash/system/palette/tools/create_note_action.h"
|
||||
#include "ash/system/palette/tools/enter_capture_mode.h"
|
||||
#include "ash/system/palette/tools/laser_pointer_mode.h"
|
||||
#include "ash/system/palette/tools/magnifier_mode.h"
|
||||
#include "ash/system/palette/tools/marker_mode.h"
|
||||
#include "ui/gfx/paint_vector_icon.h"
|
||||
|
||||
namespace ash {
|
||||
@ -23,6 +25,9 @@ void PaletteTool::RegisterToolInstances(PaletteToolManager* tool_manager) {
|
||||
tool_manager->AddTool(std::make_unique<CreateNoteAction>(tool_manager));
|
||||
tool_manager->AddTool(std::make_unique<LaserPointerMode>(tool_manager));
|
||||
tool_manager->AddTool(std::make_unique<MagnifierMode>(tool_manager));
|
||||
if (features::IsAnnotatorModeEnabled()) {
|
||||
tool_manager->AddTool(std::make_unique<MarkerMode>(tool_manager));
|
||||
}
|
||||
}
|
||||
|
||||
PaletteTool::PaletteTool(Delegate* delegate) : delegate_(delegate) {}
|
||||
|
92
ash/system/palette/tools/marker_mode.cc
Normal file
92
ash/system/palette/tools/marker_mode.cc
Normal file
@ -0,0 +1,92 @@
|
||||
// Copyright 2024 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "ash/system/palette/tools/marker_mode.h"
|
||||
|
||||
#include "ash/annotator/annotation_source_watcher.h"
|
||||
#include "ash/annotator/annotator_controller.h"
|
||||
#include "ash/resources/vector_icons/vector_icons.h"
|
||||
#include "ash/shell.h"
|
||||
#include "ash/strings/grit/ash_strings.h"
|
||||
#include "ash/system/palette/palette_ids.h"
|
||||
#include "ui/aura/window.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/display/screen.h"
|
||||
#include "ui/gfx/vector_icon_types.h"
|
||||
#include "ui/views/view.h"
|
||||
#include "ui/wm/core/cursor_manager.h"
|
||||
|
||||
namespace ash {
|
||||
|
||||
namespace {
|
||||
|
||||
aura::Window* GetRootWindow() {
|
||||
const int64_t display_id = Shell::Get()->cursor_manager()->GetDisplay().id();
|
||||
|
||||
// The Display object returned by `CursorManager::GetDisplay()` may be stale,
|
||||
// but will have the correct id.
|
||||
auto* root = Shell::GetRootWindowForDisplayId(display_id);
|
||||
return root ? root : Shell::GetPrimaryRootWindow();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
MarkerMode::MarkerMode(Delegate* delegate) : CommonPaletteTool(delegate) {}
|
||||
|
||||
MarkerMode::~MarkerMode() = default;
|
||||
|
||||
PaletteGroup MarkerMode::GetGroup() const {
|
||||
return PaletteGroup::MODE;
|
||||
}
|
||||
|
||||
PaletteToolId MarkerMode::GetToolId() const {
|
||||
return PaletteToolId::MARKER_MODE;
|
||||
}
|
||||
|
||||
// TODO(b/339834202): Consider changing to base class's OnEnable() calling a
|
||||
// overridable function.
|
||||
void MarkerMode::OnEnable() {
|
||||
CommonPaletteTool::OnEnable();
|
||||
delegate()->HidePaletteImmediately();
|
||||
Shell::Get()
|
||||
->annotator_controller()
|
||||
->annotation_source_watcher()
|
||||
->NotifyMarkerEnabled(GetRootWindow());
|
||||
}
|
||||
|
||||
// TODO(b/339834202): Consider changing to base class's OnDisable() calling a
|
||||
// overridable function.
|
||||
void MarkerMode::OnDisable() {
|
||||
CommonPaletteTool::OnDisable();
|
||||
Shell::Get()
|
||||
->annotator_controller()
|
||||
->annotation_source_watcher()
|
||||
->NotifyMarkerDisabled();
|
||||
}
|
||||
|
||||
views::View* MarkerMode::CreateView() {
|
||||
return CreateDefaultView(
|
||||
l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_MARKER_MODE));
|
||||
}
|
||||
|
||||
// TODO(b/339834202): Consider setting icons in ctor.
|
||||
const gfx::VectorIcon& MarkerMode::GetActiveTrayIcon() const {
|
||||
return kPaletteTrayIconProjectorIcon;
|
||||
}
|
||||
|
||||
const gfx::VectorIcon& MarkerMode::GetPaletteIcon() const {
|
||||
return kPaletteTrayIconProjectorIcon;
|
||||
}
|
||||
|
||||
// TODO(b/339834202): Consider changing to base class's OnViewClicked() calling
|
||||
// a overridable function.
|
||||
void MarkerMode::OnViewClicked(views::View* sender) {
|
||||
Shell::Get()
|
||||
->annotator_controller()
|
||||
->annotation_source_watcher()
|
||||
->NotifyMarkerClicked(GetRootWindow());
|
||||
CommonPaletteTool::OnViewClicked(sender);
|
||||
}
|
||||
|
||||
} // namespace ash
|
44
ash/system/palette/tools/marker_mode.h
Normal file
44
ash/system/palette/tools/marker_mode.h
Normal file
@ -0,0 +1,44 @@
|
||||
// Copyright 2024 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ASH_SYSTEM_PALETTE_TOOLS_MARKER_MODE_H_
|
||||
#define ASH_SYSTEM_PALETTE_TOOLS_MARKER_MODE_H_
|
||||
|
||||
#include "ash/system/palette/common_palette_tool.h"
|
||||
|
||||
namespace gfx {
|
||||
struct VectorIcon;
|
||||
}
|
||||
|
||||
namespace views {
|
||||
class View;
|
||||
}
|
||||
|
||||
namespace ash {
|
||||
|
||||
// This class manages the palette tool which is a point of entry for marker
|
||||
// mode. Marker mode allows users to annotate on the screen.
|
||||
class MarkerMode : public CommonPaletteTool {
|
||||
public:
|
||||
explicit MarkerMode(Delegate* delegate);
|
||||
MarkerMode(const MarkerMode&) = delete;
|
||||
MarkerMode& operator=(const MarkerMode&) = delete;
|
||||
~MarkerMode() override;
|
||||
|
||||
// PaletteTool:
|
||||
PaletteGroup GetGroup() const override;
|
||||
PaletteToolId GetToolId() const override;
|
||||
void OnEnable() override;
|
||||
void OnDisable() override;
|
||||
views::View* CreateView() override;
|
||||
const gfx::VectorIcon& GetActiveTrayIcon() const override;
|
||||
|
||||
// CommonPaletteTool:
|
||||
const gfx::VectorIcon& GetPaletteIcon() const override;
|
||||
void OnViewClicked(views::View* sender) override;
|
||||
};
|
||||
|
||||
} // namespace ash
|
||||
|
||||
#endif // ASH_SYSTEM_PALETTE_TOOLS_MARKER_MODE_H_
|
@ -1633,6 +1633,7 @@ ash/webui/personalization_app/mojom/personalization_app.mojom -->
|
||||
<int value="7" label="Laser pointer mode"/>
|
||||
<int value="8" label="Assistant mode"/>
|
||||
<int value="9" label="Enter capture mode"/>
|
||||
<int value="10" label="Marker mode"/>
|
||||
</enum>
|
||||
|
||||
<enum name="PanelButton">
|
||||
|
Reference in New Issue
Block a user