private static bool IsLightTheme => ThemeManager.PlatformThemeId == LightPlatformThemeId;
public static Color TaskbarBackgroundColor => IsLightTheme ? new Color("rgba(255, 254, 254, 0.3)") : new Color("rgba(22, 19, 26, 0.3)");
+ public static Color DisabledTaskbarBackgroundColor => IsLightTheme ? new Color("rgba(255, 254, 254, 0.15)") : new Color("rgba(22, 19, 26, 0.15)");
public static Color MenuBackgroundColor => IsLightTheme ? new Color("rgba(250, 250, 250, 0.5)") : new Color("rgba(22, 19, 26, 0.5)");
public static Color PopupBackgroundColor => IsLightTheme ? new Color("#FAFAFA") : new Color("#16131A");
public static Color TaskbarTextColor => IsLightTheme ? new Color("#090E21") : new Color("#FDFDFD");
public static Color FillButtonTextColor => IsLightTheme ? new Color("#16131A") : new Color("#FDFDFD");
public static Color FillButtonColor => IsLightTheme ? new Color("#FF6200") : new Color("#FF8A00");
- public static Color DisabledButtonTextColor => IsLightTheme ? new Color("#CACACA") : new Color("#666666");
- public static Color NormalButtonTextColor => IsLightTheme ? new Color("#FF6200") : new Color("#FF8A00");
- public static Color PressedButtonTextColor => IsLightTheme ? new Color("#FFA166") : new Color("#CC6E00");
public static Color NormalMenuItemTextColor => IsLightTheme ? new Color("#090E21") : new Color("#FDFDFD");
- public static Color PressedMenuItemTextColor => new Color("#1473E6");
+ public static Color PressedMenuItemTextColor => new Color("#FF6200");
public static Color UninstallMenuItemTextColor => new Color("#A40404");
public static Color DisabledMenuItemTextColor => IsLightTheme ? new Color("#CACACA") : new Color("#666666");
public const int SingleItemCornerRadius = 8;
public const int ButtonBorderlineWidth = 2;
+ public static Size2D MinimumMenuSize = new Size2D(220, 44);
public static Size2D PopupButtonSize = new Size2D(252, 48);
public static Size2D IndicatorSize = new Size2D(20, 4);
- public static Size2D MenuItemSize = new Size2D(220, 44);
-
- public static readonly Vector4 TopItemCornerRadius = new Vector4(8, 8, 0, 0);
- public static readonly Vector4 BottomItemCornerRadius = new Vector4(0, 0, 8, 8);
public static string GetImagePath()
{
using System;
using System.Collections.Generic;
using System.Windows.Input;
-using Tizen.NUI;
using Tizen.NUI.Binding;
using TaskBar.Common;
using TaskBar.Core;
{
class AppInfoModel : PropertyNotifier
{
- private ImageVisual defaultVisual;
- private GradientVisual gradientVisual;
-
public event Action PinAppClicked;
public event Action UnpinAppClicked;
public event Action UninstallAppClicked;
set => SetProperty(ref isRunning, value);
}
- private PropertyMap iconBackground;
- public PropertyMap IconBackground
- {
- get => iconBackground;
- set => SetProperty(ref iconBackground, value);
- }
-
private ICommand appSelectCommand;
public ICommand AppSelectCommand
{
}
}
- private void SetDefaultImageVisual()
- {
- defaultVisual = new ImageVisual()
- {
- URL = Resources.GetImagePath() + "default_gradient.png",
- CornerRadius = new Vector4(12, 12, 12, 12),
- };
- }
-
- private void SetGradientVisual(PropertyArray stopColor)
- {
- gradientVisual = new GradientVisual()
- {
- StartPosition = new Vector2(0.0f, -1.0f),
- EndPosition = new Vector2(0.0f, 1.0f),
- StopColor = stopColor,
- SpreadMethod = GradientVisualSpreadMethodType.Pad,
- CornerRadius = new Vector4(12, 12, 12, 12),
- };
- }
-
- private PropertyArray GetGradientStopColors(Palette palette)
- {
- PropertyArray propertyArray = new PropertyArray();
- if (palette == null)
- {
- Tizen.Log.Error(Resources.LogTag, "Color palette from background is null");
- return propertyArray;
- }
-
- Palette.Swatch lightMutedSwatch = palette.GetLightMutedSwatch();
- Palette.Swatch darkMutedSwatch = palette.GetDarkMutedSwatch();
- if (lightMutedSwatch != null && darkMutedSwatch != null)
- {
- propertyArray.PushBack(new PropertyValue(lightMutedSwatch.GetRgb()));
- propertyArray.PushBack(new PropertyValue(darkMutedSwatch.GetRgb()));
- return propertyArray;
- }
-
- Palette.Swatch lightVibrantSwatch = palette.GetLightVibrantSwatch();
- Palette.Swatch darkVibrantSwatch = palette.GetDarkVibrantSwatch();
- if (lightVibrantSwatch != null && darkVibrantSwatch != null)
- {
- propertyArray.PushBack(new PropertyValue(lightVibrantSwatch.GetRgb()));
- propertyArray.PushBack(new PropertyValue(darkVibrantSwatch.GetRgb()));
- return propertyArray;
- }
-
- Palette.Swatch mutedSwatch = palette.GetMutedSwatch();
- Palette.Swatch vibrantSwatch = palette.GetVibrantSwatch();
- if (mutedSwatch != null && vibrantSwatch != null)
- {
- propertyArray.PushBack(new PropertyValue(mutedSwatch.GetRgb()));
- propertyArray.PushBack(new PropertyValue(vibrantSwatch.GetRgb()));
- return propertyArray;
- }
-
- IReadOnlyCollection<Palette.Swatch> swatches = palette.GetSwatches();
- foreach (Palette.Swatch swatch in swatches)
- {
- if (propertyArray.Count() >= 2)
- {
- return propertyArray;
- }
- if (swatch != null)
- {
- propertyArray.PushBack(new PropertyValue(swatch.GetRgb()));
- }
- }
- return propertyArray;
- }
-
- public void SetExtractedBackground(string path)
- {
- Tizen.Log.Debug(Resources.LogTag, "Path for the color image thumbnail" + path);
- PixelBuffer pixelBuffer = ImageLoader.LoadImageFromFile(path);
- Palette palette = null;
- try
- {
- palette = Palette.Generate(pixelBuffer);
- }
- catch (ArgumentNullException e)
- {
- Tizen.Log.Error(Resources.LogTag, "ArgumentNullException: " + e.Message);
- }
- PropertyArray stopColor = GetGradientStopColors(palette);
- if (stopColor.Count() < 2)
- {
- Tizen.Log.Info(Resources.LogTag, "Palette or palatte values not valid, adding default gradient");
- SetDefaultImageVisual();
- IconBackground = defaultVisual.OutputVisualMap;
- }
- else
- {
- Tizen.Log.Info(Resources.LogTag, "setting palette color");
- SetGradientVisual(stopColor);
- IconBackground = gradientVisual.OutputVisualMap;
- }
- }
-
public void CreateUserApplicationsMoreMenu()
{
List<string> menuItems = new List<string>
~AppInfoModel()
{
- Tizen.Log.Info(Resources.LogTag, "Clearing NUI PropertyMap resources");
- defaultVisual?.Dispose();
- defaultVisual = null;
- gradientVisual?.Dispose();
- gradientVisual = null;
- IconBackground?.Dispose();
- IconBackground = null;
if (Name == "back")
{
InputGeneratorBase.FinalizeInputGenerator();
AppInfoModel appInfoModel = new AppInfoModel(appInfo.Label, appId, appInfo.IconPath);
appInfoModel.IsRunning = ApplicationManager.IsRunning(appId);
appInfoModel.IsPinned = pinnedAppsInfo.ContainsKey(appId);
- appInfoModel.SetExtractedBackground(appInfoModel.IconUrl);
appInfoModel.CreateUserApplicationsMoreMenu();
appInfoModel.PinAppClicked += () =>
{
* limitations under the License.
*/
+using System;
using System.Collections.Generic;
using System.Windows.Input;
using Tizen.NUI;
},
defaultValueCreator: (bindable) => (bindable as AppItemView).menuItemSelectCommand);
+ public event Action<AppItemView> MoreMenuAdded;
+ public event Action<AppItemView> MoreMenuRemoved;
+
public AppItemView() : base()
{
WidthSpecification = IconSize.SpToPx();
{
UpdateTheme();
}
-
private void UpdateTheme()
{
UpdateMenuTheme();
return;
}
var menuItems = moreMenu.Items as List<MenuItem>;
+ moreMenu.BackgroundColor = Resources.MenuBackgroundColor;
foreach (MenuItem item in menuItems)
{
- item.BackgroundColor = Resources.MenuBackgroundColor;
ColorSelector colors = new ColorSelector()
{
Pressed = Resources.PressedMenuItemTextColor,
{
MenuStyle moreMenuStyle = new MenuStyle()
{
- BackgroundColor = Color.Transparent,
+ CornerRadius = Resources.SingleItemCornerRadius.SpToPx(),
+ MinimumSize = Resources.MinimumMenuSize.SpToPx(),
};
Tizen.Log.Info(Resources.LogTag, "Custom Menu");
moreMenu = new CustomMenu(moreMenuStyle);
+ moreMenu.AddedToWindow += (object sender, EventArgs e) => { MoreMenuAdded?.Invoke(this); };
+ moreMenu.RemovedFromWindow += (object sender, EventArgs e) => { MoreMenuRemoved?.Invoke(this); };
}
moreMenu.Position2D = new Position2D(moreMenuPositionX, moreMenuPositionY);
moreMenu.VisibilityChanged += (object sender, VisibilityChangedEventArgs e) =>
{
ButtonStyle buttonStyle = new ButtonStyle()
{
- Size = Resources.MenuItemSize.SpToPx(),
+ SizeHeight = Resources.MenuItemHeight.SpToPx(),
Padding = new Extents(10, 10, 0, 0).SpToPx(),
Text = new TextLabelStyle()
{
Tizen.Log.Info(Resources.LogTag, "more menu Item: " + menuItemName);
}
}
- if (menuItemsList.Count > 1)
- {
- menuItemsList[0].CornerRadius = Resources.TopItemCornerRadius;
- menuItemsList[^1].CornerRadius = Resources.BottomItemCornerRadius;
- }
- else if (menuItemsList.Count == 1)
- {
- menuItemsList[0].CornerRadius = Resources.SingleItemCornerRadius.SpToPx();
- }
if (moreMenu != null)
{
moreMenu.Items = menuItemsList;
item.Clicked -= OnItemClicked;
}
moreMenuList.Clear();
+ moreMenu.Items = null;
}
}
+++ /dev/null
-/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using Tizen.NUI.BaseComponents;
-using Tizen.NUI.Binding;
-using Tizen.NUI.Components;
-using TaskBar.Common;
-
-namespace TaskBar.Views
-{
- class ApplicationsView : BaseView
- {
- public ApplicationsView() : base()
- {
- Name = "ApplicationsView";
- Tizen.Log.Info(Resources.LogTag, "ApplicationsView");
- }
-
- protected override void UpdateApps()
- {
- if (apps == null)
- {
- return;
- }
-
- foreach (AppItemView item in apps)
- {
- item.BindingContext = null;
- item.Dispose();
- Remove(item);
- }
- apps.Clear();
-
- foreach (var item in AppList)
- {
- AppItemView appItemView = new AppItemView();
- Add(appItemView);
- apps.Add(appItemView);
- appItemView.BindingContext = item;
- appItemView.AppIcon.Icon.SetBinding(ImageView.ResourceUrlProperty, "IconUrl");
- appItemView.AppIcon.SetBinding(Control.CommandProperty, "AppSelectCommand");
- appItemView.AppIcon.SetBinding(BackgroundProperty, "IconBackground");
- appItemView.SetBinding(AppItemView.ShowIndicatorProperty, "IsRunning");
- appItemView.SetBinding(AppItemView.MenuItemNamesProperty, "MoreMenuItems");
- appItemView.SetBinding(AppItemView.MenuItemSelectCommandProperty, "MenuItemSelectCommand");
- }
- Tizen.Log.Info(Resources.LogTag, "Buttons Added");
- }
- }
-}
* limitations under the License.
*/
+using System;
using System.Collections;
using System.Collections.Generic;
using Tizen.NUI;
using Tizen.NUI.BaseComponents;
using Tizen.NUI.Binding;
+using Tizen.NUI.Components;
using TaskBar.Common;
namespace TaskBar.Views
{
- abstract class BaseView : View
+ class BaseView : View
{
protected List<AppItemView> apps;
},
defaultValueCreator: (bindable) => (bindable as BaseView).appList);
+ public event Action<AppItemView, bool> MenuUpdated;
+
public BaseView()
{
Name = "BaseView";
}
}
+ public void UpdateOpacity(View selectedItem, bool isMenuAdded)
+ {
+ if (apps == null)
+ {
+ return;
+ }
+ foreach (AppItemView item in apps)
+ {
+ if (selectedItem == item)
+ {
+ continue;
+ }
+ item.Opacity = isMenuAdded ? 0.5f : 1.0f;
+ }
+ }
+
private IEnumerable appList;
public IEnumerable AppList
{
set => SetValue(AppListProperty, value);
}
- protected abstract void UpdateApps();
+ private void UpdateApps()
+ {
+ if (apps == null)
+ {
+ return;
+ }
+
+ foreach (AppItemView item in apps)
+ {
+ item.BindingContext = null;
+ item.Dispose();
+ Remove(item);
+ }
+ apps.Clear();
+
+ foreach (var item in AppList)
+ {
+ AppItemView appItemView = new AppItemView();
+ Add(appItemView);
+ apps.Add(appItemView);
+ appItemView.BindingContext = item;
+ appItemView.AppIcon.Icon.SetBinding(ImageView.ResourceUrlProperty, "IconUrl");
+ appItemView.AppIcon.SetBinding(Control.CommandProperty, "AppSelectCommand");
+ appItemView.SetBinding(AppItemView.ShowIndicatorProperty, "IsRunning");
+ appItemView.SetBinding(AppItemView.MenuItemNamesProperty, "MoreMenuItems");
+ appItemView.SetBinding(AppItemView.MenuItemSelectCommandProperty, "MenuItemSelectCommand");
+ appItemView.MoreMenuAdded += (AppItemView sender) => { MenuUpdated?.Invoke(sender, true); };
+ appItemView.MoreMenuRemoved += (AppItemView sender) => { MenuUpdated?.Invoke(sender, false); };
+ }
+ Tizen.Log.Info(Resources.LogTag, "Buttons Added");
+ }
protected override void Dispose(DisposeTypes type)
{
* limitations under the License.
*/
-using Tizen.NUI;
using Tizen.NUI.Components;
using TaskBar.Common;
public void SetScrimAttributes()
{
- Scrim.BackgroundColor = new Color(0, 0, 0, 0.3f);
Scrim.AllowOnlyOwnTouch = true;
}
}
{
private ApplicationsViewModel applicationsViewModel;
private QuickAccessViewModel quickAccessViewModel;
- private ApplicationsView applicationsView;
+ private BaseView applicationsView;
private View addPinnedAppsView;
private Button addPinnedAppsButton;
private CustomMenu addButtonMoreMenu;
private int moreMenuPositionX;
private int moreMenuPositionY;
private LongPressGestureDetector addAppsLongPressDetector;
- private QuickAccessView quickAccessView;
+ private BaseView quickAccessView;
private const int AddButtonSize = 48;
CellPadding = new Size2D(8, 0).SpToPx(),
};
applicationsViewModel = new ApplicationsViewModel();
- applicationsView = new ApplicationsView();
+ applicationsView = new BaseView();
Add(applicationsView);
applicationsView.BindingContext = applicationsViewModel;
+ applicationsView.MenuUpdated += OnMenuUpdated;
applicationsView.SetBinding(BaseView.AppListProperty, "ButtonsInfo");
CreateAddPinnedAppsView();
Add(addPinnedAppsView);
quickAccessViewModel = new QuickAccessViewModel();
- quickAccessView = new QuickAccessView();
+ quickAccessView = new BaseView();
Add(quickAccessView);
quickAccessView.BindingContext = quickAccessViewModel;
+ quickAccessView.MenuUpdated += OnMenuUpdated;
quickAccessView.SetBinding(BaseView.AppListProperty, "ButtonsInfo");
UpdateTheme();
ThemeManager.ThemeChanged += OnThemeUpdated;
}
+ private void OnMenuUpdated(View sender, bool isMenuAdded)
+ {
+ applicationsView.UpdateOpacity(sender, isMenuAdded);
+ quickAccessView.UpdateOpacity(sender, isMenuAdded);
+ if (sender != addPinnedAppsButton)
+ {
+ addPinnedAppsView.Opacity = isMenuAdded ? 0.5f : 1.0f;
+ }
+ BackgroundColor = isMenuAdded ? Resources.DisabledTaskbarBackgroundColor : Resources.TaskbarBackgroundColor;
+ }
+
public void UpdateView()
{
WidthSpecification = DeviceInfo.Instance.DisplayWidth;
return;
}
var menuItems = addButtonMoreMenu.Items as List<MenuItem>;
+ addButtonMoreMenu.BackgroundColor = Resources.MenuBackgroundColor;
foreach (MenuItem item in menuItems)
{
- item.BackgroundColor = Resources.MenuBackgroundColor;
ColorSelector colors = new ColorSelector()
{
Pressed = Resources.PressedMenuItemTextColor,
MenuStyle moreMenuStyle = new MenuStyle()
{
Position = new Position2D(moreMenuPositionX, moreMenuPositionY),
- BackgroundColor = Color.Transparent,
+ MinimumSize = Resources.MinimumMenuSize.SpToPx(),
+ CornerRadius = Resources.SingleItemCornerRadius.SpToPx(),
};
addButtonMoreMenu = new CustomMenu(moreMenuStyle);
+ addButtonMoreMenu.AddedToWindow += (object sender, System.EventArgs e) => { OnMenuUpdated(addPinnedAppsButton, true); };
+ addButtonMoreMenu.RemovedFromWindow += (object sender, System.EventArgs e) => { OnMenuUpdated(addPinnedAppsButton, false); };
}
addButtonMoreMenu.VisibilityChanged += (object sender, VisibilityChangedEventArgs e) =>
{
};
ButtonStyle buttonStyle = new ButtonStyle()
{
- Size = Resources.MenuItemSize.SpToPx(),
+ SizeHeight = Resources.MenuItemHeight.SpToPx(),
Padding = new Extents(10, 10, 0, 0).SpToPx(),
Text = new TextLabelStyle()
{
VerticalAlignment = VerticalAlignment.Center,
Text = "Add Apps",
},
- CornerRadius = Resources.SingleItemCornerRadius.SpToPx(),
IsSelectable = false,
};
MenuItem item = new MenuItem(buttonStyle);
ThemeManager.ThemeChanged -= OnThemeUpdated;
DisposeMoreMenu();
+ applicationsView.MenuUpdated -= OnMenuUpdated;
applicationsView.BindingContext = null;
Remove(applicationsView);
applicationsView?.Dispose();
addPinnedAppsView?.Dispose();
addPinnedAppsView = null;
+ quickAccessView.MenuUpdated -= OnMenuUpdated;
quickAccessView.BindingContext = null;
Remove(quickAccessView);
quickAccessView?.Dispose();
+++ /dev/null
-/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using Tizen.NUI.BaseComponents;
-using Tizen.NUI.Binding;
-using Tizen.NUI.Components;
-using TaskBar.Common;
-
-namespace TaskBar.Views
-{
- class QuickAccessView : BaseView
- {
- public QuickAccessView() : base()
- {
- Name = "QuickAccessView";
- Tizen.Log.Info(Resources.LogTag, "QuickAccessView");
- }
-
- protected override void UpdateApps()
- {
- if (apps == null)
- {
- return;
- }
-
- foreach (AppItemView item in apps)
- {
- item.BindingContext = null;
- item.Dispose();
- Remove(item);
- }
- apps.Clear();
-
- foreach (var item in AppList)
- {
- AppItemView appItemView = new AppItemView();
- Add(appItemView);
- apps.Add(appItemView);
- appItemView.BindingContext = item;
- appItemView.AppIcon.Icon.SetBinding(ImageView.ResourceUrlProperty, "IconUrl");
- appItemView.AppIcon.SetBinding(Control.CommandProperty, "AppSelectCommand");
- appItemView.SetBinding(AppItemView.ShowIndicatorProperty, "IsRunning");
- appItemView.SetBinding(AppItemView.MenuItemNamesProperty, "MoreMenuItems");
- appItemView.SetBinding(AppItemView.MenuItemSelectCommandProperty, "MenuItemSelectCommand");
- }
- Tizen.Log.Info(Resources.LogTag, "Buttons Added");
- }
- }
-}
Tizen.Log.Info(Resources.LogTag, "Popup Added");
baseView = new View()
{
- BackgroundColor = new Color(0, 0, 0, 0.3f),
AllowOnlyOwnTouch = true,
};
Window.Instance.Add(baseView);