Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add touch events of platform view channel for tizen #8

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions shell/platform/tizen/channels/platform_view_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include "platform_view_channel.h"

#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/plugin_registrar.h"
#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/standard_method_codec.h"
#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/standard_message_codec.h"
#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/standard_method_codec.h"
#include "flutter/shell/platform/common/cpp/json_method_codec.h"
#include "flutter/shell/platform/tizen/logger.h"
#include "flutter/shell/platform/tizen/public/flutter_platform_view.h"
Expand Down Expand Up @@ -52,6 +52,17 @@ flutter::EncodableMap extractMapFromMap(
return flutter::EncodableMap();
}

flutter::EncodableList extractListFromMap(
const flutter::EncodableValue& arguments, const char* key) {
if (std::holds_alternative<flutter::EncodableMap>(arguments)) {
flutter::EncodableMap values = std::get<flutter::EncodableMap>(arguments);
flutter::EncodableValue value = values[flutter::EncodableValue(key)];
if (std::holds_alternative<flutter::EncodableList>(value))
return std::get<flutter::EncodableList>(value);
}
return flutter::EncodableList();
}

PlatformViewChannel::PlatformViewChannel(flutter::BinaryMessenger* messenger)
: channel_(
std::make_unique<flutter::MethodChannel<flutter::EncodableValue>>(
Expand Down Expand Up @@ -126,8 +137,23 @@ void PlatformViewChannel::HandleMethodCall(
it->second->resize(width, height);
result->NotImplemented();
} else if (method == "touch") {
LoggerD("PlatformViewChannel touch");
result->NotImplemented();
int type, button;
double x, y, dx, dy;

flutter::EncodableList event = extractListFromMap(arguments, "event");
if (event.size() != 6) {
result->Error("Invalid Arguments");
return;
}
type = std::get<int>(event[0]);
button = std::get<int>(event[1]);
x = std::get<double>(event[2]);
y = std::get<double>(event[3]);
dx = std::get<double>(event[4]);
dy = std::get<double>(event[5]);

it->second->touch(type, button, x, y, dx, dy);
result->Success();
} else if (method == "setDirection") {
LoggerD("PlatformViewChannel setDirection");
result->NotImplemented();
Expand Down
3 changes: 2 additions & 1 deletion shell/platform/tizen/public/flutter_platform_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class PlatformView {
flutter::PluginRegistrar* getPluginRegistrar() { return registrar_; }
virtual void dispose() = 0;
virtual void resize(double width, double height) = 0;
virtual void touch() = 0;
virtual void touch(int type, int button, double x, double y, double dx,
double dy) = 0;
virtual void setDirection(int direction) = 0;
virtual void clearFocus() = 0;

Expand Down