Question

Could anyone help with Tizen Button construction problem?

I'm getting the following log message after Construct() call of Button and application crashed. But Construct() in this case returns E_SUCCESS:

result Tizen::Graphics::_Text::TextObject::SetBounds(const Tizen::Graphics::FloatRectangle&)(1134) > [E_OUT_OF_RANGE] The given rectangle(width:-4.000000,height:12.000000) is out of range.

In the following code:

MainSimpleButton::MainSimpleButton()
{
    result res = Construct(FloatRectangle(50, 50, 20, 20), String("Default button"));
    if (res != E_SUCCESS)
    {
        throw Exception("Failed Construct() button");
    }
}

Here is details. I have customized Button class:

#ifndef MAINBUTTON_H_
#define MAINBUTTON_H_

#include <FApp.h>
#include <FUi.h>
#include <FGraphics.h>

class MainSimpleButton : public Tizen::Ui::Controls::Button {
public:
    MainSimpleButton(); // <------- This constructor is used
    MainSimpleButton(const Tizen::Graphics::Rectangle &rect, const Tizen::Base::String &text);
    MainSimpleButton(const Tizen::Graphics::FloatRectangle &rect, const Tizen::Base::String &text);
    virtual ~MainSimpleButton();
};

#endif /* MAINBUTTON_H_ */

With the following simple implementation:

MainSimpleButton::MainSimpleButton()
{
    result res = Construct(FloatRectangle(50, 50, 20, 20), String("Default button"));
    if (res != E_SUCCESS)
    {
        throw Exception("Failed Construct() button");
    }
}

MainSimpleButton::MainSimpleButton(const Rectangle &rect, const String &text)
{ // Similar to MainSimpleButton }

MainSimpleButton::MainSimpleButton(const FloatRectangle &rect, const String &text)
{ // Similar to MainSimpleButton }

MainSimpleButton::~MainSimpleButton() {}

Add instance of this customized Button() is created here:

void MainForm::InitMainForm(unsigned long formStyle)
{
    if (Construct(formStyle) != E_SUCCESS) { throw Exception("MainForm Construct() failed"); }
    MainSimpleButton *btn1 = new MainSimpleButton(); // <----- This code
    if (AddControl(btn1) != E_SUCCESS)
    {
        throw Exception("MainForm AddControl() failed");
    }
}
Was it helpful?

Solution

General it's a Tizen Framework problem. Suggest you have UI application with one button. The application structure will be following:

UIApp : [ Frame : [ Form : [ Button ] ] ]

and the initialization call chain for this simple UI will be following:

OnAppInitializing():
    new Frame() => Frame.Construct() =>
    AddFrame(frame):
        Frame.OnInitializing():
            new Form() => Form.Construct() =>
            AddControl(form):
                Form.OnInitializing():
                    new Button() => Button.Construct() =>
                    AddControl(button):
                        Button.OnInitializing()

The reason for this: object constructor does nothing (as Tizen doesn't use exceptions) and the real job is done by Construct() method. We can get the same result by using custom objects which will use constructors and exception.

OnAppInitializing():
    new Frame():
        Frame.Construct()
        new Form():
            Form.Construct()
            new Button():
                Button.Construct()
            AddControl(button)
         AddControl(form)
     AddFrame(frame)

This is what I wanted to do.

In point of view of Tizen framework we should get the same result as before every AddFrame()/AddControl() function call we have valid chain new Object() => Object.Construct() => AddControl(Object).

But the problem, probably is that when on my phone I get the same result, log is different:

04-05 02:18:04.840 : ERROR / Tizen::Ui::Controls ( 16130 : 16130 ) : Tizen::Ui::Animations::_VisualElement* Tizen::Ui::Controls::_IndicatorManager::GetIndicatorVisualElement(Tizen::Ui::_Window*, Tizen::Ui::Controls::_IndicatorOrientation, Tizen::Ui::_Control*) const(132) > [E_SYSTEM] Unable to get Indicator
04-05 02:18:04.840 : ERROR / Tizen::Ui::Controls ( 16130 : 16130 ) : result Tizen::Ui::Controls::_Indicator::AddIndicatorObject(Tizen::Ui::_Control*, Tizen::Ui::_Window*)(373) > [E_SYSTEM] Indicator can not create the surface.
04-05 02:18:04.840 : ERROR / Tizen::Ui::Controls ( 16130 : 16130 ) : Tizen::Ui::Animations::_VisualElement* Tizen::Ui::Controls::_IndicatorManager::GetIndicatorVisualElement(Tizen::Ui::_Window*, Tizen::Ui::Controls::_IndicatorOrientation, Tizen::Ui::_Control*) const(132) > [E_SYSTEM] Unable to get Indicator
04-05 02:18:04.840 : ERROR / Tizen::Ui::Controls ( 16130 : 16130 ) : result Tizen::Ui::Controls::_Indicator::AddIndicatorObject(Tizen::Ui::_Control*, Tizen::Ui::_Window*)(373) > [E_SYSTEM] Indicator can not create the surface.
04-05 02:18:04.840 : ERROR / Tizen::Ui ( 16130 : 16130 ) : result Tizen::Ui::_Control::SetFocused(bool)(2634) > [E_INVALID_OPERATION] This control should have a parent or be attached to the main tree.

Thus I think Tizen Framework can doesn't support my approach very well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top