Skip to content

Commit

Permalink
Change method name starting with lower case (flutter-tizen#16)
Browse files Browse the repository at this point in the history
* According to convention, I change first letter of method name from lower case to upper case.
  First, I apply only files related to platform view.
  • Loading branch information
seungsoo47 authored Dec 24, 2020
1 parent 26a6f7c commit 167ac22
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 60 deletions.
64 changes: 32 additions & 32 deletions shell/platform/tizen/channels/platform_view_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

static constexpr char kChannelName[] = "flutter/platform_views";

std::string extractStringFromMap(const flutter::EncodableValue& arguments,
std::string ExtractStringFromMap(const flutter::EncodableValue& arguments,
const char* key) {
if (std::holds_alternative<flutter::EncodableMap>(arguments)) {
flutter::EncodableMap values = std::get<flutter::EncodableMap>(arguments);
Expand All @@ -22,7 +22,7 @@ std::string extractStringFromMap(const flutter::EncodableValue& arguments,
}
return std::string();
}
int extractIntFromMap(const flutter::EncodableValue& arguments,
int ExtractIntFromMap(const flutter::EncodableValue& arguments,
const char* key) {
if (std::holds_alternative<flutter::EncodableMap>(arguments)) {
flutter::EncodableMap values = std::get<flutter::EncodableMap>(arguments);
Expand All @@ -31,7 +31,7 @@ int extractIntFromMap(const flutter::EncodableValue& arguments,
}
return -1;
}
double extractDoubleFromMap(const flutter::EncodableValue& arguments,
double ExtractDoubleFromMap(const flutter::EncodableValue& arguments,
const char* key) {
if (std::holds_alternative<flutter::EncodableMap>(arguments)) {
flutter::EncodableMap values = std::get<flutter::EncodableMap>(arguments);
Expand All @@ -41,7 +41,7 @@ double extractDoubleFromMap(const flutter::EncodableValue& arguments,
return -1;
}

flutter::EncodableMap extractMapFromMap(
flutter::EncodableMap ExtractMapFromMap(
const flutter::EncodableValue& arguments, const char* key) {
if (std::holds_alternative<flutter::EncodableMap>(arguments)) {
flutter::EncodableMap values = std::get<flutter::EncodableMap>(arguments);
Expand All @@ -52,7 +52,7 @@ flutter::EncodableMap extractMapFromMap(
return flutter::EncodableMap();
}

flutter::EncodableList extractListFromMap(
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);
Expand All @@ -77,34 +77,34 @@ PlatformViewChannel::PlatformViewChannel(flutter::BinaryMessenger* messenger)
PlatformViewChannel::~PlatformViewChannel() {
// Clean-up view_factories_
for (auto const& [viewType, viewFactory] : view_factories_) {
viewFactory->dispose();
viewFactory->Dispose();
}
view_factories_.clear();

// Clean-up view_instances_
for (auto const& [viewId, viewInstance] : view_instances_) {
viewInstance->dispose();
viewInstance->Dispose();
delete viewInstance;
}
view_instances_.clear();
}

void PlatformViewChannel::sendKeyEvent(Ecore_Event_Key* key, bool is_down) {
auto instances = viewInstances();
auto it = instances.find(currentFocusedViewId());
void PlatformViewChannel::SendKeyEvent(Ecore_Event_Key* key, bool is_down) {
auto instances = ViewInstances();
auto it = instances.find(CurrentFocusedViewId());
if (it != instances.end()) {
if (is_down) {
it->second->dispatchKeyDownEvent(key);
it->second->DispatchKeyDownEvent(key);
} else {
it->second->dispatchKeyUpEvent(key);
it->second->DispatchKeyUpEvent(key);
}
}
}

int PlatformViewChannel::currentFocusedViewId() {
int PlatformViewChannel::CurrentFocusedViewId() {
for (auto it = view_instances_.begin(); it != view_instances_.end(); it++) {
if (it->second->isFocused()) {
return it->second->getViewId();
if (it->second->IsFocused()) {
return it->second->GetViewId();
}
}
return -1;
Expand All @@ -117,10 +117,10 @@ void PlatformViewChannel::HandleMethodCall(
const auto& arguments = *call.arguments();

if (method == "create") {
std::string viewType = extractStringFromMap(arguments, "viewType");
int viewId = extractIntFromMap(arguments, "id");
double width = extractDoubleFromMap(arguments, "width");
double height = extractDoubleFromMap(arguments, "height");
std::string viewType = ExtractStringFromMap(arguments, "viewType");
int viewId = ExtractIntFromMap(arguments, "id");
double width = ExtractDoubleFromMap(arguments, "width");
double height = ExtractDoubleFromMap(arguments, "height");

LoggerD(
"PlatformViewChannel create viewType: %s id: %d width: %f height: %f ",
Expand All @@ -134,14 +134,14 @@ void PlatformViewChannel::HandleMethodCall(
}
auto it = view_factories_.find(viewType);
if (it != view_factories_.end()) {
auto focuesdView = view_instances_.find(currentFocusedViewId());
auto focuesdView = view_instances_.find(CurrentFocusedViewId());
if (focuesdView != view_instances_.end()) {
focuesdView->second->setFocus(false);
focuesdView->second->SetFocus(false);
}

auto viewInstance =
it->second->create(viewId, width, height, byteMessage);
viewInstance->setFocus(true);
it->second->Create(viewId, width, height, byteMessage);
viewInstance->SetFocus(true);
view_instances_.insert(
std::pair<int, PlatformView*>(viewId, viewInstance));

Expand All @@ -150,30 +150,30 @@ void PlatformViewChannel::HandleMethodCall(
channel_->InvokeMethod("viewFocused", std::move(id));
}

result->Success(flutter::EncodableValue(viewInstance->getTextureId()));
result->Success(flutter::EncodableValue(viewInstance->GetTextureId()));
} else {
LoggerE("can't find view type = %s", viewType.c_str());
result->Error("0", "can't find view type");
}
} else {
int viewId = extractIntFromMap(arguments, "id");
int viewId = ExtractIntFromMap(arguments, "id");
auto it = view_instances_.find(viewId);
if (viewId >= 0 && it != view_instances_.end()) {
if (method == "dispose") {
LoggerD("PlatformViewChannel dispose");
it->second->dispose();
it->second->Dispose();
result->Success();
} else if (method == "resize") {
LoggerD("PlatformViewChannel resize");
double width = extractDoubleFromMap(arguments, "width");
double height = extractDoubleFromMap(arguments, "height");
it->second->resize(width, height);
double width = ExtractDoubleFromMap(arguments, "width");
double height = ExtractDoubleFromMap(arguments, "height");
it->second->Resize(width, height);
result->NotImplemented();
} else if (method == "touch") {
int type, button;
double x, y, dx, dy;

flutter::EncodableList event = extractListFromMap(arguments, "event");
flutter::EncodableList event = ExtractListFromMap(arguments, "event");
if (event.size() != 6) {
result->Error("Invalid Arguments");
return;
Expand All @@ -185,14 +185,14 @@ void PlatformViewChannel::HandleMethodCall(
dx = std::get<double>(event[4]);
dy = std::get<double>(event[5]);

it->second->touch(type, button, x, y, dx, dy);
it->second->Touch(type, button, x, y, dx, dy);
result->Success();
} else if (method == "setDirection") {
LoggerD("PlatformViewChannel setDirection");
result->NotImplemented();
} else if (method == "clearFocus") {
LoggerD("PlatformViewChannel clearFocus");
it->second->clearFocus();
it->second->ClearFocus();
result->NotImplemented();
} else {
LoggerD("Unimplemented method: %s", method.c_str());
Expand Down
8 changes: 4 additions & 4 deletions shell/platform/tizen/channels/platform_view_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ class PlatformViewChannel {
public:
explicit PlatformViewChannel(flutter::BinaryMessenger* messenger);
virtual ~PlatformViewChannel();
std::map<std::string, std::unique_ptr<PlatformViewFactory>>& viewFactories() {
std::map<std::string, std::unique_ptr<PlatformViewFactory>>& ViewFactories() {
return view_factories_;
}
std::map<int, PlatformView*>& viewInstances() { return view_instances_; }
std::map<int, PlatformView*>& ViewInstances() { return view_instances_; }

void sendKeyEvent(Ecore_Event_Key* key, bool is_down);
int currentFocusedViewId();
void SendKeyEvent(Ecore_Event_Key* key, bool is_down);
int CurrentFocusedViewId();

private:
std::unique_ptr<flutter::MethodChannel<flutter::EncodableValue>> channel_;
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/tizen/channels/text_input_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TextInputChannel {
void OnPredit(const char* str, int cursorPos);
void ShowSoftwareKeyboard();
void HideSoftwareKeyboard();
bool isSoftwareKeyboardShowing() { return isSoftwareKeyboardShowing_; }
bool IsSoftwareKeyboardShowing() { return isSoftwareKeyboardShowing_; }
SoftwareKeyboardGeometry GetCurrentKeyboardGeometry() {
return current_keyboard_geometry_;
}
Expand Down
7 changes: 4 additions & 3 deletions shell/platform/tizen/flutter_tizen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
#include "public/flutter_tizen.h"

#include <inttypes.h>

#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/plugin_registrar.h"
#include "flutter/shell/platform/common/cpp/incoming_message_dispatcher.h"
#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/standard_message_codec.h"
#include "flutter/shell/platform/common/cpp/incoming_message_dispatcher.h"
#include "flutter/shell/platform/tizen/logger.h"
#include "flutter/shell/platform/tizen/public/flutter_platform_view.h"
#include "flutter/shell/platform/tizen/public/flutter_texture_registrar.h"
#include "flutter/shell/platform/tizen/tizen_embedder_engine.h"
#include "flutter/shell/platform/tizen/public/flutter_platform_view.h"

// Opaque reference to a Tizen embedder engine.
struct FlutterWindowControllerState {
Expand Down Expand Up @@ -266,7 +267,7 @@ bool FlutterMarkExternalTextureFrameAvailable(
void FlutterRegisterViewFactory(
FlutterDesktopPluginRegistrarRef registrar, const char* view_type,
std::unique_ptr<PlatformViewFactory> view_factory) {
registrar->engine->platform_view_channel->viewFactories().insert(
registrar->engine->platform_view_channel->ViewFactories().insert(
std::pair<std::string, std::unique_ptr<PlatformViewFactory>>(
view_type, std::move(view_factory)));
}
4 changes: 2 additions & 2 deletions shell/platform/tizen/key_event_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ Eina_Bool KeyEventHandler::OnKey(void *data, int type, void *event) {
if (is_down) {
engine->text_input_channel->OnKeyDown(key);
}
if (engine->text_input_channel->isSoftwareKeyboardShowing()) {
if (engine->text_input_channel->IsSoftwareKeyboardShowing()) {
return ECORE_CALLBACK_PASS_ON;
}
}
if (engine->key_event_channel) {
engine->key_event_channel->SendKeyEvent(key, is_down);
}
if (engine->platform_view_channel) {
engine->platform_view_channel->sendKeyEvent(key, is_down);
engine->platform_view_channel->SendKeyEvent(key, is_down);
}
}
return ECORE_CALLBACK_PASS_ON;
Expand Down
34 changes: 17 additions & 17 deletions shell/platform/tizen/public/flutter_platform_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ class PlatformView {
textureId_(0),
isFocused_(false) {}
virtual ~PlatformView() {}
int getViewId() { return viewId_; }
int getTextureId() { return textureId_; }
void setTextureId(int textureId) { textureId_ = textureId; }
flutter::PluginRegistrar* getPluginRegistrar() { return registrar_; }
virtual void dispose() = 0;
virtual void resize(double width, double height) = 0;
virtual void touch(int type, int button, double x, double y, double dx,
int GetViewId() { return viewId_; }
int GetTextureId() { return textureId_; }
void SetTextureId(int textureId) { textureId_ = textureId; }
flutter::PluginRegistrar* GetPluginRegistrar() { return registrar_; }
virtual void Dispose() = 0;
virtual void Resize(double width, double height) = 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;
void setFocus(bool f) { isFocused_ = f; }
bool isFocused() { return isFocused_; }
virtual void SetDirection(int direction) = 0;
virtual void ClearFocus() = 0;
void SetFocus(bool f) { isFocused_ = f; }
bool IsFocused() { return isFocused_; }

// Key input event
virtual void dispatchKeyDownEvent(Ecore_Event_Key* key) = 0;
virtual void dispatchKeyUpEvent(Ecore_Event_Key* key) = 0;
virtual void DispatchKeyDownEvent(Ecore_Event_Key* key) = 0;
virtual void DispatchKeyUpEvent(Ecore_Event_Key* key) = 0;

private:
flutter::PluginRegistrar* registrar_;
Expand All @@ -51,13 +51,13 @@ class PlatformViewFactory {
: registrar_(registrar),
codec_(flutter::StandardMessageCodec::GetInstance(nullptr)) {}
virtual ~PlatformViewFactory() {}
flutter::PluginRegistrar* getPluginRegistrar() { return registrar_; }
const flutter::MessageCodec<flutter::EncodableValue>& getCodec() {
flutter::PluginRegistrar* GetPluginRegistrar() { return registrar_; }
const flutter::MessageCodec<flutter::EncodableValue>& GetCodec() {
return codec_;
}
virtual PlatformView* create(int viewId, double width, double height,
virtual PlatformView* Create(int viewId, double width, double height,
const ByteMessage& createParams) = 0;
virtual void dispose() = 0;
virtual void Dispose() = 0;

private:
flutter::PluginRegistrar* registrar_;
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/tizen/tizen_embedder_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ void TizenEmbedderEngine::SetWindowOrientation(int32_t degree) {
double width = geometry.w;
double height = geometry.h;

if (text_input_channel->isSoftwareKeyboardShowing()) {
if (text_input_channel->IsSoftwareKeyboardShowing()) {
height -= text_input_channel->GetCurrentKeyboardGeometry().h;
}

Expand Down

0 comments on commit 167ac22

Please sign in to comment.