fix trouble in visible state of layer children + update layer adn layout tests 47/13847/3
Antoine ELIAS [Wed, 26 Feb 2014 16:13:16 +0000 (17:13 +0100)]
Change-Id: Idf61257f3d18ce0accf2b325807978c291942c86

scilab/modules/graphics/tests/unit_tests/layout.dia.ref
scilab/modules/graphics/tests/unit_tests/layout.tst
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/frame/SwingScilabLayer.java
scilab/modules/gui/tests/unit_tests/layer.dia.ref
scilab/modules/gui/tests/unit_tests/layer.tst

index 0634598..5561789 100644 (file)
@@ -6,59 +6,69 @@
 // =============================================================================
 // <-- TEST WITH GRAPHIC -->
 function fig = createFigure(layout)
-    fig = scf();
+    fig = figure("dockable", "off" ,"infobar_visible", "off", "toolbar_visible", "off", "menubar_visible", "off", "default_axes", "off")
     fig.layout = layout;
-    fig.toolbar_visible = "off";
-    fig.menubar_visible = "off";
-    fig.infobar_visible = "off";
 endfunction
 //constraints
 //no border
 createFigure("none");
 c = createConstraints("nolayout");
-u = uicontrol("constraints", c);
+u = uicontrol("constraints", c, "string", "button", "position", [10 10 100 30]);
 assert_checkequal(u.constraints, c);
 delete(gcf());
 //border layout
 createFigure("border");
 c = createConstraints("border", "center");
-u = uicontrol("constraints", c, "string", "center");
+u = uicontrol("constraints", c, "string", "center [-1 -1]");
 assert_checkequal(u.constraints, c);
-c = createConstraints("border", "left");
-u = uicontrol("constraints", c, "string", "left");
+c = createConstraints("border", "left", [150 150]);
+u = uicontrol("constraints", c, "string", "left [150 150]");
 assert_checkequal(u.constraints, c);
-c = createConstraints("border", "right");
-u = uicontrol("constraints", c, "string", "right");
+c = createConstraints("border", "right", [250 250]);
+u = uicontrol("constraints", c, "string", "right [250 250]");
 assert_checkequal(u.constraints, c);
-c = createConstraints("border", "top");
-u = uicontrol("constraints", c, "string", "top");
+c = createConstraints("border", "top", [50 50]);
+u = uicontrol("constraints", c, "string", "top [50 50]");
 assert_checkequal(u.constraints, c);
-c = createConstraints("border", "bottom");
-u = uicontrol("constraints", c, "string", "bottom");
+c = createConstraints("border", "bottom", [100, 100]);
+u = uicontrol("constraints", c, "string", "bottom [100 100]");
 assert_checkequal(u.constraints, c);
 delete(gcf());
 //grid layout
-createFigure("grid");
-c = createConstraints("grid");
-u = uicontrol("constraints", c);
-assert_checkequal(u.constraints, c);
+f = createFigure("grid");
+f.layout_options = createLayoutOptions("grid", [3 4], [10 10]);
+uicontrol("constraints", c, "string", "11");
+uicontrol("constraints", c, "string", "12");
+uicontrol("constraints", c, "string", "13");
+uicontrol("constraints", c, "string", "14");
+uicontrol("constraints", c, "string", "21");
+uicontrol("constraints", c, "string", "22");
+uicontrol("constraints", c, "string", "23");
+uicontrol("constraints", c, "string", "24");
+uicontrol("constraints", c, "string", "31");
+uicontrol("constraints", c, "string", "32");
+uicontrol("constraints", c, "string", "33");
+uicontrol("constraints", c, "string", "34");
 delete(gcf());
 //gridbag layout
