Skip to content

Commit 2d4a9dd

Browse files
committed
Make it work on android !
1 parent c150704 commit 2d4a9dd

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

modules/yup_gui/component/yup_Component.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,15 @@ void Component::moved()
148148

149149
void Component::setSize (const Size<float>& newSize)
150150
{
151-
boundsInParent = boundsInParent.withSize (newSize);
152-
153151
if (options.onDesktop)
154-
native->setSize (newSize.to<int>());
152+
{
153+
native->setSize(newSize.to<int>());
154+
boundsInParent = Rectangle<float>(0.0f, 0.0f, native->getSize().to<float>());
155+
}
156+
else
157+
{
158+
boundsInParent = boundsInParent.withSize (newSize);
159+
}
155160

156161
resized();
157162
}
@@ -184,10 +189,15 @@ float Component::getHeight() const
184189

185190
void Component::setBounds (const Rectangle<float>& newBounds)
186191
{
187-
boundsInParent = newBounds;
188-
189192
if (options.onDesktop)
190-
native->setBounds (newBounds.to<int>());
193+
{
194+
native->setBounds(newBounds.to<int>());
195+
boundsInParent = native->getBounds().to<float>();
196+
}
197+
else
198+
{
199+
boundsInParent = newBounds;
200+
}
191201

192202
resized();
193203
}

modules/yup_gui/native/yup_Windowing_glfw.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,9 +641,7 @@ void GLFWComponentNative::setVisible (bool shouldBeVisible)
641641

642642
bool GLFWComponentNative::isVisible() const
643643
{
644-
jassert (window != nullptr);
645-
646-
return false;
644+
return window != nullptr && glfwGetWindowAttrib (window, GLFW_VISIBLE) != 0;
647645
}
648646

649647
//==============================================================================
@@ -695,6 +693,10 @@ Rectangle<int> GLFWComponentNative::getBounds() const
695693

696694
void GLFWComponentNative::setBounds (const Rectangle<int>& newBounds)
697695
{
696+
#if JUCE_ANDROID
697+
screenBounds = Rectangle<int>(0, 0, getSize());
698+
699+
#else
698700
jassert (window != nullptr);
699701

700702
int leftMargin = 0, topMargin = 0, rightMargin = 0, bottomMargin = 0;
@@ -723,6 +725,8 @@ void GLFWComponentNative::setBounds (const Rectangle<int>& newBounds)
723725
glfwSetWindowPos (window, newBounds.getX() + leftMargin, newBounds.getY() + topMargin);
724726

725727
screenBounds = newBounds;
728+
729+
#endif
726730
}
727731

728732
//==============================================================================

0 commit comments

Comments
 (0)