You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ah...@apache.org on 2020/12/07 01:34:14 UTC
[royale-asjs] branch develop updated: initial JS implementation of
ProgressBar. Should help fix #931
This is an automated email from the ASF dual-hosted git repository.
aharui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/develop by this push:
new 8702ca1 initial JS implementation of ProgressBar. Should help fix #931
8702ca1 is described below
commit 8702ca18fcd1dc5be6457653805f3b1e8ffe11ed
Author: Alex Harui <ah...@apache.org>
AuthorDate: Sun Dec 6 17:29:31 2020 -0800
initial JS implementation of ProgressBar. Should help fix #931
---
.../MXRoyale/src/main/resources/defaults.css | 5 +
.../src/main/royale/mx/controls/ProgressBar.as | 11 ++
.../royale/mx/controls/beads/ProgressBarView.as | 118 +++++++++++++++++++++
3 files changed, 134 insertions(+)
diff --git a/frameworks/projects/MXRoyale/src/main/resources/defaults.css b/frameworks/projects/MXRoyale/src/main/resources/defaults.css
index 1210045..1f5dd07 100644
--- a/frameworks/projects/MXRoyale/src/main/resources/defaults.css
+++ b/frameworks/projects/MXRoyale/src/main/resources/defaults.css
@@ -489,6 +489,11 @@ TabNavigator
border: 1px solid #333333
}
+ProgressBar
+{
+ IBeadView: ClassReference("mx.controls.beads.ProgressBarView");
+}
+
TextInput
{
border-color: #000000;
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/ProgressBar.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/ProgressBar.as
index 8f0905b..1686071 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/ProgressBar.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/ProgressBar.as
@@ -45,6 +45,7 @@ import mx.core.IUITextField;
*/
import mx.core.UIComponent;
import mx.events.FlexEvent;
+import mx.controls.beads.ProgressBarView;
/*
import mx.core.UITextField;
import mx.styles.ISimpleStyleClient;
@@ -520,6 +521,11 @@ public class ProgressBar extends UIComponent //implements IFontContextComponent
// "controls", "label");
_label = value;
+ COMPILE::JS
+ {
+ (view as ProgressBarView).text = value;
+ }
+
invalidateDisplayList();
dispatchEvent(new Event("labelChanged"));
@@ -936,6 +942,11 @@ public class ProgressBar extends UIComponent //implements IFontContextComponent
{
if (_mode == ProgressBarMode.MANUAL)
_setProgress(value, total);
+
+ COMPILE::JS
+ {
+ (view as ProgressBarView).setProgress(value / total);
+ }
}
/**
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/ProgressBarView.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/ProgressBarView.as
new file mode 100644
index 0000000..99522aa
--- /dev/null
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/ProgressBarView.as
@@ -0,0 +1,118 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+package mx.controls.beads
+{
+ import org.apache.royale.core.BeadViewBase;
+ import org.apache.royale.core.IBeadView;
+ import org.apache.royale.core.IStrand;
+ import org.apache.royale.core.UIBase;
+ import org.apache.royale.events.Event;
+
+ import mx.controls.ProgressBar;
+
+ /**
+ * The RadioButtonView class creates the visual elements of the org.apache.royale.html.RadioButton
+ * component.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.0
+ */
+ public class ProgressBarView extends BeadViewBase implements IBeadView
+ {
+ /**
+ * constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.0
+ */
+ public function ProgressBarView()
+ {
+ }
+
+ private var host:UIBase;
+ COMPILE::JS
+ private var bar:HTMLElement;
+ COMPILE::JS
+ private var inner:HTMLElement;
+ COMPILE::JS
+ private var label:HTMLSpanElement;
+
+ /**
+ * @copy org.apache.royale.core.IBead#strand
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.0
+ *
+ * @royaleignorecoercion HTMLElement
+ * @royaleignorecoercion HTMLSpanElement
+ */
+ override public function set strand(value:IStrand):void
+ {
+ super.strand = value;
+ host = value as UIBase;
+ COMPILE::JS
+ {
+ bar = document.createElement('div') as HTMLElement;
+ bar.style.width = '100%';
+ bar.style.height = '8px';
+ bar.style.border = 'solid 1px';
+ bar.style.backgroundColor = '#404040';
+ host.element.appendChild(bar);
+ inner = document.createElement('div') as HTMLElement;
+ inner.style.height = '8px';
+ inner.style.backgroundColor = '#C0C0C0';
+ bar.appendChild(inner);
+ label = document.createElement('span') as HTMLSpanElement;
+ host.element.appendChild(label);
+ }
+ }
+
+ COMPILE::JS
+ public function setProgress(value:Number):void
+ {
+ inner.style.width = (value * 100) + '%';
+ }
+
+ /**
+ * The string label for the org.apache.royale.html.RadioButton.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.0
+ */
+ COMPILE::JS
+ public function get text():String
+ {
+ return label.innerText;
+ }
+ COMPILE::JS
+ public function set text(value:String):void
+ {
+ label.innerText = value;
+ }
+
+ }
+}