-createFigure("gridbag");
-c = createConstraints("gridbag", [1 2 3 4]);
-u = uicontrol("constraints", c);
+f = createFigure("gridbag");
+c = createConstraints("gridbag", [1 1 1 1]);
+u = uicontrol("constraints", c, "string", "text1");
+assert_checkequal(u.constraints, c);
+c = createConstraints("gridbag", [2 1 1 1], [1.0 1.0]);
+u = uicontrol("constraints", c, "string", "text2");
 assert_checkequal(u.constraints, c);
-c = createConstraints("gridbag", [1 2 3 4], [1.1 2.1]);
-u = uicontrol("constraints", c);
+c = createConstraints("gridbag", [1 2 2 1], [1.0 1.0], "vertical");
+u = uicontrol("constraints", c, "string", "text3");
 assert_checkequal(u.constraints, c);
-c = createConstraints("gridbag", [1 2 3 4], [1.1 2.1], "both");
-u = uicontrol("constraints", c);
+c = createConstraints("gridbag", [3 1 1 2], [1.0 1.0], "both", "lower_left", [0 0]);
+u = uicontrol("constraints", c, "string", "text4");
 assert_checkequal(u.constraints, c);
-c = createConstraints("gridbag", [1 2 3 4], [1.1 2.1], "both", "lower_left");
-u = uicontrol("constraints", c);
+c = createConstraints("gridbag", [1 4 3 2], [1.0 1.0], "both", "center", [0 0], [-1 -1]);
+u = uicontrol("constraints", c, "string", "text5");
 assert_checkequal(u.constraints, c);
-c = createConstraints("gridbag", [1 2 3 4], [1.1 2.1], "both", "lower_left", [10 20]);
-u = uicontrol("constraints", c);
+c = createConstraints("gridbag", [1 6 3 2], [1.0 1.0], "both", "center", [0 0], [200 200]);
+u = uicontrol("constraints", c, "string", "text6");
 assert_checkequal(u.constraints, c);
 delete(gcf());
 // options
@@ -83,8 +93,8 @@ delete(gcf());
 createFigure("grid");
 f = gcf();
 assert_checkequal(f.layout_options, createLayoutOptions("grid"));
-f.layout_options = createLayoutOptions("grid", [30,40]);
-assert_checkequal(f.layout_options, createLayoutOptions("grid", [30,40]));
-f.layout_options = createLayoutOptions("grid", [10,20], [30,40]);
-assert_checkequal(f.layout_options, createLayoutOptions("grid", [10,20], [30,40]));
+f.layout_options = createLayoutOptions("grid", [5,3]);
+assert_checkequal(f.layout_options, createLayoutOptions("grid", [5,3]));
+f.layout_options = createLayoutOptions("grid", [5,3], [30,40]);
+assert_checkequal(f.layout_options, createLayoutOptions("grid", [5,3], [30,40]));
 delete(gcf());
index 5d19be3..f6d5c39 100644 (file)
@@ -9,11 +9,8 @@
 
 
 function fig = createFigure(layout)
-    fig = scf();
+    fig = figure("dockable", "off" ,"infobar_visible", "off", "toolbar_visible", "off", "menubar_visible", "off", "default_axes", "off")
     fig.layout = layout;
-    fig.toolbar_visible = "off";
-    fig.menubar_visible = "off";
-    fig.infobar_visible = "off";
 endfunction
 
 //constraints
@@ -22,7 +19,7 @@ endfunction
 createFigure("none");
 
 c = createConstraints("nolayout");
-u = uicontrol("constraints", c);
+u = uicontrol("constraints", c, "string", "button", "position", [10 10 100 30]);
 assert_checkequal(u.constraints, c);
 
 delete(gcf());
@@ -31,57 +28,70 @@ delete(gcf());
 createFigure("border");
 
 c = createConstraints("border", "center");
-u = uicontrol("constraints", c, "string", "center");
+u = uicontrol("constraints", c, "string", "center [-1 -1]");
 assert_checkequal(u.constraints, c);
 
