Simplify eo-inherit even more
Square does not need "side", can use the parent's setters to make sure width=height always.
This commit is contained in:
parent
1e380eace9
commit
ae932ce226
|
@ -20,7 +20,7 @@ _square_create()
|
|||
|
||||
square = efl_add(EXAMPLE_SQUARE_CLASS, NULL,
|
||||
efl_name_set(efl_added, "Square"),
|
||||
example_square_side_set(efl_added, 7));
|
||||
example_rectangle_width_set(efl_added, 7));
|
||||
|
||||
return square;
|
||||
}
|
||||
|
|
|
@ -10,16 +10,17 @@ typedef struct
|
|||
} Example_Square_Data;
|
||||
|
||||
EOLIAN static void
|
||||
_example_square_side_set(Eo *obj, Example_Square_Data *pd EINA_UNUSED, int size)
|
||||
_example_square_example_rectangle_width_set(Eo *obj, Example_Square_Data *pd EINA_UNUSED, int width)
|
||||
{
|
||||
example_rectangle_width_set(obj, size);
|
||||
example_rectangle_height_set(obj, size);
|
||||
example_rectangle_width_set(efl_super(obj, EXAMPLE_SQUARE_CLASS), width);
|
||||
example_rectangle_height_set(efl_super(obj, EXAMPLE_SQUARE_CLASS), width);
|
||||
}
|
||||
|
||||
EOLIAN static int
|
||||
_example_square_side_get(Eo *obj, Example_Square_Data *pd EINA_UNUSED)
|
||||
EOLIAN static void
|
||||
_example_square_example_rectangle_height_set(Eo *obj, Example_Square_Data *pd EINA_UNUSED, int height)
|
||||
{
|
||||
return example_rectangle_width_get(obj);
|
||||
example_rectangle_width_set(efl_super(obj, EXAMPLE_SQUARE_CLASS), height);
|
||||
example_rectangle_height_set(efl_super(obj, EXAMPLE_SQUARE_CLASS), height);
|
||||
}
|
||||
|
||||
#include "example_square.eo.c"
|
||||
|
|
|
@ -1,15 +1,7 @@
|
|||
class Example.Square (Example.Rectangle) {
|
||||
[[A square shape object]]
|
||||
methods {
|
||||
@property side {
|
||||
[[The length of both sides of this square]]
|
||||
set {
|
||||
}
|
||||
get {
|
||||
}
|
||||
values {
|
||||
size: int; [[Square side length]]
|
||||
}
|
||||
}
|
||||
implements {
|
||||
Example.Rectangle.width {set;}
|
||||
Example.Rectangle.height {set;}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue