-/*
- * Copyright (c) 2016 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.
- *
- */
+/** Copyright (c) 2017 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 System;
using System.Runtime.InteropServices;
private Dali.Application _application;
private TableView _contentContainer;
+ private Timer _timer;
private Stage _stage;
private Popup _popup;
+ private ProgressBar _progressBar;
// List of items
private Item[] mViewList = {
- new Item("PushButton", true), new Item("DropDown", false), new Item("Toggle", true),
- new Item("InputField", false), new Item("AnimateGif", false), new Item("Loading", false),
- new Item("ProgressBar", false), new Item("CheckBox", false), new Item("RadioButton", true),
- new Item("Tooltip", true), new Item("Popup", true), new Item("Toast", true),
- new Item("ItemView", false), new Item("CheckBox", true)
- };
+ new Item("PushButton", true), new Item("DropDown", false), new Item("Toggle", true),
+ new Item("InputField", false), new Item("AnimateGif", false), new Item("Loading", false),
+ new Item("ProgressBar", true), new Item("CheckBox", false), new Item("RadioButton", true),
+ new Item("Tooltip", true), new Item("Popup", true), new Item("Toast", true),
+ new Item("ItemView", false), new Item("CheckBox", true)
+ };
public Example(Dali.Application application)
{
topLabel.SetResizePolicy(ResizePolicyType.FILL_TO_PARENT, DimensionType.WIDTH);
topLabel.SetResizePolicy(ResizePolicyType.SIZE_RELATIVE_TO_PARENT, DimensionType.HEIGHT);
topLabel.AnchorPoint = NDalic.AnchorPointTopCenter;
- topLabel.ParentOrigin = NDalic.ParentOriginTopCenter;
- topLabel.SetSizeModeFactor(new Vector3( 0.0f, 0.1f, 0.0f ) );
+ topLabel.Position = new Position(0, 0, 0);
+ topLabel.SetSizeModeFactor(new Vector3(0.0f, 0.1f, 0.0f));
topLabel.BackgroundColor = new Color(43.0f / 255.0f, 145.0f / 255.0f, 175.0f / 255.0f, 1.0f);
topLabel.TextColor = NDalic.WHITE;
topLabel.Text = " DALi Views";
_contentContainer = new TableView(6, 5);
_contentContainer.SetResizePolicy(ResizePolicyType.FILL_TO_PARENT, DimensionType.WIDTH);
_contentContainer.SetResizePolicy(ResizePolicyType.SIZE_RELATIVE_TO_PARENT, DimensionType.HEIGHT);
- _contentContainer.SetSizeModeFactor(new Vector3( 0.0f, 0.9f, 0.0f ) );
+ _contentContainer.SetSizeModeFactor(new Vector3(0.0f, 0.9f, 0.0f));
_contentContainer.AnchorPoint = NDalic.AnchorPointBottomCenter;
- _contentContainer.ParentOrigin = NDalic.ParentOriginBottomCenter;
+ _contentContainer.Position = new Position(0, _stage.Size.Height * 0.1f, 0);
_contentContainer.SetRelativeHeight(0, 0.07f);
_contentContainer.SetRelativeHeight(1, 0.26f);
_contentContainer.SetRelativeHeight(2, 0.07f);
pushButton.LabelText = "Push Button";
pushButton.SetResizePolicy(ResizePolicyType.FILL_TO_PARENT, DimensionType.WIDTH);
pushButton.SetResizePolicy(ResizePolicyType.FILL_TO_PARENT, DimensionType.HEIGHT);
- pushButton.UnselectedColor = new Vector4(1.0f,0.0f,0.0f,1.0f);
- pushButton.SelectedColor = new Vector4(0.0f,1.0f,0.0f,1.0f);
+ pushButton.UnselectedColor = new Vector4(1.0f, 0.0f, 0.0f, 1.0f);
+ pushButton.SelectedColor = new Vector4(0.0f, 1.0f, 0.0f, 1.0f);
pushButton.Clicked += (obj, e) =>
{
e.Button.LabelText = "Click Me";
- e.Button.UnselectedColor = new Vector4(0.0f,0.0f,1.0f,1.0f);
+ e.Button.UnselectedColor = new Vector4(0.0f, 0.0f, 1.0f, 1.0f);
return true;
};
{
ToggleButton toggleButton = new ToggleButton();
Dali.Property.Array array = new Dali.Property.Array();
- array.Add( new Dali.Property.Value("./images/star-highlight.png") );
- array.Add( new Dali.Property.Value("./images/star-mod.png") );
- array.Add( new Dali.Property.Value("./images/star-dim.png") );
+ array.Add(new Dali.Property.Value("./images/star-highlight.png"));
+ array.Add(new Dali.Property.Value("./images/star-mod.png"));
+ array.Add(new Dali.Property.Value("./images/star-dim.png"));
toggleButton.StateVisuals = array;
Dali.Property.Array tooltips = new Dali.Property.Array();
- tooltips.Add( new Dali.Property.Value("State A") );
- tooltips.Add( new Dali.Property.Value("State B") );
- tooltips.Add( new Dali.Property.Value("State C") );
+ tooltips.Add(new Dali.Property.Value("State A"));
+ tooltips.Add(new Dali.Property.Value("State B"));
+ tooltips.Add(new Dali.Property.Value("State C"));
toggleButton.Tooltips = tooltips;
- toggleButton.WidthResizePolicy = "FILL_TO_PARENT";
+ toggleButton.WidthResizePolicy = "FILL_TO_PARENT";
toggleButton.HeightResizePolicy = "FILL_TO_PARENT";
toggleButton.Clicked += (obj, e) =>
{
}
if (item.name.CompareTo("ProgressBar") == 0)
{
+ _progressBar = new ProgressBar();
+ _progressBar.SetResizePolicy(ResizePolicyType.FILL_TO_PARENT, DimensionType.WIDTH);
+ _progressBar.SetResizePolicy(ResizePolicyType.FIXED, DimensionType.HEIGHT);
+ _progressBar.SetSize(0, 50);
+ _progressBar.ValueChanged += OnProgressBarValueChanged;
+
+ _timer = new Timer(100);
+ _timer.Tick += (obj, e) =>
+ {
+ float progress = (float)Math.Round(_progressBar.ProgressValue, 2);
+
+ if (progress == 1.0f)
+ {
+ _progressBar.ProgressValue = 0.0f;
+ _progressBar.SecondaryProgressValue = 0.01f;
+ }
+ else
+ {
+ _progressBar.ProgressValue = progress + 0.01f;
+ _progressBar.SecondaryProgressValue = progress + 0.21f;
+ }
+ return true;
+ };
+ _timer.Start();
+
+ _contentContainer.AddChild(_progressBar, new TableView.CellPosition(((uint)idx / 5) * 2 + 1, (uint)idx % 5));
}
if (item.name.CompareTo("ScrollBar") == 0)
{
RadioButton rButton = new RadioButton();
rButton.LabelText = "Yes";
rButton.Selected = true;
+
tableView.AddChild(rButton, new TableView.CellPosition(0, 0));
rButton = new RadioButton();
// Create two push buttons and add them to a table view
PushButton buttonWithSimpleTooltip = new PushButton();
buttonWithSimpleTooltip.LabelText = "Tooltip with text only";
- buttonWithSimpleTooltip.UnselectedColor = new Vector4(0.5f,0.5f,0.7f,1.0f);
- buttonWithSimpleTooltip.SelectedColor = new Vector4(0.7f,0.5f,0.7f,1.0f);
+ buttonWithSimpleTooltip.UnselectedColor = new Vector4(0.5f, 0.5f, 0.7f, 1.0f);
+ buttonWithSimpleTooltip.SelectedColor = new Vector4(0.7f, 0.5f, 0.7f, 1.0f);
buttonWithSimpleTooltip.WidthResizePolicy = "FILL_TO_PARENT";
tableView.AddChild(buttonWithSimpleTooltip, new TableView.CellPosition(0, 0));
PushButton buttonWithIconTooltip = new PushButton();
buttonWithIconTooltip.LabelText = "Tooltip with Text and Icon";
buttonWithIconTooltip.WidthResizePolicy = "FILL_TO_PARENT";
- buttonWithIconTooltip.UnselectedColor = new Vector4(0.5f,0.5f,0.7f,1.0f);
- buttonWithIconTooltip.SelectedColor = new Vector4(0.7f,0.5f,0.7f,1.0f);
+ buttonWithIconTooltip.UnselectedColor = new Vector4(0.5f, 0.5f, 0.7f, 1.0f);
+ buttonWithIconTooltip.SelectedColor = new Vector4(0.7f, 0.5f, 0.7f, 1.0f);
+
tableView.AddChild(buttonWithIconTooltip, new TableView.CellPosition(1, 0));
// Add a simple text only tooltip to the first push button
Property.Array iconTooltipContent = new Property.Array();
Property.Map iconVisual = new Property.Map();
- iconVisual.Add( Dali.Constants.Visual.Property.Type, new Property.Value((int)Dali.Constants.Visual.Type.Image) )
- .Add( Dali.Constants.ImageVisualProperty.URL, new Property.Value("./images/star-highlight.png") );
+ iconVisual.Add(Dali.Constants.Visual.Property.Type, new Property.Value((int)Dali.Constants.Visual.Type.Image))
+ .Add(Dali.Constants.ImageVisualProperty.URL, new Property.Value("./images/star-highlight.png"));
iconTooltipContent.Add(new Property.Value(iconVisual));
Property.Map textVisual = new Property.Map();
- textVisual.Add( Dali.Constants.Visual.Property.Type, new Property.Value((int)Dali.Constants.Visual.Type.Text) )
- .Add( Dali.Constants.TextVisualProperty.Text, new Property.Value("Tooltip with Icon") );
+ textVisual.Add(Dali.Constants.Visual.Property.Type, new Property.Value((int)Dali.Constants.Visual.Type.Text))
+ .Add(Dali.Constants.TextVisualProperty.Text, new Property.Value("Tooltip with Icon"));
iconTooltipContent.Add(new Property.Value(textVisual));
Property.Map iconTooltip = new Property.Map();
- iconTooltip.Add( Dali.Constants.Tooltip.Property.Content, new Property.Value(iconTooltipContent) )
- .Add( Dali.Constants.Tooltip.Property.Tail, new Property.Value(true) );
+ iconTooltip.Add(Dali.Constants.Tooltip.Property.Content, new Property.Value(iconTooltipContent))
+ .Add(Dali.Constants.Tooltip.Property.Tail, new Property.Value(true));
// Add the tooltip with icon and text to the second push button
buttonWithIconTooltip.Tooltip = iconTooltip;
button.LabelText = "Popup";
button.ParentOrigin = NDalic.ParentOriginCenter;
button.AnchorPoint = NDalic.AnchorPointCenter;
- button.MaximumSize = new Vector2(90.0f,50.0f);
+ button.MaximumSize = new Vector2(90.0f, 50.0f);
_popup = CreatePopup();
_popup.SetTitle(CreateTitle("Popup"));
text.MultiLine = true;
text.SetResizePolicy(ResizePolicyType.FILL_TO_PARENT, DimensionType.WIDTH);
text.SetResizePolicy(ResizePolicyType.DIMENSION_DEPENDENCY, DimensionType.HEIGHT);
- text.SetPadding(new RectFloat(10.0f, 10.0f, 20.0f, 0.0f));
+ text.SetPadding(new PaddingType(10.0f, 10.0f, 20.0f, 0.0f));
_popup.SetContent(text);
_popup.SetKeyboardFocusable(true);
_popup.SetDisplayState(Popup.DisplayStateType.HIDDEN);
{
_stage.Add(_popup);
_popup.SetDisplayState(Popup.DisplayStateType.SHOWN);
- FocusManager.Instance.SetCurrentFocusActor((_popup.FindChildByName( "Footer" )).FindChildByName("OKButton"));
+ FocusManager.Instance.SetCurrentFocusActor((_popup.FindChildByName("Footer")).FindChildByName("OKButton"));
return true;
};
_contentContainer.AddChild(button, new TableView.CellPosition(((uint)idx / 5) * 2 + 1, (uint)idx % 5));
button.AnchorPoint = NDalic.AnchorPointCenter;
button.Clicked += (obj, ee) =>
{
- TypeInfo typeInfo = new TypeInfo(TypeRegistry.Get().GetTypeInfo( "PopupToast" ));
- if( typeInfo )
+ TypeInfo typeInfo = new TypeInfo(TypeRegistry.Get().GetTypeInfo("PopupToast"));
+ if (typeInfo)
{
BaseHandle baseHandle = typeInfo.CreateInstance();
- if( baseHandle )
+ if (baseHandle)
{
- Popup toast = Popup.DownCast( baseHandle );
+ Popup toast = Popup.DownCast(baseHandle);
TextLabel text = new TextLabel("This is a Toast.\nIt will auto-hide itself");
text.TextColor = Color.White;
text.MultiLine = true;
text.HorizontalAlignment = "center";
- toast.SetTitle( text);
+ toast.SetTitle(text);
_stage.Add(toast);
- toast.SetDisplayState( Popup.DisplayStateType.SHOWN);
+ toast.SetDisplayState(Popup.DisplayStateType.SHOWN);
}
}
return true;
ImageView notSupportView = new ImageView("images/not_yet_sign.png");
notSupportView.Size = new Vector3(_stage.GetSize().Width * 0.2f, _stage.GetSize().Height * 0.25f, 0.0f);
notSupportView.SetKeyboardFocusable(true);
+
_contentContainer.AddChild(notSupportView, new TableView.CellPosition(((uint)idx / 5) * 2 + 1, (uint)idx % 5));
}
}
okButton.SetResizePolicy(ResizePolicyType.SIZE_FIXED_OFFSET_FROM_PARENT, DimensionType.ALL_DIMENSIONS);
okButton.SetSizeModeFactor(new Vector3(-20.0f, -20.0f, 0.0f));
+
PushButton cancelButton = CreateCancelButton();
cancelButton.ParentOrigin = NDalic.ParentOriginCenter;
cancelButton.AnchorPoint = NDalic.AnchorPointCenter;
cancelButton.SetResizePolicy(ResizePolicyType.SIZE_FIXED_OFFSET_FROM_PARENT, DimensionType.ALL_DIMENSIONS);
cancelButton.SetSizeModeFactor(new Vector3(-20.0f, -20.0f, 0.0f));
+
TableView controlLayout = new TableView(1, 2);
controlLayout.ParentOrigin = NDalic.ParentOriginCenter;
controlLayout.AnchorPoint = NDalic.AnchorPointCenter;
controlLayout.AddChild(okButton, new TableView.CellPosition(0, 0));
controlLayout.AddChild(cancelButton, new TableView.CellPosition(0, 1));
+
footer.Add(controlLayout);
confirmationPopup.SetFooter(footer);
titleActor.TextColor = Color.White;
titleActor.MultiLine = true;
titleActor.HorizontalAlignment = "center";
+
return titleActor;
}
return cancelButton;
}
+ void OnProgressBarValueChanged(object source, ProgressBar.ValueChangedEventArgs e)
+ {
+ Property.Map labelVisual = new Property.Map();
+ labelVisual.Add(Dali.Constants.Visual.Property.Type, new Property.Value((int)Dali.Constants.Visual.Type.Text))
+ .Add(Dali.Constants.TextVisualProperty.Text, new Property.Value(Math.Round(e.ProgressBar.ProgressValue, 2) + " / " + Math.Round(e.ProgressBar.SecondaryProgressValue, 2)));
+ e.ProgressBar.LabelVisual = labelVisual;
+ return;
+ }
+
public void MainLoop()
{
_application.MainLoop();
{
Console.WriteLine("Hello Mono World");
- Example example = new Example(Application.NewApplication());
+ Example example = new Example(Application.NewApplication("json/control-dashboard.json"));
example.MainLoop();
}
}
}
+