summaryrefslogtreecommitdiff
path: root/efl/elementary/panes.pyx
blob: fac2d538b239b17be12361986a8b0e8aed15d814 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# Copyright (C) 2007-2014 various contributors (see AUTHORS)
#
# This file is part of Python-EFL.
#
# Python-EFL is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# Python-EFL is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this Python-EFL.  If not, see <http://www.gnu.org/licenses/>.

"""

Widget description
------------------

.. image:: /images/panes-preview.png
    :align: left

The panes widget adds a draggable bar between two contents. When
dragged this bar will resize contents' size.

Panes can be displayed vertically or horizontally, and contents size
proportion can be customized (homogeneous by default).

This widget emits the following signals, besides the ones sent from
:py:class:`~efl.elementary.layout_class.LayoutClass`:

- ``press`` - The panes has been pressed (button wasn't released yet).
- ``unpressed`` - The panes was released after being pressed.
- ``clicked`` - The panes has been clicked.
- ``clicked,double`` - The panes has been double clicked.

Available styles for it:

- ``default``

Default content parts of the panes widget that you can use are:

- ``left`` - A leftside content of the panes
- ``right`` - A rightside content of the panes
- ``top`` - A top content of the vertical panes
- ``bottom`` - A bottom content of the vertical panes

If panes are displayed vertically, left content will be displayed on top.

"""

from efl.eo cimport _object_mapping_register
from efl.evas cimport Object as evasObject
from layout_class cimport LayoutClass

cdef class Panes(LayoutClass):

    """This is the class that actually implements the widget."""

    def __init__(self, evasObject parent, *args, **kwargs):
        self._set_obj(elm_panes_add(parent.obj))
        self._set_properties_from_keyword_args(kwargs)

    property fixed:
        """Whether the left and right panes resize homogeneously or not.

        By default panes are resized homogeneously.

        .. seealso:: :py:attr:`content_left_size` :py:attr:`content_right_size`

        :type: bool

        """
        def __set__(self, fixed):
            elm_panes_fixed_set(self.obj, fixed)
        def __get__(self):
            return bool(elm_panes_fixed_get(self.obj))

    property content_left_size:
        """The size proportion of panes widget's left side.

        By default it's homogeneous, i.e., both sides have the same size.

        If something different is required, it can be set with this property.
        For example, if the left content should be displayed over
        75% of the panes size, ``size`` should be passed as ``0.75``.
        This way, right content will be resized to 25% of panes size.

        If displayed vertically, left content is displayed at top, and
        right content at bottom.

        .. note:: This proportion will change when user drags the panes bar.

        :type: float

        """
        def __get__(self):
            return elm_panes_content_left_size_get(self.obj)
        def __set__(self, size):
            elm_panes_content_left_size_set(self.obj, size)

    property content_right_size:
        """The size proportion of panes widget's right side.

        By default it's homogeneous, i.e., both sides have the same size.

        If something different is required, it can be set with this property.
        For example, if the right content should be displayed over
        75% of the panes size, ``size`` should be passed as ``0.75.``
        This way, left content will be resized to 25% of panes size.

        If displayed vertically, left content is displayed at top, and
        right content at bottom.

        .. note:: This proportion will change when user drags the panes bar.

        :type: float

        """
        def __get__(self):
            return elm_panes_content_right_size_get(self.obj)
        def __set__(self, size):
            elm_panes_content_right_size_set(self.obj, size)

    property horizontal:
        """The orientation of a given panes widget.

        Use this property to change how your panes is to be disposed:
        vertically or horizontally.

        By default it's displayed horizontally.

        :type: bool

        """
        def __set__(self, horizontal):
            elm_panes_horizontal_set(self.obj, horizontal)
        def __get__(self):
            return bool(elm_panes_horizontal_get(self.obj))

    def callback_press_add(self, func, *args, **kwargs):
        """The panes has been pressed (button wasn't released yet)."""
        self._callback_add("press", func, *args, **kwargs)

    def callback_press_del(self, func):
        self._callback_del("press", func)

    def callback_unpress_add(self, func, *args, **kwargs):
        """The panes was released after being pressed."""
        self._callback_add("unpress", func, *args, **kwargs)

    def callback_unpress_del(self, func):
        self._callback_del("unpress", func)

    def callback_clicked_add(self, func, *args, **kwargs):
        """The panes has been clicked."""
        self._callback_add("clicked", func, *args, **kwargs)

    def callback_clicked_del(self, func):
        self._callback_del("clicked", func)

    def callback_clicked_double_add(self, func, *args, **kwargs):
        """The panes has been double clicked."""
        self._callback_add("clicked,double", func, *args, **kwargs)

    def callback_clicked_double_del(self, func):
        self._callback_del("clicked,double", func)


_object_mapping_register("Elm_Panes", Panes)