forked from google/blockly-android
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'surinder83singh-juggaar'
- Loading branch information
Showing
8 changed files
with
139 additions
and
88 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
61 changes: 61 additions & 0 deletions
61
blocklylib-core/src/main/java/com/google/blockly/android/ZoomBehavior.java
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,61 @@ | ||
package com.google.blockly.android; | ||
|
||
import android.content.Context; | ||
import android.content.res.TypedArray; | ||
|
||
/** | ||
* Created by Surinder Singh ([email protected]) on 09/12/16. | ||
*/ | ||
public final class ZoomBehavior { | ||
|
||
//no scrollbar, no zoom, no buttons | ||
public static final int BEHAVIOR_FIXED = 1; | ||
//only scrollable, no buttons, no zoom | ||
public static final int BEHAVIOR_SCROLL_ONLY = 2; | ||
//scrollable, zoomable with buttons, zoom-in/out buttons | ||
public static final int BEHAVIOR_BUTTONS_ONLY = 3; | ||
//scrollable, zoomable, no buttons | ||
public static final int BEHAVIOR_ZOOM_ONLY = 4; | ||
//scrollable, zoomable, zoom-in/out buttons | ||
public static final int BEHAVIOR_ZOOM_AND_BUTTONS = 5; | ||
|
||
public static final int DEFAULT_BEHAVIOR = BEHAVIOR_ZOOM_AND_BUTTONS; | ||
|
||
private int mBehavior = DEFAULT_BEHAVIOR; | ||
|
||
|
||
public ZoomBehavior(Context context) { | ||
TypedArray a = context.getTheme().obtainStyledAttributes( | ||
null, | ||
R.styleable.BlocklyWorkspaceTheme, | ||
0, 0); | ||
try { | ||
mBehavior = | ||
a.getInt(R.styleable.BlocklyWorkspaceTheme_zoomBehavior, DEFAULT_BEHAVIOR); | ||
} finally { | ||
a.recycle(); | ||
} | ||
} | ||
|
||
/** | ||
* @return true if zoom-in/out buttons are enabled | ||
*/ | ||
public boolean isButtonEnabled(){ | ||
return (mBehavior == BEHAVIOR_BUTTONS_ONLY || mBehavior == BEHAVIOR_ZOOM_AND_BUTTONS); | ||
} | ||
|
||
/** | ||
* @return true if workspace is scrollable | ||
*/ | ||
public boolean isScrollEnabled(){ | ||
return mBehavior > BEHAVIOR_FIXED; | ||
} | ||
|
||
/** | ||
* @return true if workspace scalable using touch/pinch events | ||
*/ | ||
public boolean isPinchZoomEnabled(){ | ||
return mBehavior > BEHAVIOR_BUTTONS_ONLY; | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.