Merge the latest cpp template from flutter-embedded-linux repo (#131)
Signed-off-by: Hidenori Matsubayashi <[email protected]>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Sony Corporation. All rights reserved.
|
// Copyright 2022 Sony Corporation. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
@@ -13,8 +13,6 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
// todo: Supports other types besides int, string.
|
|
||||||
|
|
||||||
namespace commandline {
|
namespace commandline {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -56,6 +54,15 @@ class CommandOptions {
|
|||||||
ReaderInt(), required, true);
|
ReaderInt(), required, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddDouble(const std::string& name,
|
||||||
|
const std::string& short_name,
|
||||||
|
const std::string& description,
|
||||||
|
const double& default_value,
|
||||||
|
bool required) {
|
||||||
|
Add<double, ReaderDouble>(name, short_name, description, default_value,
|
||||||
|
ReaderDouble(), required, true);
|
||||||
|
}
|
||||||
|
|
||||||
void AddString(const std::string& name,
|
void AddString(const std::string& name,
|
||||||
const std::string& short_name,
|
const std::string& short_name,
|
||||||
const std::string& description,
|
const std::string& description,
|
||||||
@@ -250,6 +257,10 @@ class CommandOptions {
|
|||||||
std::string operator()(const std::string& value) { return value; }
|
std::string operator()(const std::string& value) { return value; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ReaderDouble {
|
||||||
|
double operator()(const std::string& value) { return std::stod(value); }
|
||||||
|
};
|
||||||
|
|
||||||
class Option {
|
class Option {
|
||||||
public:
|
public:
|
||||||
Option(const std::string& name,
|
Option(const std::string& name,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Sony Corporation. All rights reserved.
|
// Copyright 2022 Sony Corporation. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
@@ -21,6 +21,9 @@ class FlutterEmbedderOptions {
|
|||||||
options_.AddInt("rotation", "r",
|
options_.AddInt("rotation", "r",
|
||||||
"Window rotation(degree) [0(default)|90|180|270]", 0,
|
"Window rotation(degree) [0(default)|90|180|270]", 0,
|
||||||
false);
|
false);
|
||||||
|
options_.AddDouble("force-scale-factor", "s",
|
||||||
|
"Force a scale factor instead using default value", 1.0,
|
||||||
|
false);
|
||||||
#if defined(FLUTTER_TARGET_BACKEND_GBM) || \
|
#if defined(FLUTTER_TARGET_BACKEND_GBM) || \
|
||||||
defined(FLUTTER_TARGET_BACKEND_EGLSTREAM)
|
defined(FLUTTER_TARGET_BACKEND_EGLSTREAM)
|
||||||
// no more options.
|
// no more options.
|
||||||
@@ -72,6 +75,14 @@ class FlutterEmbedderOptions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options_.Exist("force-scale-factor")) {
|
||||||
|
is_force_scale_factor_ = true;
|
||||||
|
scale_factor_ = options_.GetValue<double>("force-scale-factor");
|
||||||
|
} else {
|
||||||
|
is_force_scale_factor_ = false;
|
||||||
|
scale_factor_ = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(FLUTTER_TARGET_BACKEND_GBM) || \
|
#if defined(FLUTTER_TARGET_BACKEND_GBM) || \
|
||||||
defined(FLUTTER_TARGET_BACKEND_EGLSTREAM)
|
defined(FLUTTER_TARGET_BACKEND_EGLSTREAM)
|
||||||
use_onscreen_keyboard_ = false;
|
use_onscreen_keyboard_ = false;
|
||||||
@@ -112,6 +123,8 @@ class FlutterEmbedderOptions {
|
|||||||
flutter::FlutterViewController::ViewRotation WindowRotation() const {
|
flutter::FlutterViewController::ViewRotation WindowRotation() const {
|
||||||
return window_view_rotation_;
|
return window_view_rotation_;
|
||||||
}
|
}
|
||||||
|
bool IsForceScaleFactor() const { return is_force_scale_factor_; }
|
||||||
|
double ScaleFactor() const { return scale_factor_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
commandline::CommandOptions options_;
|
commandline::CommandOptions options_;
|
||||||
@@ -126,6 +139,8 @@ class FlutterEmbedderOptions {
|
|||||||
int window_height_ = 720;
|
int window_height_ = 720;
|
||||||
flutter::FlutterViewController::ViewRotation window_view_rotation_ =
|
flutter::FlutterViewController::ViewRotation window_view_rotation_ =
|
||||||
flutter::FlutterViewController::ViewRotation::kRotation_0;
|
flutter::FlutterViewController::ViewRotation::kRotation_0;
|
||||||
|
bool is_force_scale_factor_;
|
||||||
|
double scale_factor_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FLUTTER_EMBEDDER_OPTIONS_
|
#endif // FLUTTER_EMBEDDER_OPTIONS_
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Sony Corporation. All rights reserved.
|
// Copyright 2022 Sony Corporation. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
@@ -33,6 +33,8 @@ int main(int argc, char** argv) {
|
|||||||
view_properties.use_mouse_cursor = options.IsUseMouseCursor();
|
view_properties.use_mouse_cursor = options.IsUseMouseCursor();
|
||||||
view_properties.use_onscreen_keyboard = options.IsUseOnscreenKeyboard();
|
view_properties.use_onscreen_keyboard = options.IsUseOnscreenKeyboard();
|
||||||
view_properties.use_window_decoration = options.IsUseWindowDecoraation();
|
view_properties.use_window_decoration = options.IsUseWindowDecoraation();
|
||||||
|
view_properties.force_scale_factor = options.IsForceScaleFactor();
|
||||||
|
view_properties.scale_factor = options.ScaleFactor();
|
||||||
|
|
||||||
// The Flutter instance hosted by this window.
|
// The Flutter instance hosted by this window.
|
||||||
FlutterWindow window(view_properties, project);
|
FlutterWindow window(view_properties, project);
|
||||||
|
|||||||
Reference in New Issue
Block a user