flutter_desktop: menu bar, switch menu & shrink-stretch -> adaptive
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
027ffbb405
commit
59f0ffa82f
@ -315,29 +315,31 @@ abstract class MenuEntrySwitchBase<T> extends MenuEntryBase<T> {
|
||||
mod_menu.PopupMenuItem(
|
||||
padding: EdgeInsets.zero,
|
||||
height: conf.height,
|
||||
child: Obx(
|
||||
() => SwitchListTile(
|
||||
value: curOption.value,
|
||||
onChanged: (v) {
|
||||
setOption(v);
|
||||
},
|
||||
title: Container(
|
||||
child: TextButton(
|
||||
child: Container(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
constraints: BoxConstraints(minHeight: conf.height),
|
||||
child: Text(
|
||||
height: conf.height,
|
||||
child: Row(children: [
|
||||
// const SizedBox(width: MenuConfig.midPadding),
|
||||
Text(
|
||||
text,
|
||||
style: const TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: MenuConfig.fontSize,
|
||||
fontWeight: FontWeight.normal),
|
||||
),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Obx(() => Switch(
|
||||
value: curOption.value,
|
||||
onChanged: (v) => setOption(v),
|
||||
)),
|
||||
dense: true,
|
||||
visualDensity: const VisualDensity(
|
||||
horizontal: VisualDensity.minimumDensity,
|
||||
vertical: VisualDensity.minimumDensity,
|
||||
),
|
||||
contentPadding: const EdgeInsets.only(left: 8.0),
|
||||
),
|
||||
))
|
||||
])),
|
||||
onPressed: () {
|
||||
setOption(!curOption.value);
|
||||
},
|
||||
),
|
||||
)
|
||||
];
|
||||
|
@ -406,14 +406,13 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
|
||||
MenuEntryRadios<String>(
|
||||
text: translate('Ratio'),
|
||||
optionsGetter: () => [
|
||||
Tuple2<String, String>(translate('Original'), 'original'),
|
||||
Tuple2<String, String>(translate('Shrink'), 'shrink'),
|
||||
Tuple2<String, String>(translate('Stretch'), 'stretch'),
|
||||
Tuple2<String, String>(translate('Scale original'), 'original'),
|
||||
Tuple2<String, String>(translate('Scale adaptive'), 'adaptive'),
|
||||
],
|
||||
curOptionGetter: () async {
|
||||
return await bind.sessionGetOption(
|
||||
id: widget.id, arg: 'view-style') ??
|
||||
'';
|
||||
'adaptive';
|
||||
},
|
||||
optionSetter: (String v) async {
|
||||
await bind.sessionPeerOption(
|
||||
|
@ -497,39 +497,11 @@ class CanvasModel with ChangeNotifier {
|
||||
return;
|
||||
}
|
||||
|
||||
_scale = 1.0;
|
||||
if (style == 'adaptive') {
|
||||
final s1 = size.width / (parent.target?.ffiModel.display.width ?? 720);
|
||||
final s2 = size.height / (parent.target?.ffiModel.display.height ?? 1280);
|
||||
|
||||
// Closure to perform shrink operation.
|
||||
final shrinkOp = () {
|
||||
final s = s1 < s2 ? s1 : s2;
|
||||
if (s < 1) {
|
||||
_scale = s;
|
||||
}
|
||||
};
|
||||
// Closure to perform stretch operation.
|
||||
final stretchOp = () {
|
||||
final s = s1 < s2 ? s1 : s2;
|
||||
if (s > 1) {
|
||||
_scale = s;
|
||||
}
|
||||
};
|
||||
// Closure to perform default operation(set the scale to 1.0).
|
||||
final defaultOp = () {
|
||||
_scale = 1.0;
|
||||
};
|
||||
|
||||
// // On desktop, shrink is the default behavior.
|
||||
// if (isDesktop) {
|
||||
// shrinkOp();
|
||||
// } else {
|
||||
defaultOp();
|
||||
// }
|
||||
|
||||
if (style == 'shrink') {
|
||||
shrinkOp();
|
||||
} else if (style == 'stretch') {
|
||||
stretchOp();
|
||||
_scale = s1 < s2 ? s1 : s2;
|
||||
}
|
||||
|
||||
_x = (size.width - getDisplayWidth() * _scale) / 2;
|
||||
|
@ -30,7 +30,7 @@ class PlatformFFI {
|
||||
String _dir = '';
|
||||
String _homeDir = '';
|
||||
F2? _translate;
|
||||
var _eventHandlers = Map<String, Map<String, HandleEvent>>();
|
||||
final _eventHandlers = Map<String, Map<String, HandleEvent>>();
|
||||
late RustdeskImpl _ffiBind;
|
||||
late String _appType;
|
||||
void Function(Map<String, dynamic>)? _eventCallback;
|
||||
@ -50,27 +50,27 @@ class PlatformFFI {
|
||||
}
|
||||
|
||||
bool registerEventHandler(
|
||||
String event_name, String handler_name, HandleEvent handler) {
|
||||
debugPrint('registerEventHandler $event_name $handler_name');
|
||||
var handlers = _eventHandlers[event_name];
|
||||
String eventName, String handlerName, HandleEvent handler) {
|
||||
debugPrint('registerEventHandler $eventName $handlerName');
|
||||
var handlers = _eventHandlers[eventName];
|
||||
if (handlers == null) {
|
||||
_eventHandlers[event_name] = {handler_name: handler};
|
||||
_eventHandlers[eventName] = {handlerName: handler};
|
||||
return true;
|
||||
} else {
|
||||
if (handlers.containsKey(handler_name)) {
|
||||
if (handlers.containsKey(handlerName)) {
|
||||
return false;
|
||||
} else {
|
||||
handlers[handler_name] = handler;
|
||||
handlers[handlerName] = handler;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void unregisterEventHandler(String event_name, String handler_name) {
|
||||
debugPrint('unregisterEventHandler $event_name $handler_name');
|
||||
var handlers = _eventHandlers[event_name];
|
||||
void unregisterEventHandler(String eventName, String handlerName) {
|
||||
debugPrint('unregisterEventHandler $eventName $handlerName');
|
||||
var handlers = _eventHandlers[eventName];
|
||||
if (handlers != null) {
|
||||
handlers.remove(handler_name);
|
||||
handlers.remove(handlerName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -317,5 +317,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Relay Connection", "中继连接"),
|
||||
("Secure Connection", "安全连接"),
|
||||
("Insecure Connection", "非安全连接"),
|
||||
("Scale original", "原始尺寸"),
|
||||
("Scale adaptive", "适应窗口"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -317,5 +317,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Relay Connection", "Připojení relé"),
|
||||
("Secure Connection", "Zabezpečené připojení"),
|
||||
("Insecure Connection", "Nezabezpečené připojení"),
|
||||
("Scale original", "Měřítko původní"),
|
||||
("Scale adaptive", "Měřítko adaptivní"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -317,5 +317,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Relay Connection", "Relæforbindelse"),
|
||||
("Secure Connection", "Sikker forbindelse"),
|
||||
("Insecure Connection", "Usikker forbindelse"),
|
||||
("Scale original", "Skala original"),
|
||||
("Scale adaptive", "Skala adaptiv"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -317,5 +317,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Relay Connection", "Relaisverbindung"),
|
||||
("Secure Connection", "Sichere Verbindung"),
|
||||
("Insecure Connection", "Unsichere Verbindung"),
|
||||
("Scale original", "Original skalieren"),
|
||||
("Scale adaptive", "Adaptiv skalieren"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -317,5 +317,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Relay Connection", "Relajsa Konekto"),
|
||||
("Secure Connection", "Sekura Konekto"),
|
||||
("Insecure Connection", "Nesekura Konekto"),
|
||||
("Scale original", "Skalo originalo"),
|
||||
("Scale adaptive", "Skalo adapta"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -317,5 +317,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Relay Connection", "Conexión de relé"),
|
||||
("Secure Connection", "Conexión segura"),
|
||||
("Insecure Connection", "Conexión insegura"),
|
||||
("Scale original", "escala originales"),
|
||||
("Scale adaptive", "Adaptable a escala"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -317,5 +317,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Relay Connection", "Connexion relais"),
|
||||
("Secure Connection", "Connexion sécurisée"),
|
||||
("Insecure Connection", "Connexion non sécurisée"),
|
||||
("Scale original", "Échelle d'origine"),
|
||||
("Scale adaptive", "Échelle adaptative"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -317,5 +317,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Relay Connection", "Relé csatlakozás"),
|
||||
("Secure Connection", "Biztonságos kapcsolat"),
|
||||
("Insecure Connection", "Nem biztonságos kapcsolat"),
|
||||
("Scale original", "Eredeti méretarány"),
|
||||
("Scale adaptive", "Skála adaptív"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -317,5 +317,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Relay Connection", "Koneksi Relay"),
|
||||
("Secure Connection", "Koneksi aman"),
|
||||
("Insecure Connection", "Koneksi Tidak Aman"),
|
||||
("Scale original", "Skala asli"),
|
||||
("Scale adaptive", "Skala adaptif"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -316,5 +316,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Relay Connection", "Collegamento a relè"),
|
||||
("Secure Connection", "Connessione sicura"),
|
||||
("Insecure Connection", "Connessione insicura"),
|
||||
("Scale original", "Scala originale"),
|
||||
("Scale adaptive", "Scala adattiva"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -314,5 +314,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Relay Connection", "リレー接続"),
|
||||
("Secure Connection", "安全な接続"),
|
||||
("Insecure Connection", "安全でない接続"),
|
||||
("Scale original", "オリジナルサイズ"),
|
||||
("Scale adaptive", "フィットウィンドウ"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -314,5 +314,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Relay Connection", "릴레이 연결"),
|
||||
("Secure Connection", "보안 연결"),
|
||||
("Insecure Connection", "안전하지 않은 연결"),
|
||||
("Scale original", "원래 크기"),
|
||||
("Scale adaptive", "맞는 창"),
|
||||
].iter().cloned().collect();
|
||||
}
|
@ -318,5 +318,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Relay Connection", "Połączenie przekaźnika"),
|
||||
("Secure Connection", "Bezpieczne połączenie"),
|
||||
("Insecure Connection", "Niepewne połączenie"),
|
||||
("Scale original", "Skala oryginalna"),
|
||||
("Scale adaptive", "Skala adaptacyjna"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -314,5 +314,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Relay Connection", "Conexão de relé"),
|
||||
("Secure Connection", "Conexão segura"),
|
||||
("Insecure Connection", "Conexão insegura"),
|
||||
("Scale original", "Escala original"),
|
||||
("Scale adaptive", "Escala adaptável"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -317,5 +317,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Relay Connection", ""),
|
||||
("Secure Connection", ""),
|
||||
("Insecure Connection", ""),
|
||||
("Scale original", ""),
|
||||
("Scale adaptive", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -317,5 +317,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Relay Connection", "Релейное соединение"),
|
||||
("Secure Connection", "Безопасное соединение"),
|
||||
("Insecure Connection", "Небезопасное соединение"),
|
||||
("Scale original", "Оригинал масштаба"),
|
||||
("Scale adaptive", "Масштаб адаптивный"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -317,5 +317,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Relay Connection", "Reléové pripojenie"),
|
||||
("Secure Connection", "Zabezpečené pripojenie"),
|
||||
("Insecure Connection", "Nezabezpečené pripojenie"),
|
||||
("Scale original", "Pôvodná mierka"),
|
||||
("Scale adaptive", "Prispôsobivá mierka"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -317,5 +317,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Relay Connection", ""),
|
||||
("Secure Connection", ""),
|
||||
("Insecure Connection", ""),
|
||||
("Scale original", ""),
|
||||
("Scale adaptive", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -317,5 +317,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Relay Connection", "Röle Bağlantısı"),
|
||||
("Secure Connection", "Güvenli bağlantı"),
|
||||
("Insecure Connection", "Güvenli Bağlantı"),
|
||||
("Scale original", "Orijinali ölçeklendir"),
|
||||
("Scale adaptive", "Ölçek uyarlanabilir"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -317,5 +317,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Relay Connection", "中繼連接"),
|
||||
("Secure Connection", "安全連接"),
|
||||
("Insecure Connection", "非安全連接"),
|
||||
("Scale original", "原始尺寸"),
|
||||
("Scale adaptive", "適應窗口"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -317,5 +317,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Relay Connection", "Kết nối chuyển tiếp"),
|
||||
("Secure Connection", "Kết nối an toàn"),
|
||||
("Insecure Connection", "Kết nối không an toàn"),
|
||||
("Scale original", "Quy mô gốc"),
|
||||
("Scale adaptive", "Quy mô thích ứng"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user