aboutsummaryrefslogtreecommitdiff
path: root/src/osx
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-02-21 18:44:40 +0800
committercrupest <crupest@outlook.com>2022-02-21 18:44:40 +0800
commitced1a63686e6c64cb574d74a34d1bbd07d0a668e (patch)
tree4082e4689e5e7cede8d59a0538d0f1ae37064acb /src/osx
parent6b00fca7c662301bf657a99cb1e89f21541a46bc (diff)
downloadcru-ced1a63686e6c64cb574d74a34d1bbd07d0a668e.tar.gz
cru-ced1a63686e6c64cb574d74a34d1bbd07d0a668e.tar.bz2
cru-ced1a63686e6c64cb574d74a34d1bbd07d0a668e.zip
...
Diffstat (limited to 'src/osx')
-rw-r--r--src/osx/graphics/quartz/Painter.cpp8
-rw-r--r--src/osx/gui/Clipboard.mm4
-rw-r--r--src/osx/gui/ClipboardPrivate.h3
-rw-r--r--src/osx/gui/InputMethod.mm12
-rw-r--r--src/osx/gui/UiApplication.mm5
-rw-r--r--src/osx/gui/Window.mm32
6 files changed, 11 insertions, 53 deletions
diff --git a/src/osx/graphics/quartz/Painter.cpp b/src/osx/graphics/quartz/Painter.cpp
index d74e456b..a8c3715a 100644
--- a/src/osx/graphics/quartz/Painter.cpp
+++ b/src/osx/graphics/quartz/Painter.cpp
@@ -1,6 +1,5 @@
#include "cru/osx/graphics/quartz/Painter.h"
-#include "cru/common/Logger.h"
#include "cru/osx/graphics/quartz/Brush.h"
#include "cru/osx/graphics/quartz/Convert.h"
#include "cru/osx/graphics/quartz/Geometry.h"
@@ -27,10 +26,6 @@ QuartzCGContextPainter::QuartzCGContextPainter(
transform_ = Matrix::Scale(1, -1) * Matrix::Translation(0, size.height);
CGContextConcatCTM(cg_context_, Convert(transform_));
-
- // log::TagDebug(log_tag,
- // u"Created with CGContext: {}, Auto Release: {}, Size: {}.",
- // cg_context, auto_release, size_);
}
QuartzCGContextPainter::~QuartzCGContextPainter() {
@@ -61,8 +56,6 @@ void QuartzCGContextPainter::Clear(const Color& color) {
color.GetFloatGreen(), color.GetFloatBlue(),
color.GetFloatAlpha());
CGContextFillRect(cg_context_, Convert(Rect{Point{}, size_}));
-
- // log::TagDebug(log_tag, u"Clear with color {}, size {}.", color, size_);
}
void QuartzCGContextPainter::DrawLine(const Point& start, const Point& end,
@@ -225,7 +218,6 @@ void QuartzCGContextPainter::DoEndDraw() {
if (cg_context_) {
CGContextFlush(cg_context_);
CGContextSynchronize(cg_context_);
- // log::TagDebug(log_tag, u"End draw and flush.");
on_end_draw_(this);
}
diff --git a/src/osx/gui/Clipboard.mm b/src/osx/gui/Clipboard.mm
index b37efce2..6e3fb076 100644
--- a/src/osx/gui/Clipboard.mm
+++ b/src/osx/gui/Clipboard.mm
@@ -1,7 +1,7 @@
#include "cru/osx/gui/Clipboard.h"
#include "ClipboardPrivate.h"
-#include "cru/common/Logger.h"
+#include "cru/common/log/Logger.h"
#include "cru/osx/Convert.h"
#include <memory>
@@ -27,7 +27,7 @@ OsxClipboardPrivate::~OsxClipboardPrivate() {}
String OsxClipboardPrivate::GetText() {
auto result = [pasteboard_ readObjectsForClasses:@[ NSString.class ] options:nil];
if (result == nil) {
- log::TagWarn(log_tag, u"Failed to get text from clipboard");
+ CRU_LOG_WARN(u"Failed to get text from clipboard");
return u"";
} else {
if (result.count == 0) {
diff --git a/src/osx/gui/ClipboardPrivate.h b/src/osx/gui/ClipboardPrivate.h
index 93fe5448..63145a64 100644
--- a/src/osx/gui/ClipboardPrivate.h
+++ b/src/osx/gui/ClipboardPrivate.h
@@ -7,8 +7,7 @@
namespace cru::platform::gui::osx {
namespace details {
class OsxClipboardPrivate : public Object {
- CRU_DEFINE_CLASS_LOG_TAG(
- u"cru::platform::gui::osx::details::OsxClipboardPrivate")
+ CRU_DEFINE_CLASS_LOG_TAG(u"OsxClipboardPrivate")
public:
explicit OsxClipboardPrivate(NSPasteboard* pasteboard);
diff --git a/src/osx/gui/InputMethod.mm b/src/osx/gui/InputMethod.mm
index 3a961209..2c19c358 100644
--- a/src/osx/gui/InputMethod.mm
+++ b/src/osx/gui/InputMethod.mm
@@ -3,7 +3,7 @@
#import <AppKit/AppKit.h>
#include "InputMethodPrivate.h"
#include "WindowPrivate.h"
-#include "cru/common/Logger.h"
+#include "cru/common/log/Logger.h"
#include "cru/osx/Convert.h"
#include "cru/osx/gui/Window.h"
@@ -46,15 +46,9 @@ OsxInputMethodContext::OsxInputMethodContext(OsxWindow* window)
OsxInputMethodContext::~OsxInputMethodContext() {}
-void OsxInputMethodContext::EnableIME() {
- // log::Debug(u"Enable IME.");
- p_->Activate();
-}
+void OsxInputMethodContext::EnableIME() { p_->Activate(); }
-void OsxInputMethodContext::DisableIME() {
- // log::Debug(u"Disable IME.");
- p_->Deactivate();
-}
+void OsxInputMethodContext::DisableIME() { p_->Deactivate(); }
bool OsxInputMethodContext::ShouldManuallyDrawCompositionText() { return true; }
diff --git a/src/osx/gui/UiApplication.mm b/src/osx/gui/UiApplication.mm
index 20ce82d3..43c49c5c 100644
--- a/src/osx/gui/UiApplication.mm
+++ b/src/osx/gui/UiApplication.mm
@@ -1,7 +1,7 @@
#include "cru/osx/gui/UiApplication.h"
#include "ClipboardPrivate.h"
-#include "cru/common/Logger.h"
+#include "cru/common/log/Logger.h"
#include "cru/common/platform/osx/Convert.h"
#include "cru/osx/graphics/quartz/Factory.h"
#include "cru/osx/gui/Clipboard.h"
@@ -80,9 +80,6 @@ OsxUiApplication::OsxUiApplication()
: OsxGuiResource(this), p_(new details::OsxUiApplicationPrivate(this)) {
[NSApplication sharedApplication];
- // Add stdio logger.
- log::Logger::GetInstance()->AddSource(std::make_unique<log::StdioLogSource>());
-
[NSApp setDelegate:p_->app_delegate_];
p_->quartz_graphics_factory_ = std::make_unique<graphics::osx::quartz::QuartzGraphicsFactory>();
p_->cursor_manager_ = std::make_unique<OsxCursorManager>(this);
diff --git a/src/osx/gui/Window.mm b/src/osx/gui/Window.mm
index 403ae030..8d15ef37 100644
--- a/src/osx/gui/Window.mm
+++ b/src/osx/gui/Window.mm
@@ -3,8 +3,8 @@
#include "CursorPrivate.h"
#include "InputMethodPrivate.h"
-#include "cru/common/Logger.h"
#include "cru/common/Range.h"
+#include "cru/common/log/Logger.h"
#include "cru/osx/Convert.h"
#include "cru/osx/graphics/quartz/Convert.h"
#include "cru/osx/graphics/quartz/Painter.h"
@@ -351,7 +351,6 @@ std::unique_ptr<graphics::IPainter> OsxWindow::BeginPaint() {
return std::make_unique<cru::platform::graphics::osx::quartz::QuartzCGContextPainter>(
GetUiApplication()->GetGraphicsFactory(), cg_context, false, GetClientSize(),
[this](graphics::osx::quartz::QuartzCGContextPainter*) {
- // log::Debug(u"Finish painting and invalidate view.");
[[p_->window_ contentView] setNeedsDisplay:YES];
});
}
@@ -470,7 +469,6 @@ cru::platform::gui::KeyModifier GetKeyModifier(NSEvent* event) {
}
- (void)drawRect:(NSRect)dirtyRect {
- // cru::log::TagDebug(u"CruView", u"Begin to draw layer in view.");
auto cg_context = [[NSGraphicsContext currentContext] CGContext];
auto layer = _p->GetDrawLayer();
Ensures(layer);
@@ -486,32 +484,26 @@ cru::platform::gui::KeyModifier GetKeyModifier(NSEvent* event) {
}
- (void)mouseMoved:(NSEvent*)event {
- // cru::log::TagDebug(u"CruView", u"Recieved mouse move.");
_p->OnMouseMove(cru::platform::Point(event.locationInWindow.x, event.locationInWindow.y));
}
- (void)mouseDragged:(NSEvent*)event {
- // cru::log::TagDebug(u"CruView", u"Recieved mouse move.");
_p->OnMouseMove(cru::platform::Point(event.locationInWindow.x, event.locationInWindow.y));
}
- (void)rightMouseDragged:(NSEvent*)event {
- // cru::log::TagDebug(u"CruView", u"Recieved mouse move.");
_p->OnMouseMove(cru::platform::Point(event.locationInWindow.x, event.locationInWindow.y));
}
- (void)mouseEntered:(NSEvent*)event {
- // cru::log::TagDebug(u"CruView", u"Recieved mouse enter.");
_p->OnMouseEnterLeave(cru::platform::gui::MouseEnterLeaveType::Enter);
}
- (void)mouseExited:(NSEvent*)event {
- // cru::log::TagDebug(u"CruView", u"Recieved mouse exit.");
_p->OnMouseEnterLeave(cru::platform::gui::MouseEnterLeaveType::Leave);
}
- (void)mouseDown:(NSEvent*)event {
- // cru::log::TagDebug(u"CruView", u"Recieved mouse down.");
[[self window] makeKeyWindow];
auto key_modifier = GetKeyModifier(event);
@@ -521,8 +513,6 @@ cru::platform::gui::KeyModifier GetKeyModifier(NSEvent* event) {
}
- (void)mouseUp:(NSEvent*)event {
- // cru::log::TagDebug(u"CruView", u"Recieved mouse up.");
-
auto key_modifier = GetKeyModifier(event);
cru::platform::Point p(event.locationInWindow.x, event.locationInWindow.y);
@@ -530,8 +520,6 @@ cru::platform::gui::KeyModifier GetKeyModifier(NSEvent* event) {
}
- (void)rightMouseDown:(NSEvent*)event {
- // cru::log::TagDebug(u"CruView", u"Recieved right mouse down.");
-
auto key_modifier = GetKeyModifier(event);
cru::platform::Point p(event.locationInWindow.x, event.locationInWindow.y);
@@ -539,8 +527,6 @@ cru::platform::gui::KeyModifier GetKeyModifier(NSEvent* event) {
}
- (void)rightMouseUp:(NSEvent*)event {
- // cru::log::TagDebug(u"CruView", u"Recieved right mouse up.");
-
auto key_modifier = GetKeyModifier(event);
cru::platform::Point p(event.locationInWindow.x, event.locationInWindow.y);
@@ -548,8 +534,6 @@ cru::platform::gui::KeyModifier GetKeyModifier(NSEvent* event) {
}
- (void)scrollWheel:(NSEvent*)event {
- // cru::log::TagDebug(u"CruView", u"Recieved mouse wheel.");
-
auto key_modifier = GetKeyModifier(event);
cru::platform::Point p(event.locationInWindow.x, event.locationInWindow.y);
@@ -620,10 +604,6 @@ const std::unordered_set<KeyCode> input_context_handle_codes_when_has_text{
KeyCode::Right, KeyCode::Up, KeyCode::Down};
- (void)keyDown:(NSEvent*)event {
- if constexpr (key_down_debug) {
- cru::log::TagDebug(u"CruView", u"Recieved key down.");
- }
-
auto key_modifier = GetKeyModifier(event);
bool handled = false;
@@ -655,15 +635,11 @@ const std::unordered_set<KeyCode> input_context_handle_codes_when_has_text{
if (!handled) {
_p->OnKeyDown(c, key_modifier);
- } else {
- if constexpr (key_down_debug) {
- cru::log::TagDebug(u"CruView", u"Key down is handled by input context.");
- }
}
}
- (void)keyUp:(NSEvent*)event {
- // cru::log::TagDebug(u"CruView", u"Recieved key up.");
+ // cru::CRU_LOG_DEBUG(u"CruView", u"Recieved key up.");
auto key_modifier = GetKeyModifier(event);
auto c = cru::platform::gui::osx::KeyCodeFromOsxToCru(event.keyCode);
@@ -698,7 +674,7 @@ const std::unordered_set<KeyCode> input_context_handle_codes_when_has_text{
auto ss = Convert(s);
- // cru::log::TagDebug(u"CruView",
+ // cru::CRU_LOG_DEBUG(u"CruView",
// u"Received setMarkedText string: {}, selected range: ({}, {}), "
// u"replacement range: ({}, {}).",
// ss, selectedRange.location, selectedRange.length, replacementRange.location,
@@ -759,7 +735,7 @@ const std::unordered_set<KeyCode> input_context_handle_codes_when_has_text{
_input_context_p->SetCompositionText(cru::platform::gui::CompositionText());
cru::String ss = Convert(s);
- // cru::log::TagDebug(u"CruView", u"Finish composition: {}, replacement range: ({}, {})", ss,
+ // cru::CRU_LOG_DEBUG(u"CruView", u"Finish composition: {}, replacement range: ({}, {})", ss,
// replacementRange.location, replacementRange.length);
_input_context_p->RaiseCompositionEvent();