Commit 859b0922 authored by Bas Lijnse's avatar Bas Lijnse

Improved ui diff for buttons and icons

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@2368 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 48168bcb
......@@ -10,4 +10,13 @@ Ext.define('itwc.component.action.ActionButton',{
onClick: function() {
this.viewport = this.findViewport();
this.viewport.fireEvent('action',this.taskId, this.actionId);
}});
},
//Update operations
setEnabled: function(enabled) {
if(enabled) {
this.enable();
} else {
this.disable();
}
}
});
......@@ -30,6 +30,11 @@ Ext.define('itwc.component.misc.Icon', {
this.setType(iconCls);
},
setTooltip: function(text) {
this.tooltip = new Ext.ToolTip({html: text, target: this.getEl()});
if(this.tooltip) {
this.tooltip.destroy();
}
if(text){
this.tooltip = new Ext.ToolTip({html: text, target: this.getEl()});
}
}
});
......@@ -235,7 +235,7 @@ Ext.define('itwc.controller.Controller', {
} else {
//If replace is not defined as function, try remove followed by add
if(update.method == 'replace' && typeof cmp['remove'] == 'function' && typeof cmp['insert'] == 'function') {
me.warn("Doing inefficient replace by using remove followed by add");
me.warn("Doing inefficient replace by using remove followed by add in " + update.arguments[1].xtype);
cmp.suspendLayout = true; //Don't layout in between remove and add
cmp.remove(update.arguments[0]);
cmp.insert(update.arguments[0],update.arguments[1]);
......
......@@ -14,6 +14,9 @@ from Task import :: Event
| UISetEnabled !Bool // Enable/disable form elements
| UISetActive !Bool // Make a tab active/inactive
| UISetTitle !(Maybe String) // Set/reset title of a container
| UISetText !(Maybe String) // Set/reset text of a button
| UISetIconCls !(Maybe String) // Set/reset icon of component
| UISetTooltip !(Maybe String) // Set/reset tooltip of a component
| UISetHotkeys ![UIKeyAction] // Set hotkeys for a container
| UISelfUpdate !UIControl // Let a component update itself with a new UI definition (for custom components)
//Structure edits
......
......@@ -75,13 +75,13 @@ diffControls path event c1 c2
(UITree sOpts1 cOpts1, UITree sOpts2 cOpts2)
= [diffSizeOpts path sOpts1 sOpts2,diffChoiceOpts path cOpts1 cOpts2]
(UIActionButton sOpts1 aOpts1 opts1, UIActionButton sOpts2 aOpts2 opts2)
= [diffSizeOpts path sOpts1 sOpts2,diffActionOpts path aOpts1 aOpts2,diffOpts opts1 opts2]
= [diffSizeOpts path sOpts1 sOpts2,diffActionOpts path aOpts1 aOpts2,diffButtonOpts path opts1 opts2]
(UIMenuButton sOpts1 opts1, UIMenuButton sOpts2 opts2)
= [diffSizeOpts path sOpts1 sOpts2,diffOpts opts1 opts2]
(UILabel sOpts1 opts1, UILabel sOpts2 opts2)
= [diffSizeOpts path sOpts1 sOpts2,diffOpts opts1 opts2]
(UIIcon sOpts1 opts1, UIIcon sOpts2 opts2)
= [diffSizeOpts path sOpts1 sOpts2,diffOpts opts1 opts2]
= [diffSizeOpts path sOpts1 sOpts2,diffIconOpts path opts1 opts2]
(UITab sOpts1 opts1, UITab sOpts2 opts2)
= [diffSizeOpts path sOpts1 sOpts2,diffOpts opts1 opts2]
// Tasklet on the right hand side:
......@@ -188,7 +188,7 @@ selfUpdate path c1 c2
diffPanelOpts :: UIPath Event UIPanelOpts UIPanelOpts -> DiffResult
diffPanelOpts path event opts1 opts2
| impossible = DiffImpossible
= DiffPossible (foldr (++) [] [titleUpd,menusUpd,hotkeyUpd])
= DiffPossible (flatten [titleUpd,menusUpd,hotkeyUpd])
where
impossible = opts1.UIPanelOpts.frame <> opts2.UIPanelOpts.frame
|| opts1.UIPanelOpts.iconCls <> opts2.UIPanelOpts.iconCls
......@@ -201,6 +201,19 @@ where
menusUpd = diffItems [MenuStep:path] event (fromMaybe [] opts1.UIPanelOpts.tbar) (fromMaybe [] opts2.UIPanelOpts.tbar)
hotkeyUpd = diffHotkeys path (fromMaybe [] opts1.UIPanelOpts.hotkeys) (fromMaybe [] opts2.UIPanelOpts.hotkeys)
diffButtonOpts :: UIPath UIButtonOpts UIButtonOpts -> DiffResult
diffButtonOpts path b1 b2 = DiffPossible (flatten [textUpd,iconUpd,enabledUpd])
where
textUpd = if (b1.UIButtonOpts.text === b2.UIButtonOpts.text) [] [UIUpdate path (UISetText b2.UIButtonOpts.text)]
iconUpd = if (b1.UIButtonOpts.iconCls === b2.UIButtonOpts.iconCls) [] [UIUpdate path (UISetIconCls b2.UIButtonOpts.iconCls)]
enabledUpd = if (b1.UIButtonOpts.disabled === b2.UIButtonOpts.disabled) [] [UIUpdate path (UISetEnabled (not b2.UIButtonOpts.disabled))]
diffIconOpts :: UIPath UIIconOpts UIIconOpts -> DiffResult
diffIconOpts path i1 i2 = DiffPossible (flatten [iconUpd,tooltipUpd])
where
iconUpd = if (i1.UIIconOpts.iconCls === i2.UIIconOpts.iconCls) [] [UIUpdate path (UISetIconCls (Just i2.UIIconOpts.iconCls))]
tooltipUpd = if (i1.UIIconOpts.tooltip === i2.UIIconOpts.tooltip) [] [UIUpdate path (UISetTooltip i2.UIIconOpts.tooltip)]
diffItems :: UIPath Event [UIControl] [UIControl] -> [UIUpdate]
diffItems path event items1 items2 = diff path event 0 items1 items2
where
......@@ -269,6 +282,9 @@ encodeUIUpdateOperation (UISetName name) = ("setName", [JSONString name])
encodeUIUpdateOperation (UISetEnabled enabled) = ("setDisabled", [JSONBool (not enabled)])
encodeUIUpdateOperation (UISetActive active) = ("setActive", [JSONBool active])
encodeUIUpdateOperation (UISetTitle title) = ("setTitle", [toJSON title])
encodeUIUpdateOperation (UISetText text) = ("setText", [toJSON text])
encodeUIUpdateOperation (UISetIconCls cls) = ("setIconCls", [toJSON cls])
encodeUIUpdateOperation (UISetTooltip tip) = ("setTooltip", [toJSON tip])
encodeUIUpdateOperation (UISetHotkeys keys) = ("setHotkeys", [toJSON keys])
encodeUIUpdateOperation (UIReplace index def) = ("replace", [JSONInt index, encodeUIControl def])
encodeUIUpdateOperation (UISelfUpdate def) = ("selfUpdate", [encodeUIControl def])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment