-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding contrast control button to Visiomatic component (#1212)
* Adding contrast control button to Visiomatic component * Binding ContrastViewModel's value * Applying contrast to the tile * Closed #1216 - Change contrast of tile when configuration is applied. Co-authored-by: Glauber Costa Vila-Verde <[email protected]>
- Loading branch information
1 parent
9dfe98b
commit 65e2b14
Showing
6 changed files
with
1,329 additions
and
997 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
frontend/packages/local/visiomatic/src/contrast/ContrastWindow.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
Ext.define('visiomatic.contrast.ContrastWindow', { | ||
extend: 'Ext.window.Window', | ||
|
||
xtype: 'visiomatic-contrast', | ||
|
||
title: 'Choose Color Ranges', | ||
|
||
width: 250, | ||
height: 200, | ||
|
||
closeAction: 'destroy', | ||
|
||
resizable: false, | ||
|
||
constrain: true, | ||
|
||
bodyPadding: 10, | ||
|
||
config: { | ||
// Instancia atual do visiomatic | ||
visiomatic: null, | ||
// Lista com os contrasts diponiveis e os valores para cada cor. | ||
colorRanges: null, | ||
}, | ||
|
||
viewModel: { | ||
data: { | ||
currentContrast: { contrast: 'normal' }, | ||
} | ||
}, | ||
|
||
initComponent: function () { | ||
var me = this, | ||
vm = me.getViewModel(), | ||
colorRanges = me.getColorRanges(), | ||
radiogroupItems = []; | ||
|
||
// Cria a lista de Radio itens um para cada opcao de contrast | ||
Ext.Object.each(colorRanges, function (contrastName, contrastValues, ranges) { | ||
radiogroupItems.push({ | ||
inputValue: contrastName, | ||
boxLabel: contrastValues.displayName, | ||
height: 30, | ||
}) | ||
}, me) | ||
|
||
Ext.apply(this, { | ||
items: [{ | ||
xtype: 'fieldset', | ||
flex: 1, | ||
border: false, | ||
layout: 'anchor', | ||
defaults: { | ||
anchor: '100%', | ||
hideEmptyLabel: false | ||
}, | ||
items: [ | ||
{ | ||
xtype: 'radiogroup', | ||
hideLabel: true, | ||
columns: 1, | ||
simpleValue: true, | ||
name: 'contrast', | ||
bind: '{currentContrast}', | ||
items: radiogroupItems, | ||
listeners: { | ||
scope: me, | ||
change: me.onChooseContrast | ||
} | ||
} | ||
|
||
] | ||
}] | ||
}); | ||
|
||
me.callParent(arguments); | ||
|
||
}, | ||
|
||
onChooseContrast: function (radiogroup, value) { | ||
var me = this; | ||
me.setCurrentContrast(value.contrast) | ||
}, | ||
|
||
getContrastValues: function (contrastName) { | ||
var me = this, | ||
colorRanges = me.getColorRanges(); | ||
return colorRanges[contrastName] | ||
}, | ||
|
||
/** | ||
* Setar o contraste que está disponível, | ||
* esse contraste será usado para modificar o contraste da tile. | ||
* se o constrate for diferente executa o metodo changeContrast do visiomatic. | ||
* se for igual nao faz nada | ||
*/ | ||
setCurrentContrast: function (currentContrast) { | ||
var me = this, | ||
vm = me.getViewModel(), | ||
oldContrast = vm.get('currentContrast'), | ||
visiomatic = me.getVisiomatic(), | ||
contrastValues = me.getContrastValues(currentContrast); | ||
|
||
if (currentContrast !== oldContrast.contrast) { | ||
|
||
vm.set('currentContrast', { contrast: currentContrast }); | ||
|
||
visiomatic.changeContrast(currentContrast, contrastValues, me) | ||
|
||
} | ||
} | ||
}); |
Oops, something went wrong.