Add center view button.

This commit is contained in:
kenkeiras 2018-01-20 22:08:08 +01:00
parent 826f32beca
commit f821f49b94
8 changed files with 25 additions and 1 deletions

View File

@ -469,8 +469,13 @@ class CanvasView extends View implements PartGrid {
public void setDevMode(boolean devMode) { public void setDevMode(boolean devMode) {
_devMode = devMode; _devMode = devMode;
if (!_devMode) { if (!_devMode) {
this._viewOrigin = new Tuple2<>(0, 0); CenterView();
} }
this.invalidate(); this.invalidate();
} }
public void CenterView() {
this._viewOrigin = new Tuple2<>(0, 0);
this.invalidate();
}
} }

View File

@ -18,6 +18,7 @@ public class MainActivity extends AppCompatActivity {
com.getbase.floatingactionbutton.AddFloatingActionButton AddPartButton; com.getbase.floatingactionbutton.AddFloatingActionButton AddPartButton;
com.getbase.floatingactionbutton.FloatingActionButton SetDevModeButton; com.getbase.floatingactionbutton.FloatingActionButton SetDevModeButton;
com.getbase.floatingactionbutton.FloatingActionButton SetUserModeButton; com.getbase.floatingactionbutton.FloatingActionButton SetUserModeButton;
com.getbase.floatingactionbutton.FloatingActionButton CenterViewButton;
com.getbase.floatingactionbutton.FloatingActionsMenu devFabMenu; com.getbase.floatingactionbutton.FloatingActionsMenu devFabMenu;
com.getbase.floatingactionbutton.FloatingActionsMenu userFabMenu; com.getbase.floatingactionbutton.FloatingActionsMenu userFabMenu;
@ -73,6 +74,15 @@ public class MainActivity extends AppCompatActivity {
} }
}); });
CenterViewButton = (com.getbase.floatingactionbutton.FloatingActionButton)
findViewById(R.id.center_view_button);
CenterViewButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
canvasView.CenterView();
}
});
SetDevModeButton = (com.getbase.floatingactionbutton.FloatingActionButton) SetDevModeButton = (com.getbase.floatingactionbutton.FloatingActionButton)
findViewById(R.id.set_developer_mode_button); findViewById(R.id.set_developer_mode_button);
SetDevModeButton.setOnClickListener(new View.OnClickListener() { SetDevModeButton.setOnClickListener(new View.OnClickListener() {

Binary file not shown.

After

Width:  |  Height:  |  Size: 504 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 341 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 659 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 995 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -93,6 +93,15 @@
fab:fab_title="Add new part" fab:fab_title="Add new part"
fab:fab_colorPressed="@color/white_pressed"/> fab:fab_colorPressed="@color/white_pressed"/>
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/center_view_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_icon="@drawable/ic_center_focus_weak_black"
fab:fab_colorNormal="@color/white"
fab:fab_title="Center view"
fab:fab_colorPressed="@color/white_pressed" />
<com.getbase.floatingactionbutton.FloatingActionButton <com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/set_user_mode_button" android:id="@+id/set_user_mode_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"