using Tizen.NUI;
+using Tizen.NUI.WindowSystem.Shell;
namespace TaskBar.Common
{
private int width;
private int height;
private Window.WindowOrientation orientation;
+ private Window.WindowOrientation naturalDeviceOrientation;
private static readonly DeviceInfo instance = new DeviceInfo();
height = Window.Instance.Size.Height;
IsPortrait = width < height;
orientation = Window.Instance.GetCurrentOrientation();
+ naturalDeviceOrientation = Window.Instance.GetCurrentOrientation();
+ TaskbarPosition = TaskbarService.PlaceType.Bottom;
if (orientation == Window.WindowOrientation.Portrait || orientation == Window.WindowOrientation.PortraitInverse)
{
if (IsPortrait == false)
public void UpdateDeviceInfo()
{
Window.WindowOrientation currentOrientation = Window.Instance.GetCurrentOrientation();
+ Tizen.Log.Info(Resources.LogTag, "new Orientation: " + currentOrientation);
+ UpdateTaskbarPosition(currentOrientation);
if (orientation == Window.WindowOrientation.Portrait || orientation == Window.WindowOrientation.PortraitInverse)
{
if (currentOrientation == Window.WindowOrientation.Landscape || currentOrientation == Window.WindowOrientation.LandscapeInverse)
orientation = currentOrientation;
}
+ public void SetFullInputRegion()
+ {
+ Window.Instance.SetInputRegion(new Rectangle(0, 0, width, height));
+ }
+
+ public void SetTaskbarInputRegion()
+ {
+ int sizeWidth = width;
+ int sizeHeight = Resources.TaskbarHeight.SpToPx();
+ int positionX = 0;
+ int positionY = height - sizeHeight;
+ Window.Instance.SetInputRegion(new Rectangle(positionX, positionY, sizeWidth, sizeHeight));
+ }
+
+ private void UpdateTaskbarPosition(Window.WindowOrientation newOrientation)
+ {
+ int difference = (newOrientation - naturalDeviceOrientation) / 90;
+ difference = difference >= 0 ? difference : 4 + difference;
+ TaskbarPosition = difference switch
+ {
+ 1 => TaskbarService.PlaceType.Left,
+ 2 => TaskbarService.PlaceType.Top,
+ 3 => TaskbarService.PlaceType.Right,
+ _ => TaskbarService.PlaceType.Bottom,
+ };
+ Tizen.Log.Info(Resources.LogTag, "new Position: " + TaskbarPosition);
+ }
+
private void ToggleOrientation()
{
(width, height) = (height, width);
public int DisplayWidth { get => width; }
public int DisplayHeight { get => height; }
+
+ public TaskbarService.PlaceType TaskbarPosition { get; private set; }
}
}
public static readonly Color LightMenuBackground = new Color(0.98f, 0.98f, 0.98f, 0.5f);
public static readonly Color DarkMenuBackground = new Color(0.0863f, 0.0745f, 0.1020f, 0.5f);
+ public const int TaskbarHeight = 64;
public const int MenuItemWidth = 220;
public const int MenuItemHeight = 44;
public static readonly Vector4 SingleItemCornerRadius = new Vector4(8, 8, 8, 8);
public static readonly Vector4 TopItemCornerRadius = new Vector4(8, 8, 0, 0);
public static readonly Vector4 BottomItemCornerRadius = new Vector4(0, 0, 8, 8);
- private static Window moreMenuWindow;
public static string GetImagePath()
{
{
return (ThemeManager.PlatformThemeId == LightPlatformThemeId) ? GetLightImagePath() : GetDarkImagePath();
}
-
- public static Window MoreMenuWindow
- {
- get
- {
- if (moreMenuWindow == null)
- {
- Tizen.Log.Info(LogTag, "Create menu window");
- moreMenuWindow = new Window();
- moreMenuWindow.SetTransparency(true);
- moreMenuWindow.BackgroundColor = Color.Transparent;
- List<Window.WindowOrientation> list = new List<Window.WindowOrientation>
- {
- Window.WindowOrientation.Landscape,
- Window.WindowOrientation.LandscapeInverse,
- Window.WindowOrientation.NoOrientationPreference,
- Window.WindowOrientation.Portrait,
- Window.WindowOrientation.PortraitInverse
- };
- moreMenuWindow.SetAvailableOrientations(list);
- }
- return moreMenuWindow;
- }
- }
-
- public static void DisposeMoreMenuWindow()
- {
- moreMenuWindow?.Dispose();
- }
}
}
\ No newline at end of file
{
}
- private const int WindowHeight = 64;
- private bool isTaskBarVisible = true;
-
- private TaskbarService.PlaceType taskBarPosition;
-
private static Window window;
private MainView mainView;
private TizenShell tizenShell;
Window.WindowOrientation.PortraitInverse
};
window.SetAvailableOrientations(list);
-
- UpdateWindowDimensions();
window.SetTransparency(true);
window.BackgroundColor = Color.Transparent;
tizenShell = new TizenShell();
- taskBarPosition = TaskbarService.PlaceType.Bottom;
- taskbarService = new TaskbarService(tizenShell, window, taskBarPosition);
- taskbarService.SetSize((uint)window.Size.Width, (uint)window.Size.Height);
+ taskbarService = new TaskbarService(tizenShell, window);
+ taskbarService.SetSize((uint)DeviceInfo.Instance.DisplayWidth, (uint)Resources.TaskbarHeight.SpToPx());
+ DeviceInfo.Instance.SetTaskbarInputRegion();
PinnedAppsDataBase.Instance.InitializeDataBase();
window.OrientationChanged += OnOrientationChanged;
}
- private void UpdateWindowDimensions()
- {
- int sizeWidth = DeviceInfo.Instance.DisplayWidth;
- int sizeHeight = WindowHeight.SpToPx();
- int positionX = 0;
- int positionY = DeviceInfo.Instance.DisplayHeight - sizeHeight;
- window.WindowPosition = new Position2D(positionX, positionY);
- window.WindowSize = new Size2D(sizeWidth, sizeHeight);
- }
-
private void OnOrientationChanged(object sender, WindowOrientationChangedEventArgs e)
{
DeviceInfo.Instance.UpdateDeviceInfo();
- UpdateWindowDimensions();
+ DeviceInfo.Instance.SetTaskbarInputRegion();
+ //taskbarService.SetPlaceType(DeviceInfo.Instance.TaskbarPosition);
mainView.UpdateView();
}
window?.Remove(mainView);
mainView?.Dispose();
mainView = null;
- Resources.DisposeMoreMenuWindow();
taskbarService?.Dispose();
tizenShell?.Dispose();
private void OnLongPressGestureDetected(object source, LongPressGestureDetector.DetectedEventArgs e)
{
- Tizen.Log.Info(Resources.LogTag, "LongPress Detected");
+ Tizen.Log.Info(Resources.LogTag, "LongPress Detected" + e.LongPressGesture.State);
if (e.LongPressGesture.State == Gesture.StateType.Started)
{
if (menuItemNames != null && menuItemNames.Count > 0)
{
AddMoreMenu();
UpdateMenuItems();
- Resources.MoreMenuWindow.SetParent(Window.Instance);
- Resources.MoreMenuWindow.Show();
- Resources.MoreMenuWindow.Raise();
- moreMenu.SetScrimAttributes(Resources.MoreMenuWindow);
- moreMenu.Post(Resources.MoreMenuWindow);
+ moreMenu.SetScrimAttributes();
+ moreMenu.Post();
+ //Input region is set to Full screen when more menu is added.
+ DeviceInfo.Instance.SetFullInputRegion();
+ AppIcon.IsEnabled = false;
}
}
+ else
+ {
+ AppIcon.IsEnabled = true;
+ }
}
private void AddButton()
moreMenuWidth = Resources.MenuItemWidth.SpToPx();
moreMenuHeight = (menuItemNames.Count * Resources.MenuItemHeight).SpToPx();
moreMenuPositionX = (int)ScreenPosition.X;
- moreMenuPositionY = DeviceInfo.Instance.DisplayHeight - Window.Instance.WindowSize.Height - moreMenuHeight;
+ moreMenuPositionY = DeviceInfo.Instance.DisplayHeight - Resources.TaskbarHeight.SpToPx() - moreMenuHeight;
if (moreMenu == null)
{
Tizen.Log.Info(Resources.LogTag, "Custom Menu");
moreMenu.Position2D = new Position2D(moreMenuPositionX, moreMenuPositionY);
moreMenu.VisibilityChanged += (object sender, VisibilityChangedEventArgs e) =>
{
- // when more menu is dismissed, its visibilty state changes to false, and window hide is handled here.
+ // when more menu is dismissed, its visibilty state changes to false, and input region is updated again.
if (e.Visibility == false)
{
+ DeviceInfo.Instance.SetTaskbarInputRegion();
DisposeMenuItems();
- Resources.MoreMenuWindow.Unparent();
- Resources.MoreMenuWindow.Hide();
}
};
}
private void OnItemClicked(object sender, ClickedEventArgs e)
{
MenuItem item = sender as MenuItem;
- MenuItemSelectCommand.Execute(item.Text);
+ string itemText = item.Text;
DisposeMenuItems();
DisposeMoreMenu();
+ MenuItemSelectCommand.Execute(itemText);
}
private void DisposeMenuItems()
{
moreMenu.Dismiss();
moreMenu = null;
-
- Resources.MoreMenuWindow.Unparent();
- Resources.MoreMenuWindow.Hide();
}
}
Tizen.Log.Info(Resources.LogTag, "Custom Menu with MenuStyle");
}
- public void SetScrimAttributes(Window win)
+ public void SetScrimAttributes()
{
- if (win != null)
- {
- Scrim.Size2D = win.Size;
- Scrim.Position2D = win.WindowPosition;
- Scrim.BackgroundColor = new Color(0, 0, 0, 0.3f);
- }
+ Scrim.BackgroundColor = new Color(0, 0, 0, 0.3f);
+ Scrim.AllowOnlyOwnTouch = true;
}
}
}
public MainView() : base()
{
- Size2D = Window.Instance.Size;
+ WidthSpecification = DeviceInfo.Instance.DisplayWidth;
+ HeightSpecification = Resources.TaskbarHeight.SpToPx();
+ Position2D = new Position2D(0, DeviceInfo.Instance.DisplayHeight - Resources.TaskbarHeight.SpToPx());
CornerRadius = new Vector4(24, 24, 0, 0);
Layout = new LinearLayout()
{
public void UpdateView()
{
- Size2D = Window.Instance.Size;
+ WidthSpecification = DeviceInfo.Instance.DisplayWidth;
+ HeightSpecification = Resources.TaskbarHeight.SpToPx();
+ Position2D = new Position2D(0, DeviceInfo.Instance.DisplayHeight - Resources.TaskbarHeight.SpToPx());
DisposeMoreMenu();
quickAccessView.UpdateView();
applicationsView.UpdateView();
if (e.LongPressGesture.State == Gesture.StateType.Started)
{
CreateMoreMenu();
- Resources.MoreMenuWindow.SetParent(Window.Instance);
- Resources.MoreMenuWindow.Show();
- Resources.MoreMenuWindow.Raise();
- addButtonMoreMenu.SetScrimAttributes(Resources.MoreMenuWindow);
- addButtonMoreMenu.Post(Resources.MoreMenuWindow);
+ addButtonMoreMenu.SetScrimAttributes();
+ addButtonMoreMenu.Post();
+ //Input region is set to Full screen when more menu is added.
+ DeviceInfo.Instance.SetFullInputRegion();
+ addPinnedAppsButton.IsEnabled = false;
+ }
+ else if (e.LongPressGesture.State == Gesture.StateType.Finished)
+ {
+ addPinnedAppsButton.IsEnabled = true;
}
}
moreMenuWidth = Resources.MenuItemWidth.SpToPx();
moreMenuHeight = Resources.MenuItemHeight.SpToPx();
moreMenuPositionX = (int)addPinnedAppsButton.ScreenPosition.X;
- moreMenuPositionY = DeviceInfo.Instance.DisplayHeight - Window.Instance.WindowSize.Height - moreMenuHeight;
+ moreMenuPositionY = DeviceInfo.Instance.DisplayHeight - Resources.TaskbarHeight.SpToPx() - moreMenuHeight;
if (addButtonMoreMenu == null)
{
Tizen.Log.Info(Resources.LogTag, "Custom Menu");
addButtonMoreMenu.Position2D = new Position2D(moreMenuPositionX, moreMenuPositionY);
addButtonMoreMenu.VisibilityChanged += (object sender, VisibilityChangedEventArgs e) =>
{
- // when more menu is dismissed, its visibilty state changes to false, and window hide is handled here.
+ // when more menu is dismissed, its visibilty state changes to false, and input region is updated again.
if (e.Visibility == false)
{
- Resources.MoreMenuWindow.Unparent();
- Resources.MoreMenuWindow.Hide();
+ DeviceInfo.Instance.SetTaskbarInputRegion();
}
};
MenuItem item = new MenuItem("MenuItems")
}
addButtonMoreMenu.Dismiss();
addButtonMoreMenu = null;
-
- Resources.MoreMenuWindow.Unparent();
- Resources.MoreMenuWindow.Hide();
}
}
public UninstallConfirmationView()
{
Tizen.Log.Info(Resources.LogTag, "Popup Added");
- confirmationPopupWindow = new Window();
- List<Window.WindowOrientation> list = new List<Window.WindowOrientation>
- {
- Window.WindowOrientation.Landscape,
- Window.WindowOrientation.LandscapeInverse,
- Window.WindowOrientation.NoOrientationPreference,
- Window.WindowOrientation.Portrait,
- Window.WindowOrientation.PortraitInverse
- };
- confirmationPopupWindow.SetAvailableOrientations(list);
-
- confirmationPopupWindow.SetTransparency(true);
- confirmationPopupWindow.BackgroundColor = Color.Transparent;
baseView = new View()
{
BackgroundColor = new Color(0, 0, 0, 0.3f),
};
- confirmationPopupWindow.Add(baseView);
+ Window.Instance.Add(baseView);
Button cancelButton = new Button("CancelButton");
Button deleteButton = new Button()
Text = "Delete",
};
deleteButton.PointSize = 16.SpToPx();
+
confirmationPopup = new AlertDialog()
{
StyleName = "AlertDialogBackground",
Actions = new List<Button>() { cancelButton, deleteButton },
};
baseView.Add(confirmationPopup);
- UpdateConfirmationPopupWindowDimensions();
- confirmationPopupWindow.SetParent(Window.Instance);
- confirmationPopupWindow.Raise();
- confirmationPopupWindow.OrientationChanged += (object sender, WindowOrientationChangedEventArgs e) =>
- {
- UpdateConfirmationPopupWindowDimensions();
- };
+ UpdatePopup();
+
+ baseView.TouchEvent += OnBaseViewTouched;
+ Window.Instance.OrientationChanged += OnOrientationChanged;
cancelButton.Clicked += (object sender, ClickedEventArgs e) =>
{
};
}
- private void UpdateConfirmationPopupWindowDimensions()
+ private bool OnBaseViewTouched(object source, View.TouchEventArgs e)
{
- baseView.WidthSpecification = confirmationPopupWindow.Size.Width;
- baseView.HeightSpecification = confirmationPopupWindow.Size.Height - Window.Instance.Size.Height;
- baseView.Remove(confirmationPopup);
- baseView.Add(confirmationPopup);
+ RemoveConfirmationPopup();
+ return true;
+ }
+
+ private void OnOrientationChanged(object sender, WindowOrientationChangedEventArgs e)
+ {
+ UpdatePopup();
+ }
+
+ private void UpdatePopup()
+ {
+ if (baseView != null)
+ {
+ baseView.Size2D = Window.Instance.Size;
+ baseView.Remove(confirmationPopup);
+ baseView.Add(confirmationPopup);
+ DeviceInfo.Instance.SetFullInputRegion();
+ }
}
private void RemoveConfirmationPopup()
{
if (confirmationPopup != null)
{
- confirmationPopupWindow?.Remove(baseView);
+ Window.Instance.Remove(baseView);
baseView?.Remove(confirmationPopup);
confirmationPopup.Dispose();
confirmationPopup = null;
baseView?.Dispose();
baseView = null;
- confirmationPopupWindow?.Dispose();
- confirmationPopupWindow = null;
+
+ Window.Instance.OrientationChanged -= OnOrientationChanged;
+ DeviceInfo.Instance.SetTaskbarInputRegion();
}
}
- private Window confirmationPopupWindow;
private View baseView;
private AlertDialog confirmationPopup;
}