You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ca...@apache.org on 2020/09/01 12:23:44 UTC
[royale-asjs] branch develop updated: jewel-tabbar: make indicator
in tabbar take into account the layout horizontal or vertical
This is an automated email from the ASF dual-hosted git repository.
carlosrovira 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 4f1d689 jewel-tabbar: make indicator in tabbar take into account the layout horizontal or vertical
4f1d689 is described below
commit 4f1d689036e213ce833ebdaf747f0480756af744
Author: Carlos Rovira <ca...@apache.org>
AuthorDate: Tue Sep 1 14:23:31 2020 +0200
jewel-tabbar: make indicator in tabbar take into account the layout horizontal or vertical
---
.../projects/Jewel/src/main/resources/defaults.css | 14 +++++++---
.../itemRenderers/TabBarItemRendererInitializer.as | 6 +++--
.../apache/royale/jewel/beads/views/TabBarView.as | 31 +++++++++++++++++++---
.../itemRenderers/TabBarButtonItemRenderer.as | 6 ++---
.../Jewel/src/main/sass/components/_tabbar.sass | 21 ++++++++++++---
.../JewelTheme/src/main/resources/defaults.css | 12 +++++++--
.../src/main/sass/components-primary/_tabbar.sass | 27 ++++++++++++++-----
7 files changed, 91 insertions(+), 26 deletions(-)
diff --git a/frameworks/projects/Jewel/src/main/resources/defaults.css b/frameworks/projects/Jewel/src/main/resources/defaults.css
index 45d1ec7..0843800 100644
--- a/frameworks/projects/Jewel/src/main/resources/defaults.css
+++ b/frameworks/projects/Jewel/src/main/resources/defaults.css
@@ -3702,15 +3702,21 @@ j|TabBar {
pointer-events: none;
z-index: 1;
}
-.jewel.tabbarbutton .indicator > .indicatorContent {
- align-self: flex-end;
- width: 100%;
+.jewel.tabbarbutton .indicator > .indicator-content {
opacity: 0;
+ align-self: flex-end;
}
-.jewel.tabbarbutton.selected .indicator > .indicatorContent {
+.jewel.tabbarbutton.selected .indicator > .indicator-content {
opacity: 1;
}
+.jewel.tabbar.layout.horizontal .indicator > .indicator-content {
+ width: 100%;
+}
+.jewel.tabbar.layout.vertical .indicator > .indicator-content {
+ height: 100%;
+}
+
j|TabBarButtonItemRenderer {
IBeadController: ClassReference("org.apache.royale.html.beads.controllers.ItemRendererMouseController");
IBeadLayout: ClassReference("org.apache.royale.jewel.beads.layouts.HorizontalLayout");
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/itemRenderers/TabBarItemRendererInitializer.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/itemRenderers/TabBarItemRendererInitializer.as
index 2b61c03..fcc244c 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/itemRenderers/TabBarItemRendererInitializer.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/itemRenderers/TabBarItemRendererInitializer.as
@@ -22,9 +22,9 @@ package org.apache.royale.jewel.beads.itemRenderers
import org.apache.royale.core.IBeadLayout;
import org.apache.royale.core.IIndexedItemRenderer;
import org.apache.royale.core.IStrand;
+ import org.apache.royale.core.IStyledUIBase;
import org.apache.royale.core.layout.IPaddings;
import org.apache.royale.jewel.beads.layouts.Paddings;
- import org.apache.royale.jewel.beads.layouts.SimpleVerticalLayout;
import org.apache.royale.jewel.beads.models.ListPresentationModel;
import org.apache.royale.jewel.itemRenderers.TabBarButtonItemRenderer;
@@ -60,7 +60,9 @@ package org.apache.royale.jewel.beads.itemRenderers
// if layout is vertical make button width = 100% so all buttons grow to fill all available space
var strandLayout:IBead = _strand.getBeadByType(IBeadLayout);
- if(strandLayout is SimpleVerticalLayout)
+
+ // if(strandLayout is SimpleVerticalLayout)
+ if((_strand as IStyledUIBase).containsClass("vertical"))
{
TabBarButtonItemRenderer(ir).percentWidth = 100;
}
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/TabBarView.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/TabBarView.as
index a2b0834..fa31cf3 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/TabBarView.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/TabBarView.as
@@ -25,6 +25,7 @@ package org.apache.royale.jewel.beads.views
import org.apache.royale.events.Event;
import org.apache.royale.jewel.itemRenderers.TabBarButtonItemRenderer;
}
+ import org.apache.royale.core.IStyledUIBase;
import org.apache.royale.utils.getSelectionRenderBead;
/**
@@ -58,6 +59,15 @@ package org.apache.royale.jewel.beads.views
super();
}
+ // private var _layout:StyledLayoutBase;
+ // public function get layout():StyledLayoutBase
+ // {
+ // if(!_layout)
+ // _layout = _strand.getBeadByType(IBeadLayout) as StyledLayoutBase;
+
+ // return _layout;
+ // }
+
/**
* @private
* @royaleignorecoercion org.apache.royale.core.StyledMXMLItemRenderer
@@ -77,13 +87,26 @@ package org.apache.royale.jewel.beads.views
var lastRect:ClientRect = prev_ir.getBoundingBox;
var currentRect:ClientRect = ir.getBoundingBox;
var widthDiff:Number = lastRect.width / currentRect.width;
- if(isNaN(widthDiff))
- widthDiff = 1;
- var positionDiff:Number = lastRect.left - currentRect.left;
+
+ if((_strand as IStyledUIBase).containsClass("horizontal"))
+ {
+ if(isNaN(widthDiff))
+ widthDiff = 1;
+ var positionXDiff:Number = lastRect.left - currentRect.left;
+ } else {
+ var heightDiff:Number = lastRect.height / currentRect.height;
+ if(isNaN(heightDiff))
+ heightDiff = 1;
+ var positionYDiff:Number = lastRect.top - currentRect.top;
+ }
selectionBead = getSelectionRenderBead(ir);
selectionBead.selected = true;
- ir.animateIndicator(positionDiff, widthDiff, 300, 'ease-in-out');
+ if((_strand as IStyledUIBase).containsClass("horizontal"))
+ ir.animateIndicator("X", positionXDiff, widthDiff, 300, 'ease-in-out');
+ else
+ ir.animateIndicator("Y", positionYDiff, heightDiff, 300, 'ease-in-out');
+
} else
{
selectionBead = getSelectionRenderBead(ir);
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/itemRenderers/TabBarButtonItemRenderer.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/itemRenderers/TabBarButtonItemRenderer.as
index 4930480..321bc9b 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/itemRenderers/TabBarButtonItemRenderer.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/itemRenderers/TabBarButtonItemRenderer.as
@@ -108,7 +108,7 @@ package org.apache.royale.jewel.itemRenderers
addIndicator();
indicator_content = document.createElement('span') as HTMLSpanElement;
- indicator_content.className = "indicatorContent";
+ indicator_content.className = "indicator-content";
indicator.appendChild(indicator_content);
return element;
@@ -133,12 +133,12 @@ package org.apache.royale.jewel.itemRenderers
}
COMPILE::JS
- public function animateIndicator(positionDiff:Number, widthDiff:Number, duration:int, easingFunction:String):void
+ public function animateIndicator(axis:String, positionDiff:Number, widthDiff:Number, duration:int, easingFunction:String):void
{
indicator_content["animate"](
[
{
- transform: "translateX(" + positionDiff + "px) scaleX(" + widthDiff + ")"
+ transform: "translate" + axis + "(" + positionDiff + "px) scale" + axis + "(" + widthDiff + ")"
},
{
transform: "none"
diff --git a/frameworks/projects/Jewel/src/main/sass/components/_tabbar.sass b/frameworks/projects/Jewel/src/main/sass/components/_tabbar.sass
index 0531a9e..2cf29d5 100644
--- a/frameworks/projects/Jewel/src/main/sass/components/_tabbar.sass
+++ b/frameworks/projects/Jewel/src/main/sass/components/_tabbar.sass
@@ -98,16 +98,29 @@ $tabbarbutton-margin: 0 !default
pointer-events: none
z-index: 1
- > .indicatorContent
- align-self: flex-end
- width: 100%
+ > .indicator-content
opacity: 0
+ align-self: flex-end
&.selected
.indicator
- > .indicatorContent
+ > .indicator-content
opacity: 1
+// indicator depends on TabBar horizontal or vertical layout to be bottom or at side
+.jewel
+ &.tabbar
+ &.layout
+ &.horizontal
+ .indicator
+ > .indicator-content
+ width: 100%
+ &.vertical
+ .indicator
+ > .indicator-content
+ height: 100%
+
+
j|TabBarButtonItemRenderer
IBeadController: ClassReference("org.apache.royale.html.beads.controllers.ItemRendererMouseController")
IBeadLayout: ClassReference("org.apache.royale.jewel.beads.layouts.HorizontalLayout")
diff --git a/frameworks/themes/JewelTheme/src/main/resources/defaults.css b/frameworks/themes/JewelTheme/src/main/resources/defaults.css
index 92004d1..90958c4 100644
--- a/frameworks/themes/JewelTheme/src/main/resources/defaults.css
+++ b/frameworks/themes/JewelTheme/src/main/resources/defaults.css
@@ -1194,8 +1194,7 @@ j|TabBar {
font-weight: 600;
transition: background-color 0.3s ease-in-out, color 0.3s ease-in-out;
}
-.jewel.tabbarbutton .indicator > .indicatorContent {
- height: 2px;
+.jewel.tabbarbutton .indicator > .indicator-content {
background-color: #3CADF1;
}
.jewel.tabbarbutton.hovered {
@@ -1206,6 +1205,15 @@ j|TabBar {
background: rgba(60, 173, 241, 0.4);
}
+.jewel.tabbar.layout.horizontal .indicator > .indicator-content {
+ height: 2px;
+}
+.jewel.tabbar.layout.vertical .indicator > .indicator-content {
+ width: 2px;
+ right: 0;
+ position: absolute;
+}
+
.jewel.simpletable {
background: linear-gradient(white, #f3f3f3);
border: 1px solid #b3b3b3;
diff --git a/frameworks/themes/JewelTheme/src/main/sass/components-primary/_tabbar.sass b/frameworks/themes/JewelTheme/src/main/sass/components-primary/_tabbar.sass
index e786261..4354406 100644
--- a/frameworks/themes/JewelTheme/src/main/sass/components-primary/_tabbar.sass
+++ b/frameworks/themes/JewelTheme/src/main/sass/components-primary/_tabbar.sass
@@ -58,14 +58,8 @@ j|TabBar
// padding-bottom: 12px
.indicator
- > .indicatorContent
- height: 2px
+ > .indicator-content
background-color: $primary-color
- // transform-origin: left
- // transition: transform .25s ease-in-out //cubic-bezier(.4,0,.2,1)
- // animation-duration: .3s
- // animation-timing-function: ease-in-out
- // animation-fill-mode: both
&.hovered
// color: $font-theme-color
background: rgba($primary-color, .2)
@@ -75,5 +69,24 @@ j|TabBar
color: darken($primary-color, 15%)
background: rgba($primary-color, .4)
+.jewel
+ &.tabbar
+ &.layout
+ &.horizontal
+ .indicator
+ > .indicator-content
+ height: 2px
+ // transform-origin: left
+ // transition: transform .25s ease-in-out //cubic-bezier(.4,0,.2,1)
+ // animation-duration: .3s
+ // animation-timing-function: ease-in-out
+ // animation-fill-mode: both
+ &.vertical
+ .indicator
+ > .indicator-content
+ width: 2px
+ right: 0
+ position: absolute
+
// j|TabBarButtonItemRenderer
// itemsHorizontalAlign: itemsCenter
\ No newline at end of file