ime_mode_indicator_view.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ASH_IME_IME_MODE_INDICATOR_VIEW_H_
  5. #define ASH_IME_IME_MODE_INDICATOR_VIEW_H_
  6. #include <string>
  7. #include "ash/ash_export.h"
  8. #include "base/timer/timer.h"
  9. #include "ui/base/metadata/metadata_header_macros.h"
  10. #include "ui/gfx/geometry/rect.h"
  11. #include "ui/views/bubble/bubble_dialog_delegate_view.h"
  12. #include "ui/views/widget/widget.h"
  13. namespace views {
  14. class Label;
  15. } // namespace views
  16. namespace ash {
  17. // A small bubble that shows the short name of the current IME (e.g. "DV" for
  18. // Dvorak) after switching IMEs with an accelerator (e.g. Ctrl-Space).
  19. class ASH_EXPORT ImeModeIndicatorView : public views::BubbleDialogDelegateView {
  20. public:
  21. METADATA_HEADER(ImeModeIndicatorView);
  22. // The cursor bounds is in the universal screen coordinates in DIP.
  23. ImeModeIndicatorView(const gfx::Rect& cursor_bounds,
  24. const std::u16string& label);
  25. ImeModeIndicatorView(const ImeModeIndicatorView&) = delete;
  26. ImeModeIndicatorView& operator=(const ImeModeIndicatorView&) = delete;
  27. ~ImeModeIndicatorView() override;
  28. // Show the mode indicator then hide with fading animation.
  29. void ShowAndFadeOut();
  30. // views::BubbleDialogDelegateView override:
  31. void OnBeforeBubbleWidgetInit(views::Widget::InitParams* params,
  32. views::Widget* widget) const override;
  33. gfx::Size CalculatePreferredSize() const override;
  34. void Init() override;
  35. protected:
  36. // views::WidgetDelegateView overrides:
  37. std::unique_ptr<views::NonClientFrameView> CreateNonClientFrameView(
  38. views::Widget* widget) override;
  39. private:
  40. gfx::Rect cursor_bounds_;
  41. views::Label* label_view_;
  42. base::OneShotTimer timer_;
  43. };
  44. } // namespace ash
  45. #endif // ASH_IME_IME_MODE_INDICATOR_VIEW_H_