Skip to content
Snippets Groups Projects
Commit 84f77a5e authored by Ghazi Triki's avatar Ghazi Triki
Browse files

Fix PopUpButtonSkin to follow component life-cycle guidelines.

parent 196d77bc
No related branches found
No related tags found
No related merge requests found
......@@ -37,250 +37,257 @@
////////////////////////////////////////////////////////////////////////////////
package org.bigbluebutton.skins {
import flash.display.DisplayObject;
import mx.core.IFlexDisplayObject;
import mx.core.IProgrammaticSkin;
import mx.core.UIComponent;
import mx.core.mx_internal;
import mx.skins.halo.PopUpIcon;
use namespace mx_internal;
public class PopUpButtonSkin extends UIComponent implements IProgrammaticSkin {
//--------------------------------------------------------------------------
//
// Constructor
//
//--------------------------------------------------------------------------
/**
* Constructor.
*
* @langversion 3.0
* @playerversion Flash 9
* @playerversion AIR 1.1
* @productversion Flex 3
*/
public function PopUpButtonSkin() {
super();
mouseEnabled = false;
}
//--------------------------------------------------------------------------
//
// Overridden properties
//
//--------------------------------------------------------------------------
//----------------------------------
// measuredWidth
//----------------------------------
import flash.display.DisplayObject;
import mx.core.IFlexDisplayObject;
import mx.core.IProgrammaticSkin;
import mx.core.UIComponent;
import mx.core.mx_internal;
import mx.skins.halo.PopUpIcon;
use namespace mx_internal;
public class PopUpButtonSkin extends UIComponent implements IProgrammaticSkin {
//--------------------------------------------------------------------------
//
// Constructor
//
//--------------------------------------------------------------------------
private var popUpIcon:IFlexDisplayObject;
/**
* Constructor.
*
* @langversion 3.0
* @playerversion Flash 9
* @playerversion AIR 1.1
* @productversion Flex 3
*/
public function PopUpButtonSkin() {
super();
mouseEnabled = false;
}
//--------------------------------------------------------------------------
//
// Overridden properties
//
//--------------------------------------------------------------------------
//----------------------------------
// measuredWidth
//----------------------------------
/**
* @private
*/
override public function get measuredWidth():Number {
return DEFAULT_MEASURED_MIN_WIDTH;
}
//----------------------------------
// measuredHeight
//----------------------------------
/**
* @private
*/
override public function get measuredHeight():Number {
return DEFAULT_MEASURED_MIN_HEIGHT;
}
/**
* @private
*/
override public function get measuredWidth():Number {
return DEFAULT_MEASURED_MIN_WIDTH;
}
//--------------------------------------------------------------------------
//
// Overridden methods
//
//--------------------------------------------------------------------------
//----------------------------------
// measuredHeight
//----------------------------------
/**
* Create resize handles and window controls.
*/
override protected function createChildren():void {
popUpIcon = IFlexDisplayObject(getChildByName("popUpIcon"));
/**
* @private
*/
override public function get measuredHeight():Number {
return DEFAULT_MEASURED_MIN_HEIGHT;
}
if (!popUpIcon) {
var popUpIconClass:Class = Class(getStyle("popUpIcon"));
popUpIcon = new popUpIconClass();
DisplayObject(popUpIcon).name = "popUpIcon";
addChild(DisplayObject(popUpIcon));
DisplayObject(popUpIcon).visible = true;
}
}
//--------------------------------------------------------------------------
//
// Overridden methods
//
//--------------------------------------------------------------------------
/**
* @private
*/
override protected function updateDisplayList(w:Number, h:Number):void {
super.updateDisplayList(w, h);
/**
* @private
*/
override protected function updateDisplayList(w:Number, h:Number):void {
super.updateDisplayList(w, h);
var borderColorUp:uint = getStyle("borderColorUp");
var borderColorOver:uint = getStyle("borderColorOver");
var borderColorDown:uint = getStyle("borderColorDown");
var borderColorDisabled:uint = getStyle("borderColorDisabled");
var borderColorUp:uint = getStyle("borderColorUp");
var borderColorOver:uint = getStyle("borderColorOver");
var borderColorDown:uint = getStyle("borderColorDown");
var borderColorDisabled:uint = getStyle("borderColorDisabled");
var borderThickness:uint = getStyle("borderThickness");
var borderThickness:uint = getStyle("borderThickness");
var fillColorUp:uint = getStyle("fillColorUp");
var fillColorOver:uint = getStyle("fillColorOver");
var fillColorDown:uint = getStyle("fillColorDown");
var fillColorDisabled:uint = getStyle("fillColorDisabled");
var fillColorUp:uint = getStyle("fillColorUp");
var fillColorOver:uint = getStyle("fillColorOver");
var fillColorDown:uint = getStyle("fillColorDown");
var fillColorDisabled:uint = getStyle("fillColorDisabled");
// User-defined styles.
var arrowColor:uint = getStyle("iconColor");
var arrowColorOver:uint = getStyle("iconColorOver");
var arrowColorDown:uint = getStyle("iconColorDown");
// User-defined styles.
var arrowColor:uint = getStyle("iconColor");
var arrowColorOver:uint = getStyle("iconColorOver");
var arrowColorDown:uint = getStyle("iconColorDown");
var cornerRadius:Number = getStyle("cornerRadius");
var cornerRadius:Number = getStyle("cornerRadius");
var arrowButtonWidth:Number = Math.max(getStyle("arrowButtonWidth"), popUpIcon.width + 3 + borderThickness);
var popUpIcon:IFlexDisplayObject = IFlexDisplayObject(getChildByName("popUpIcon"));
var dividerPosX:Number = w - arrowButtonWidth;
if (!popUpIcon) {
var popUpIconClass:Class = Class(getStyle("popUpIcon"));
popUpIcon = new popUpIconClass();
DisplayObject(popUpIcon).name = "popUpIcon";
addChild(DisplayObject(popUpIcon));
DisplayObject(popUpIcon).visible = true;
}
popUpIcon.move(w - (arrowButtonWidth + popUpIcon.width) / 2, (h - popUpIcon.height) / 2);
var arrowButtonWidth:Number = Math.max(getStyle("arrowButtonWidth"), popUpIcon.width + 3 + borderThickness);
// Corner radius
var cr:Number = Math.max(0, cornerRadius);
var cr1:Number = Math.max(0, cornerRadius - borderThickness);
var dividerPosX:Number = w - arrowButtonWidth;
graphics.clear();
popUpIcon.move(w - (arrowButtonWidth + popUpIcon.width) / 2, (h - popUpIcon.height) / 2);
switch (name) {
case "upSkin": {
// button border/edge
drawRoundRect(0, 0, w, h, cr, borderColorUp, 1);
// Corner radius
var cr:Number = Math.max(0, cornerRadius);
var cr1:Number = Math.max(0, cornerRadius - borderThickness);
// button fill
drawRoundRect(borderThickness, borderThickness, w - (borderThickness * 2), h - (borderThickness * 2), cr1, fillColorUp, 1);
graphics.clear();
// Separator
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), cr, borderColorUp, 1);
switch (name) {
case "upSkin": {
// button border/edge
drawRoundRect(0, 0, w, h, cr, borderColorUp, 1);
break;
}
case "overSkin": // for hover on the main button (left) side
{
// button border/edge
drawRoundRect(0, 0, w, h, cr, borderColorOver, 1);
// button fill
drawRoundRect(borderThickness, borderThickness, w - (borderThickness * 2), h - (borderThickness * 2), cr1, fillColorUp, 1);
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), 0, borderColorOver, 1);
// Separator
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), cr, borderColorUp, 1);
// button fill
drawRoundRect(borderThickness, borderThickness, w - (borderThickness * 2), h - (borderThickness * 2), cr1, fillColorUp, 1);
break;
}
case "overSkin": // for hover on the main button (left) side
{
// button border/edge
drawRoundRect(0, 0, w, h, cr, borderColorOver, 1);
// left/main button fill
drawRoundRect(borderThickness, borderThickness, w - arrowButtonWidth - borderThickness, h - (borderThickness * 2), getRadius(cr1, true), fillColorOver, 1);
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), 0, borderColorOver, 1);
// Separator
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), cr, borderColorOver, 1);
// button fill
drawRoundRect(borderThickness, borderThickness, w - (borderThickness * 2), h - (borderThickness * 2), cr1, fillColorUp, 1);
break;
}
// left/main button fill
drawRoundRect(borderThickness, borderThickness, w - arrowButtonWidth - borderThickness, h - (borderThickness * 2), getRadius(cr1, true), fillColorOver, 1);
case "popUpOverSkin": // for hover on the arrow-button (right) side
{
arrowColor = arrowColorOver;
// Separator
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), cr, borderColorOver, 1);
// button border/edge
drawRoundRect(0, 0, w, h, cr, borderColorOver, 1);
break;
}
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), 0, borderColorOver, 1);
case "popUpOverSkin": // for hover on the arrow-button (right) side
{
arrowColor = arrowColorOver;
// button fill
drawRoundRect(borderThickness, borderThickness, w - (borderThickness * 2), h - (borderThickness * 2), getRadius(cr1, true), fillColorUp, 1);
// button border/edge
drawRoundRect(0, 0, w, h, cr, borderColorOver, 1);
// right button fill
drawRoundRect(dividerPosX + borderThickness, borderThickness, arrowButtonWidth - (borderThickness * 2), h - (borderThickness * 2), getRadius(cr1, false), fillColorOver, 1);
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), 0, borderColorOver, 1);
// Separator
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), cr, borderColorUp, 1);
// button fill
drawRoundRect(borderThickness, borderThickness, w - (borderThickness * 2), h - (borderThickness * 2), getRadius(cr1, true), fillColorUp, 1);
break;
}
// right button fill
drawRoundRect(dividerPosX + borderThickness, borderThickness, arrowButtonWidth - (borderThickness * 2), h - (borderThickness * 2), getRadius(cr1, false), fillColorOver, 1);
case "downSkin": // for press on the main button (left) side
{
// button border/ddge
drawRoundRect(0, 0, w, h, cr, borderColorDown, 1);
// Separator
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), cr, borderColorUp, 1);
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), 0, borderColorDown, 1);
break;
}
// button fill
drawRoundRect(borderThickness, borderThickness, w - (borderThickness * 2), h - (borderThickness * 2), cr1, fillColorUp, 1);
case "downSkin": // for press on the main button (left) side
{
// button border/ddge
drawRoundRect(0, 0, w, h, cr, borderColorDown, 1);
// left/main button fill
drawRoundRect(borderThickness, borderThickness, w - arrowButtonWidth - borderThickness, h - (borderThickness * 2), getRadius(cr1, true), fillColorDown, 1);
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), 0, borderColorDown, 1);
// Separator
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), cr, borderColorDown, 1);
// button fill
drawRoundRect(borderThickness, borderThickness, w - (borderThickness * 2), h - (borderThickness * 2), cr1, fillColorUp, 1);
break;
}
// left/main button fill
drawRoundRect(borderThickness, borderThickness, w - arrowButtonWidth - borderThickness, h - (borderThickness * 2), getRadius(cr1, true), fillColorDown, 1);
case "popUpDownSkin": // for press on the arrow-button (right) side
{
arrowColor = arrowColorDown;
// Separator
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), cr, borderColorDown, 1);
// button border/edge
drawRoundRect(0, 0, w, h, cr, borderColorDown, 1);
break;
}
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), 0, borderColorDown, 1);
case "popUpDownSkin": // for press on the arrow-button (right) side
{
arrowColor = arrowColorDown;
// button fill
drawRoundRect(borderThickness, borderThickness, w - (borderThickness * 2), h - (borderThickness * 2), cr1, fillColorUp, 1);
// button border/edge
drawRoundRect(0, 0, w, h, cr, borderColorDown, 1);
// right button fill
drawRoundRect(dividerPosX + borderThickness, borderThickness, arrowButtonWidth - (borderThickness * 2), h - (borderThickness * 2), getRadius(cr1, false), fillColorDown, 1);
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), 0, borderColorDown, 1);
// Separator
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), cr, borderColorDown, 1);
// button fill
drawRoundRect(borderThickness, borderThickness, w - (borderThickness * 2), h - (borderThickness * 2), cr1, fillColorUp, 1);
break;
}
// right button fill
drawRoundRect(dividerPosX + borderThickness, borderThickness, arrowButtonWidth - (borderThickness * 2), h - (borderThickness * 2), getRadius(cr1, false), fillColorDown, 1);
case "disabledSkin": {
arrowColor = getStyle("disabledIconColor");
// Separator
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), cr, borderColorDown, 1);
// outer edge
drawRoundRect(0, 0, w, h, cornerRadius, fillColorDisabled, 1);
break;
}
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), 0, borderColorDisabled, 1);
case "disabledSkin": {
arrowColor = getStyle("disabledIconColor");
// button fill
drawRoundRect(borderThickness, borderThickness, w - (borderThickness * 2), h - (borderThickness * 2), cr1, fillColorDisabled, 1);
// outer edge
drawRoundRect(0, 0, w, h, cornerRadius, fillColorDisabled, 1);
// Separator
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), cr, borderColorDisabled, 1);
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), 0, borderColorDisabled, 1);
// Separator
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), cr, borderColorDisabled, 1);
// button fill
drawRoundRect(borderThickness, borderThickness, w - (borderThickness * 2), h - (borderThickness * 2), cr1, fillColorDisabled, 1);
break;
}
// Separator
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), cr, borderColorDisabled, 1);
}
// Separator
drawRoundRect(dividerPosX, borderThickness, borderThickness, h - (borderThickness * 2), cr, borderColorDisabled, 1);
if (popUpIcon is PopUpIcon)
PopUpIcon(popUpIcon).arrowColor = arrowColor;
}
break;
}
//--------------------------------------------------------------------------
//
// Methods
//
//--------------------------------------------------------------------------
}
if (popUpIcon is PopUpIcon)
PopUpIcon(popUpIcon).arrowColor = arrowColor;
}
//--------------------------------------------------------------------------
//
// Methods
//
//--------------------------------------------------------------------------
/**
* @private
*/
private function getRadius(r:Number, left:Boolean):Object {
return left ? {br: 0, bl: r, tr: 0, tl: r} : {br: r, bl: 0, tr: r, tl: 0};
}
}
/**
* @private
*/
private function getRadius(r:Number, left:Boolean):Object {
return left ? {br: 0, bl: r, tr: 0, tl: r} : {br: r, bl: 0, tr: r, tl: 0};
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment