Skip to content

Commit 0adf154

Browse files
committed
efl: Proper Iup.Fixed container, fix layout/positioning
1 parent 6742ee4 commit 0adf154

5 files changed

Lines changed: 94 additions & 73 deletions

File tree

iup/external/src/efl/iupefl_button.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,20 @@ static void eflButtonComputeNaturalSizeMethod(Ihandle* ih, int* w, int* h, int*
470470

471471
(void)children_expand;
472472

473+
if (!ih->handle)
474+
{
475+
char* value = iupAttribGet(ih, "IMAGE");
476+
if (value)
477+
{
478+
char* title = iupAttribGet(ih, "TITLE");
479+
type = IUP_BUTTON_IMAGE;
480+
if (title && *title != 0)
481+
type |= IUP_BUTTON_TEXT;
482+
}
483+
else
484+
type = IUP_BUTTON_TEXT;
485+
}
486+
473487
if (type & IUP_BUTTON_IMAGE)
474488
{
475489
iupImageGetInfo(iupAttribGet(ih, "IMAGE"), &natural_w, &natural_h, NULL);

iup/external/src/efl/iupefl_common.c

Lines changed: 27 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,11 @@ IUP_DRV_API char* iupeflBaseGetActiveAttrib(Ihandle* ih)
133133

134134
IUP_DRV_API void iupeflSetPosSize(Ihandle* ih, int x, int y, int width, int height)
135135
{
136-
Eo* widget = iupeflGetWidget(ih);
136+
Eo* widget = (Eo*)iupAttribGet(ih, "_IUP_EXTRAPARENT");
137137
Eo* bg_rect;
138+
139+
if (!widget)
140+
widget = iupeflGetWidget(ih);
138141
Ihandle* parent;
139142
int abs_x, abs_y;
140143

@@ -240,18 +243,30 @@ IUP_DRV_API unsigned int iupeflGetDefaultSeat(Eo* widget)
240243

241244
/****************************************************************************
242245
* Fixed Container (for absolute positioning)
246+
*
247+
* Concrete Efl.Ui.Widget subclass with no layout logic. Children stay
248+
* exactly where IUP positions them, no automatic layout interference.
243249
****************************************************************************/
244250

251+
static const Efl_Class_Description _iup_fixed_class_desc = {
252+
EO_VERSION,
253+
"Iup.Fixed",
254+
EFL_CLASS_TYPE_REGULAR,
255+
0, NULL, NULL, NULL
256+
};
257+
258+
EFL_DEFINE_CLASS(iupefl_fixed_class_get, &_iup_fixed_class_desc, EFL_UI_WIDGET_CLASS, NULL)
259+
245260
IUP_DRV_API Eo* iupeflFixedContainerNew(Eo* parent)
246261
{
247-
Eo* box = efl_add(EFL_UI_BOX_CLASS, parent);
248-
if (!box)
262+
Eo* fixed = efl_add(iupefl_fixed_class_get(), parent);
263+
if (!fixed)
249264
return NULL;
250265

251-
efl_gfx_hint_weight_set(box, EFL_GFX_HINT_EXPAND, EFL_GFX_HINT_EXPAND);
252-
efl_gfx_hint_align_set(box, -1.0, -1.0);
266+
efl_gfx_hint_weight_set(fixed, EFL_GFX_HINT_EXPAND, EFL_GFX_HINT_EXPAND);
267+
efl_gfx_hint_align_set(fixed, -1.0, -1.0);
253268

254-
return box;
269+
return fixed;
255270
}
256271

257272
IUP_DRV_API void iupeflFixedContainerMove(Eo* container, Eo* child, int x, int y)
@@ -262,14 +277,14 @@ IUP_DRV_API void iupeflFixedContainerMove(Eo* container, Eo* child, int x, int y
262277

263278
IUP_DRV_API Eo* iupeflNativeContainerNew(Eo* parent)
264279
{
265-
Eo* box = efl_add(EFL_UI_BOX_CLASS, parent);
266-
if (!box)
280+
Eo* fixed = efl_add(iupefl_fixed_class_get(), parent);
281+
if (!fixed)
267282
return NULL;
268283

269-
efl_gfx_hint_weight_set(box, EFL_GFX_HINT_EXPAND, EFL_GFX_HINT_EXPAND);
270-
efl_gfx_hint_align_set(box, -1.0, -1.0);
284+
efl_gfx_hint_weight_set(fixed, EFL_GFX_HINT_EXPAND, EFL_GFX_HINT_EXPAND);
285+
efl_gfx_hint_align_set(fixed, -1.0, -1.0);
271286

272-
return box;
287+
return fixed;
273288
}
274289

275290
/****************************************************************************
@@ -679,26 +694,6 @@ IUP_SDK_API void iupdrvReparent(Ihandle* ih)
679694
(void)ih;
680695
}
681696

682-
static void eflGetAbsolutePosition(Ihandle* ih, int* abs_x, int* abs_y)
683-
{
684-
int x = ih->x;
685-
int y = ih->y;
686-
Ihandle* parent = ih->parent;
687-
688-
while (parent)
689-
{
690-
if (parent->iclass->nativetype != IUP_TYPEVOID)
691-
{
692-
x += parent->x;
693-
y += parent->y;
694-
}
695-
parent = parent->parent;
696-
}
697-
698-
*abs_x = x;
699-
*abs_y = y;
700-
}
701-
702697
IUP_DRV_API int iupeflIsInsideTabs(Ihandle* ih)
703698
{
704699
Ihandle* parent = ih->parent;
@@ -715,31 +710,10 @@ IUP_DRV_API int iupeflIsInsideTabs(Ihandle* ih)
715710

716711
IUP_SDK_API void iupdrvBaseLayoutUpdateMethod(Ihandle* ih)
717712
{
718-
Eo* widget;
719-
Eo* container = (Eo*)iupAttribGet(ih, "_IUP_EXTRAPARENT");
720-
int abs_x, abs_y;
721-
722-
widget = container ? container : iupeflGetWidget(ih);
723-
if (!widget)
724-
return;
725-
726713
if (iupeflIsInsideTabs(ih))
727714
return;
728715

729-
eflGetAbsolutePosition(ih, &abs_x, &abs_y);
730-
731-
iupeflSetPosition(widget, abs_x, abs_y);
732-
iupeflSetSize(widget, ih->currentwidth, ih->currentheight);
733-
734-
{
735-
Eo* bg_rect = (Eo*)iupAttribGet(ih, "_IUP_EFL_BGRECT");
736-
if (bg_rect)
737-
{
738-
efl_gfx_entity_position_set(bg_rect, EINA_POSITION2D(abs_x, abs_y));
739-
efl_gfx_entity_size_set(bg_rect, EINA_SIZE2D(ih->currentwidth, ih->currentheight));
740-
efl_gfx_stack_below(bg_rect, widget);
741-
}
742-
}
716+
iupeflSetPosSize(ih, ih->x, ih->y, ih->currentwidth, ih->currentheight);
743717
}
744718

745719
IUP_SDK_API void iupdrvBaseUnMapMethod(Ihandle* ih)

iup/external/src/efl/iupefl_drv.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,14 @@ IUP_DRV_API int iupeflBaseSetVisibleAttrib(Ihandle* ih, const char* value);
140140
/* Get the inner container for adding children */
141141
IUP_DRV_API Eo* iupeflGetInnerContainer(Ihandle* ih);
142142

143+
/* Concrete Efl.Ui.Widget subclass with no automatic layout */
144+
const Efl_Class* iupefl_fixed_class_get(void);
145+
143146
/* Fixed positioning container */
144147
IUP_DRV_API Eo* iupeflFixedContainerNew(Eo* parent);
145148
IUP_DRV_API void iupeflFixedContainerMove(Eo* container, Eo* child, int x, int y);
146149

147-
/* Native container using EFL_UI_BOX_CLASS */
150+
/* Native container for frame inner area */
148151
IUP_DRV_API Eo* iupeflNativeContainerNew(Eo* parent);
149152

150153
/****************************************************************************

iup/external/src/efl/iupefl_font.c

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ static Evas* eflFontGetMeasureEvas(void)
4848
return evas_object_evas_get(win);
4949
}
5050

51+
efl_font_buffer_ee = ecore_evas_buffer_new(1, 1);
52+
if (efl_font_buffer_ee)
53+
return ecore_evas_get(efl_font_buffer_ee);
54+
5155
return NULL;
5256
}
5357

@@ -61,23 +65,6 @@ static void eflFontApplyStyle(Eo* tb, const char* family, int size, int is_bold,
6165
efl_canvas_textblock_style_apply(tb, style);
6266
}
6367

64-
static IeflFont* eflFontGet(Ihandle* ih)
65-
{
66-
return (IeflFont*)iupAttribGet(ih, "_IUP_EFL_FONT");
67-
}
68-
69-
IUP_DRV_API void iupeflFontFree(Ihandle* ih)
70-
{
71-
IeflFont* font = eflFontGet(ih);
72-
if (font)
73-
{
74-
if (font->font_name)
75-
free(font->font_name);
76-
free(font);
77-
iupAttribSet(ih, "_IUP_EFL_FONT", NULL);
78-
}
79-
}
80-
8168
static void eflFontParse(const char* value, char* family, int* size, int* is_bold, int* is_italic, int* is_underline, int* is_strikeout)
8269
{
8370
const char* p;
@@ -245,6 +232,49 @@ static void eflFontMeasureString(const char* family, int size, int is_bold, int
245232
if (h) *h = sz.h > 0 ? sz.h : size;
246233
}
247234

235+
static IeflFont* eflFontGet(Ihandle* ih)
236+
{
237+
IeflFont* font = (IeflFont*)iupAttribGet(ih, "_IUP_EFL_FONT");
238+
if (!font && ih)
239+
{
240+
char* font_str = iupGetFontValue(ih);
241+
if (!font_str)
242+
font_str = IupGetGlobal("DEFAULTFONT");
243+
if (font_str)
244+
{
245+
char family[100];
246+
int size, is_bold, is_italic, is_underline, is_strikeout;
247+
248+
font = (IeflFont*)calloc(1, sizeof(IeflFont));
249+
iupAttribSet(ih, "_IUP_EFL_FONT", (char*)font);
250+
251+
eflFontParse(font_str, family, &size, &is_bold, &is_italic, &is_underline, &is_strikeout);
252+
253+
font->font_name = strdup(family);
254+
font->size = size;
255+
font->is_bold = is_bold;
256+
font->is_italic = is_italic;
257+
font->is_underline = is_underline;
258+
font->is_strikeout = is_strikeout;
259+
260+
eflFontMeasure(family, size, is_bold, is_italic, &font->charwidth, &font->charheight, &font->ascent, &font->descent);
261+
}
262+
}
263+
return font;
264+
}
265+
266+
IUP_DRV_API void iupeflFontFree(Ihandle* ih)
267+
{
268+
IeflFont* font = (IeflFont*)iupAttribGet(ih, "_IUP_EFL_FONT");
269+
if (font)
270+
{
271+
if (font->font_name)
272+
free(font->font_name);
273+
free(font);
274+
iupAttribSet(ih, "_IUP_EFL_FONT", NULL);
275+
}
276+
}
277+
248278
IUP_SDK_API int iupdrvSetFontAttrib(Ihandle* ih, const char* value)
249279
{
250280
IeflFont* font = eflFontGet(ih);

iup/external/src/efl/iupefl_tabs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ IUP_SDK_API int iupdrvTabsExtraDecor(Ihandle* ih)
330330

331331
IUP_SDK_API int iupdrvTabsExtraMargin(void)
332332
{
333-
return 0;
333+
return 4;
334334
}
335335

336336
IUP_SDK_API int iupdrvTabsGetLineCountAttrib(Ihandle* ih)
@@ -733,7 +733,7 @@ static void eflTabsChildAddedMethod(Ihandle* ih, Ihandle* child)
733733
if (!page)
734734
return;
735735

736-
content_box = efl_add(EFL_UI_BOX_CLASS, page);
736+
content_box = efl_add(iupefl_fixed_class_get(), page);
737737
if (content_box)
738738
{
739739
efl_gfx_hint_weight_set(content_box, 1.0, 1.0);

0 commit comments

Comments
 (0)