diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlLayout.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlLayout.java index a9095e78f..671db9e3b 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlLayout.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlLayout.java @@ -4,6 +4,8 @@ import static net.kdt.pojavlaunch.MainActivity.mControlLayout; import static net.kdt.pojavlaunch.Tools.currentDisplayMetrics; +import static org.lwjgl.glfw.CallbackBridge.isGrabbing; + import android.annotation.SuppressLint; import android.content.Context; import android.os.Build; @@ -239,7 +241,7 @@ public void setControlVisible(boolean isVisible) { mControlVisible = isVisible; for(ControlInterface button : getButtonChildren()){ - button.setVisible(isVisible); + button.setVisible(((button.getProperties().displayInGame && isGrabbing()) || (button.getProperties().displayInMenu && !isGrabbing())) && isVisible); } } diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlButton.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlButton.java index 8ee81a853..d99ee6305 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlButton.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlButton.java @@ -80,11 +80,6 @@ public void setProperties(ControlData properties, boolean changePos) { setText(properties.name); } - public void setVisible(boolean isVisible){ - if(mProperties.isHideable) - setVisibility(isVisible ? VISIBLE : GONE); - } - @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlDrawer.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlDrawer.java index 8d63e8c42..cc022ea47 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlDrawer.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlDrawer.java @@ -2,6 +2,7 @@ import android.annotation.SuppressLint; import android.view.MotionEvent; +import android.view.View; import android.view.ViewGroup; import android.widget.Toast; @@ -46,13 +47,14 @@ public void addButton(ControlSubButton button){ } private void setControlButtonVisibility(ControlButton button, boolean isVisible){ - post(() -> button.setVisible(isVisible)); + button.getControlView().setVisibility(isVisible ? VISIBLE : GONE); } private void switchButtonVisibility(){ areButtonsVisible = !areButtonsVisible; + int visibility = areButtonsVisible ? VISIBLE : GONE; for(ControlButton button : buttons){ - button.setVisible(areButtonsVisible); + button.getControlView().setVisibility(visibility); } } @@ -129,7 +131,7 @@ public void setVisible(boolean isVisible) { setVisibility(visibility); if(visibility == GONE || areButtonsVisible) { for(ControlSubButton button : buttons){ - button.setVisible(isVisible); + button.getControlView().setVisibility(isVisible ? VISIBLE : (!mProperties.isHideable && getVisibility() == GONE) ? VISIBLE : View.GONE); } } } diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlInterface.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlInterface.java index 08673a77a..d979ac95d 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlInterface.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlInterface.java @@ -1,5 +1,7 @@ package net.kdt.pojavlaunch.customcontrols.buttons; +import static android.view.View.GONE; +import static android.view.View.VISIBLE; import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_BUTTONSIZE; import android.annotation.SuppressLint; @@ -49,7 +51,10 @@ default void setProperties(ControlData properties) { */ void cloneButton(); - void setVisible(boolean isVisible); + default void setVisible(boolean isVisible) { + if(getProperties().isHideable) + getControlView().setVisibility(isVisible ? VISIBLE : GONE); + } void sendKeyPresses(boolean isDown); diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlJoystick.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlJoystick.java index 57bc1931b..34c21c424 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlJoystick.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlJoystick.java @@ -89,6 +89,7 @@ public ControlData getProperties() { @Override public void setProperties(ControlData properties, boolean changePos) { mControlData = (ControlJoystickData) properties; + mControlData.isHideable = true; ControlInterface.super.setProperties(properties, changePos); postDelayed(() -> setForwardLockDistance(mControlData.forwardLock ? (int) Tools.dpToPx(60) : 0), 10); } @@ -105,10 +106,6 @@ public void cloneButton() { getControlLayoutParent().addJoystickButton((ControlJoystickData) data); } - @Override - public void setVisible(boolean isVisible) { - setVisibility(isVisible ? VISIBLE : GONE); - } @Override public void setBackground() { diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlSubButton.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlSubButton.java index 9a4380bec..fdb5cfc03 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlSubButton.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlSubButton.java @@ -33,7 +33,8 @@ private void filterProperties(){ @Override public void setVisible(boolean isVisible) { - setVisibility(isVisible ? VISIBLE : (!mProperties.isHideable && parentDrawer.getVisibility() == GONE) ? VISIBLE : View.GONE); + // STUB, visibility handled by the ControlDrawer + //setVisibility(isVisible ? VISIBLE : (!mProperties.isHideable && parentDrawer.getVisibility() == GONE) ? VISIBLE : View.GONE); } @Override @@ -92,6 +93,6 @@ public void snapAndAlign(float x, float y) { @Override public void loadEditValues(EditControlPopup editControlPopup) { - editControlPopup.loadSubButtonValues(getProperties()); + editControlPopup.loadSubButtonValues(getProperties(), parentDrawer.drawerData.orientation); } } diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/handleview/EditControlPopup.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/handleview/EditControlPopup.java index c39508842..3d799ecbc 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/handleview/EditControlPopup.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/handleview/EditControlPopup.java @@ -176,6 +176,11 @@ public void appearColor(boolean fromRight, int color) { } } + // Adjust the color selector to have the same size as the control settings + ViewGroup.LayoutParams params = mColorSelector.getRootView().getLayoutParams(); + params.height = mScrollView.getHeight(); + mColorSelector.getRootView().setLayoutParams(params); + mDisplayingColor = true; mColorSelector.show(color == -1 ? Color.WHITE : color); } @@ -351,14 +356,16 @@ public void loadJoystickValues(ControlJoystickData data) { /** * Load values for sub buttons */ - public void loadSubButtonValues(ControlData data) { + public void loadSubButtonValues(ControlData data, ControlDrawerData.Orientation drawerOrientation) { loadValues(data); - // Size linked to the parent drawer - mSizeTextview.setVisibility(GONE); - mSizeXTextView.setVisibility(GONE); - mWidthEditText.setVisibility(GONE); - mHeightEditText.setVisibility(GONE); + // Size linked to the parent drawer depending on the drawer settings + if(drawerOrientation != ControlDrawerData.Orientation.FREE){ + mSizeTextview.setVisibility(GONE); + mSizeXTextView.setVisibility(GONE); + mWidthEditText.setVisibility(GONE); + mHeightEditText.setVisibility(GONE); + } // No conditional, already depends on the parent drawer visibility mVisibilityTextView.setVisibility(GONE); diff --git a/app_pojavlauncher/src/main/res/layout/dialog_color_selector.xml b/app_pojavlauncher/src/main/res/layout/dialog_color_selector.xml index a3c69156a..dccb2e998 100644 --- a/app_pojavlauncher/src/main/res/layout/dialog_color_selector.xml +++ b/app_pojavlauncher/src/main/res/layout/dialog_color_selector.xml @@ -9,7 +9,9 @@ android:paddingHorizontal="@dimen/padding_moderate" android:paddingVertical="@dimen/padding_moderate" android:id="@+id/color_picker_layout" - android:layout_marginVertical="@dimen/padding_heavy"> + android:layout_marginVertical="@dimen/padding_heavy" + android:layout_gravity="center_vertical" + > + android:background="@drawable/background_control_editor" + android:layout_gravity="center_vertical" + >