Commit 54fb1a33 authored by halatmit's avatar halatmit

change visibility property editor from a chackbox to a dropdown

parent c157e77e
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
package com.google.appinventor.client.editor.youngandroid.palette; package com.google.appinventor.client.editor.youngandroid.palette;
import com.google.appinventor.client.Ode; import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import com.google.appinventor.client.editor.simple.SimpleComponentDatabase; import com.google.appinventor.client.editor.simple.SimpleComponentDatabase;
import com.google.appinventor.client.editor.simple.components.MockComponent; import com.google.appinventor.client.editor.simple.components.MockComponent;
import com.google.appinventor.client.editor.simple.palette.DropTargetProvider; import com.google.appinventor.client.editor.simple.palette.DropTargetProvider;
...@@ -21,6 +24,7 @@ import com.google.appinventor.client.editor.youngandroid.properties.YoungAndroid ...@@ -21,6 +24,7 @@ import com.google.appinventor.client.editor.youngandroid.properties.YoungAndroid
import com.google.appinventor.client.editor.youngandroid.properties.YoungAndroidScreenOrientationChoicePropertyEditor; import com.google.appinventor.client.editor.youngandroid.properties.YoungAndroidScreenOrientationChoicePropertyEditor;
import com.google.appinventor.client.editor.youngandroid.properties.YoungAndroidSensorDistIntervalChoicePropertyEditor; import com.google.appinventor.client.editor.youngandroid.properties.YoungAndroidSensorDistIntervalChoicePropertyEditor;
import com.google.appinventor.client.editor.youngandroid.properties.YoungAndroidSensorTimeIntervalChoicePropertyEditor; import com.google.appinventor.client.editor.youngandroid.properties.YoungAndroidSensorTimeIntervalChoicePropertyEditor;
import com.google.appinventor.client.editor.youngandroid.properties.YoungAndroidVisibilityChoicePropertyEditor;
import com.google.appinventor.client.widgets.properties.FloatPropertyEditor; import com.google.appinventor.client.widgets.properties.FloatPropertyEditor;
import com.google.appinventor.client.widgets.properties.IntegerPropertyEditor; import com.google.appinventor.client.widgets.properties.IntegerPropertyEditor;
import com.google.appinventor.client.widgets.properties.NonNegativeFloatPropertyEditor; import com.google.appinventor.client.widgets.properties.NonNegativeFloatPropertyEditor;
...@@ -36,10 +40,6 @@ import com.google.gwt.user.client.ui.Composite; ...@@ -36,10 +40,6 @@ import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.StackPanel; import com.google.gwt.user.client.ui.StackPanel;
import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.VerticalPanel;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/** /**
* Panel showing Simple components which can be dropped onto the Young Android * Panel showing Simple components which can be dropped onto the Young Android
* visual designer panel. * visual designer panel.
...@@ -180,6 +180,8 @@ public class YoungAndroidPalettePanel extends Composite implements SimplePalette ...@@ -180,6 +180,8 @@ public class YoungAndroidPalettePanel extends Composite implements SimplePalette
return new YoungAndroidAlignmentChoicePropertyEditor(); return new YoungAndroidAlignmentChoicePropertyEditor();
} else if (editorType.equals(PropertyTypeConstants.PROPERTY_TYPE_TYPEFACE)) { } else if (editorType.equals(PropertyTypeConstants.PROPERTY_TYPE_TYPEFACE)) {
return new YoungAndroidFontTypefaceChoicePropertyEditor(); return new YoungAndroidFontTypefaceChoicePropertyEditor();
} else if (editorType.equals(PropertyTypeConstants.PROPERTY_TYPE_VISIBILITY)) {
return new YoungAndroidVisibilityChoicePropertyEditor();
} else { } else {
return new TextPropertyEditor(); return new TextPropertyEditor();
} }
......
// Copyright 2012 MIT. All Rights Reserved.
package com.google.appinventor.client.editor.youngandroid.properties;
import com.google.appinventor.client.widgets.properties.ChoicePropertyEditor;
/**
* Property editor for visibility: selects showing or hidden
*
* @author hal@mit.edu (Hal Abelson)
*/
public class YoungAndroidVisibilityChoicePropertyEditor extends ChoicePropertyEditor {
//TODO(hal): The values must be True and False. Losercase true and fale do not work here:
// they are not transformed from strings to booleans when passed to the property.
// Figure out why not.
private static final Choice[] visibility = new Choice[] {
new Choice("showing", "True"),
new Choice("hidden", "False"),
};
public YoungAndroidVisibilityChoicePropertyEditor() {
super(visibility);
}
}
...@@ -131,4 +131,10 @@ public class PropertyTypeConstants { ...@@ -131,4 +131,10 @@ public class PropertyTypeConstants {
* com.google.appinventor.client.editor.youngandroid.properties.YoungAndroidFontTypefaceChoicePropertyEditor}. * com.google.appinventor.client.editor.youngandroid.properties.YoungAndroidFontTypefaceChoicePropertyEditor}.
*/ */
public static final String PROPERTY_TYPE_TYPEFACE = "typeface"; public static final String PROPERTY_TYPE_TYPEFACE = "typeface";
/**
* Choices of visibility for view components offered by {@link
* com.google.appinventor.client.editor.youngandroid.properties.YoungAndroidVisibilityChoicePropertyEditor}.
*/
public static final String PROPERTY_TYPE_VISIBILITY = "visibility";
} }
...@@ -47,22 +47,25 @@ public abstract class AndroidViewComponent extends VisibleComponent { ...@@ -47,22 +47,25 @@ public abstract class AndroidViewComponent extends VisibleComponent {
* Returns true iff the component is visible. * Returns true iff the component is visible.
* @return true iff the component is visible * @return true iff the component is visible
*/ */
@SimpleProperty(description = "Whether the component is visible", @SimpleProperty(
category = PropertyCategory.APPEARANCE) category = PropertyCategory.APPEARANCE)
public boolean Visible() { public boolean Visible() {
return getView().getVisibility() == View.VISIBLE; return getView().getVisibility() == View.VISIBLE;
} }
/** /**
* Specifies whether the component should be visible * Specifies whether the component should be visible on the screen. Value is true if the
* component is showing and false if hidden.
* @param visible desired state * @param visible desired state
*/ */
@DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_BOOLEAN, defaultValue = "True") @DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_VISIBILITY,
@SimpleProperty defaultValue = "True")
public void Visible(boolean visible) { @SimpleProperty(description = "Specifies whether the component should be visible on the screen. "
+ "Value is true if the component is showing and false if hidden.")
public void Visible(Boolean visibility) {
// The principle of least astonishment suggests we not offer the // The principle of least astonishment suggests we not offer the
// Android option INVISIBLE. // Android option INVISIBLE.
getView().setVisibility(visible ? View.VISIBLE : View.GONE); getView().setVisibility(visibility ? View.VISIBLE : View.GONE);
} }
/** /**
......
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