Skip to content

Commit

Permalink
New Grid and Notification component and several styling and alignment…
Browse files Browse the repository at this point in the history
… bugfixes
  • Loading branch information
newk5 committed Apr 7, 2020
1 parent 3ebf010 commit b335d54
Show file tree
Hide file tree
Showing 19 changed files with 1,484 additions and 188 deletions.
48 changes: 48 additions & 0 deletions script/GridDemo.nut
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
local grid = UI.Grid({
id = "grid"
align = "top_center"
move = { down = "15%"}
rows =2
columns =4
margin = 5
cellWidth = 80
cellHeight = 80
borderStyle = {
color =::Colour(255,0,0)
size = 2
}
onHoverOverCell = function(cell){
cell.Colour = ::Colour(150,200,150);
}
onHoverOutCell = function(cell){
cell.Colour = ::Colour(0,0,0,0);
}
onCellClick = function(cell){
cell.Colour = ::Colour(150,150,200);
}

});

//adds components to the grid row by row
grid.add(
UI.Canvas({
id = "c"
Color = ::Colour(230,231,92,100)
})
)
grid.add(
UI.Canvas({
id = "c2"
Color = ::Colour(230,231,92,100)
})
)

//adds components to the grid in a specific cell
grid.put(
UI.Canvas({
id = "c3"
Color = ::Colour(10,231,92,100)
}),
1, //row
3 //column
)
32 changes: 32 additions & 0 deletions script/NotificationDemo.nut
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
UI.Notification({
id="not"
type = "info"
title = "INFORMATION"
time = 10 //seconds before it disappears
Size = VectorScreen(200, 90)
text = "HELLO"
autoSize = true
})
UI.Notification({
id="not2"
type = "success"
title = "SUCCESS"
time = 5
text = "HELLO"
})
UI.Notification({
id="not3"
type = "warning"
title = "WARNING"
time = 10
Size = VectorScreen(200, 90)
text = "HELLO"
})
UI.Notification({
id="not4"
type = "error"
title = "ERROR"
time = 10
Size = VectorScreen(200, 90)
text = "HELLO"
})
3 changes: 1 addition & 2 deletions script/TableDemo.nut
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ UI.Cursor("ON");
local t = UI.DataTable({
id="tbl",
contextMenu = {
type = "canvas"
options = [
{
name = "Delete",
color = Colour(255,0,0),
onClick = function() {
local row = this.data.row; //clicked row
// ::removeData(row);

UI.DataTable("tbl").removeRow(row);
}

Expand Down
2 changes: 1 addition & 1 deletion script/debug.nut
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
}


function errorHandling(err) {
function errorHandling(err) {
local stackInfos = getstackinfos(2);

if (stackInfos) {
Expand Down
1 change: 0 additions & 1 deletion script/decui/Timers.nut
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ Timer <- {
{
tm.CallCount++;
tm.LastCall = CurrTime;

tm.Listener.pacall(tm.Args);

if (tm.Repeat != 0 && tm.CallCount >= tm.Repeat)
Expand Down
61 changes: 36 additions & 25 deletions script/decui/UI/Events.nut
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
}

function onGameResize(){

foreach(i,list in this.UI.lists ) {
foreach(i,list in this.UI.lists ) {
foreach(c,e in list ) {
if (e.parents.len() == 0){

if (e.rawin("parents") && e.parents.len() == 0){

if (e.rawin("RelativeSize") && e.RelativeSize != null && e.RelativeSize.len() > 0){

Expand All @@ -25,6 +24,7 @@
}
e.updateBorders();


}else{

e.resetPosition();
Expand All @@ -33,7 +33,6 @@
e.shiftPos();
}


}

foreach (idx, child in e.getChildren() ){
Expand All @@ -45,16 +44,25 @@
if (child.rawin("onGameResize") && child.onGameResize != null){
child.onGameResize();
}
if (child.hidden){
child.hide();
}
if (child.hidden){
child.hidden = false; //after being realigned, the GUIElement is no longer hidden so we need to re-apply the hidden 'state'
child.hide();
}
}
if (e.rawin("onGameResize") && e.onGameResize != null){
e.onGameResize();
}

if (e.hidden){
e.hidden = false; //after being realigned, the GUIElement is no longer hidden so we need to re-apply the hidden 'state'
e.hide();
}

}






}
}
}
Expand Down Expand Up @@ -164,23 +172,26 @@
}

function onHoverOver(el){
if (el.rawin("metadata") && el.metadata != null){

this.UI.hoveredEl= { id =el.id, list = el.metadata.list };
try {
if (el.tooltip != null){
local isString = (typeof el.tooltip ) == "string";
local doesNotSpecifyEvent = isString ? true : !el.tooltip.rawin("event");
local eventIsNotFocus = !doesNotSpecifyEvent ? el.tooltip.event != "focus" : true;

if (isString || doesNotSpecifyEvent || eventIsNotFocus) {
el.showTooltip();
}
}
} catch(e){

this.UI.hoveredEl= { id =el.id, list = el.metadata.list };
try {
if (el.tooltip != null){
local isString = (typeof el.tooltip ) == "string";
local doesNotSpecifyEvent = isString ? true : !el.tooltip.rawin("event");
local eventIsNotFocus = !doesNotSpecifyEvent ? el.tooltip.event != "focus" : true;

if (isString || doesNotSpecifyEvent || eventIsNotFocus) {
el.showTooltip();
}
}
} catch(e){

}
if(el.onHoverOver!=null){
el.onHoverOver();
}
if(el.onHoverOver!=null){
el.onHoverOver();
}
}

}
Expand Down
Loading

0 comments on commit b335d54

Please sign in to comment.