-c = createConstraints("border", "left");
-u = uicontrol("constraints", c, "string", "left");
+c = createConstraints("border", "left", [150 150]);
+u = uicontrol("constraints", c, "string", "left [150 150]");
 assert_checkequal(u.constraints, c);
 
-c = createConstraints("border", "right");
-u = uicontrol("constraints", c, "string", "right");
+c = createConstraints("border", "right", [250 250]);
+u = uicontrol("constraints", c, "string", "right [250 250]");
 assert_checkequal(u.constraints, c);
 
-c = createConstraints("border", "top");
-u = uicontrol("constraints", c, "string", "top");
+c = createConstraints("border", "top", [50 50]);
+u = uicontrol("constraints", c, "string", "top [50 50]");
 assert_checkequal(u.constraints, c);
 
-c = createConstraints("border", "bottom");
-u = uicontrol("constraints", c, "string", "bottom");
+c = createConstraints("border", "bottom", [100, 100]);
+u = uicontrol("constraints", c, "string", "bottom [100 100]");
 assert_checkequal(u.constraints, c);
 
 delete(gcf());
 
 //grid layout
-createFigure("grid");
-
-c = createConstraints("grid");
-u = uicontrol("constraints", c);
-assert_checkequal(u.constraints, c);
+f = createFigure("grid");
+f.layout_options = createLayoutOptions("grid", [3 4], [10 10]);
+uicontrol("constraints", c, "string", "11");
+uicontrol("constraints", c, "string", "12");
+uicontrol("constraints", c, "string", "13");
+uicontrol("constraints", c, "string", "14");
+uicontrol("constraints", c, "string", "21");
+uicontrol("constraints", c, "string", "22");
+uicontrol("constraints", c, "string", "23");
+uicontrol("constraints", c, "string", "24");
+uicontrol("constraints", c, "string", "31");
+uicontrol("constraints", c, "string", "32");
+uicontrol("constraints", c, "string", "33");
+uicontrol("constraints", c, "string", "34");
 
 delete(gcf());
 
 //gridbag layout
-createFigure("gridbag");
+f = createFigure("gridbag");
+
+c = createConstraints("gridbag", [1 1 1 1]);
+u = uicontrol("constraints", c, "string", "text1");
+assert_checkequal(u.constraints, c);
 
-c = createConstraints("gridbag", [1 2 3 4]);
-u = uicontrol("constraints", c);
+c = createConstraints("gridbag", [2 1 1 1], [1.0 1.0]);
+u = uicontrol("constraints", c, "string", "text2");
 assert_checkequal(u.constraints, c);
 
-c = createConstraints("gridbag", [1 2 3 4], [1.1 2.1]);
-u = uicontrol("constraints", c);
+c = createConstraints("gridbag", [1 2 2 1], [1.0 1.0], "vertical");
+u = uicontrol("constraints", c, "string", "text3");
 assert_checkequal(u.constraints, c);
 
-c = createConstraints("gridbag", [1 2 3 4], [1.1 2.1], "both");
-u = uicontrol("constraints", c);
+c = createConstraints("gridbag", [3 1 1 2], [1.0 1.0], "both", "lower_left", [0 0]);
+u = uicontrol("constraints", c, "string", "text4");
 assert_checkequal(u.constraints, c);
 
-c = createConstraints("gridbag", [1 2 3 4], [1.1 2.1], "both", "lower_left");
-u = uicontrol("constraints", c);
+c = createConstraints("gridbag", [1 4 3 2], [1.0 1.0], "both", "center", [0 0], [-1 -1]);
+u = uicontrol("constraints", c, "string", "text5");
 assert_checkequal(u.constraints, c);
 
-c = createConstraints("gridbag", [1 2 3 4], [1.1 2.1], "both", "lower_left", [10 20]);
-u = uicontrol("constraints", c);
+c = createConstraints("gridbag", [1 6 3 2], [1.0 1.0], "both", "center", [0 0], [200 200]);
+u = uicontrol("constraints", c, "string", "text6");
 assert_checkequal(u.constraints, c);
 
 delete(gcf());
@@ -114,10 +124,10 @@ createFigure("grid");
 f = gcf();
 assert_checkequal(f.layout_options, createLayoutOptions("grid"));
 
-f.layout_options = createLayoutOptions("grid", [30,40]);
-assert_checkequal(f.layout_options, createLayoutOptions("grid", [30,40]));
+f.layout_options = createLayoutOptions("grid", [5,3]);
+assert_checkequal(f.layout_options, createLayoutOptions("grid", [5,3]));
 
-f.layout_options = createLayoutOptions("grid", [10,20], [30,40]);
-assert_checkequal(f.layout_options, createLayoutOptions("grid", [10,20], [30,40]));
+f.layout_options = createLayoutOptions("grid", [5,3], [30,40]);
+assert_checkequal(f.layout_options, createLayoutOptions("grid", [5,3], [30,40]));
 delete(gcf());
 
index 0dd17a5..e8b113d 100644 (file)
@@ -86,11 +86,12 @@ public class SwingScilabLayer extends SwingScilabFrame {
 
     public Boolean isLayerActive(Component layer) {
         Integer index = getLayerIndex(layer);
+        System.out.println("isLayerActive : " + index);
         if (index == -1) {
             return false;
         }
 
-        return isLayerActive(index);
+        return isLayerActive(getComponentCount() - (index - 1));
     }
 
 
@@ -163,12 +164,16 @@ public class SwingScilabLayer extends SwingScilabFrame {
         SwingViewObject previousFrame = (SwingViewObject)getLayerFromIndex(previous);
         SwingViewObject nextFrame = (SwingViewObject) getLayerFromIndex(next);
 
+        System.out.println("previous : " + previous);
+        System.out.println("next : " + next);
         String name = null;
         if (previousFrame != null) {
+            System.out.println("visible false : " + previousFrame.getId());
             GraphicController.getController().setProperty(previousFrame.getId(), __GO_VISIBLE__, false);
         }
 
         if (nextFrame != null) {
+            System.out.println("visible true : " + nextFrame.getId());
             GraphicController.getController().setProperty(nextFrame.getId(), __GO_VISIBLE__, true);
             name = (String)GraphicController.getController().getProperty(nextFrame.getId(), __GO_TAG__);
         }
index b1f8cc9..1aaa568 100644 (file)
@@ -34,10 +34,10 @@ assert_checkequal(layer.children.visible, visible1);
 //4 layers
 delete(gcf());
 layer = create_layer(4);
-visible1 = ['off' 'off' 'off' 'on'];
-visible2 = ['off' 'off' 'on' 'off'];
-visible3 = ['off' 'on' 'off' 'off'];
-visible4 = ['on' 'off' 'off' 'off'];
+visible1 = ['on' 'off' 'off' 'off'];
+visible2 = ['off' 'on' 'off' 'off'];
+visible3 = ['off' 'off' 'on' 'off'];
+visible4 = ['off' 'off' 'off' 'on'];
 assert_checkequal(layer.value, 1);
 assert_checkequal(layer.children.visible, visible1);
 layer.value = 2;
index 29e5636..4c046eb 100644 (file)
@@ -43,10 +43,10 @@ assert_checkequal(layer.children.visible, visible1);
 delete(gcf());
 layer = create_layer(4);
 
-visible1 = ['off' 'off' 'off' 'on'];
-visible2 = ['off' 'off' 'on' 'off'];
-visible3 = ['off' 'on' 'off' 'off'];
-visible4 = ['on' 'off' 'off' 'off'];
+visible1 = ['on' 'off' 'off' 'off'];
+visible2 = ['off' 'on' 'off' 'off'];
+visible3 = ['off' 'off' 'on' 'off'];
+visible4 = ['off' 'off' 'off' 'on'];
 
 assert_checkequal(layer.value, 1);
 assert_checkequal(layer.children.visible, visible1);