~glitter-team/glitter/trunk

« back to all changes in this revision

Viewing changes to glitter/container.py

  • Committer: Jan Jokela
  • Date: 2009-02-26 15:59:31 UTC
  • mfrom: (7.1.2 global_widget_fixes)
  • Revision ID: janjokela@gmail.com-20090226155931-kyz3gt9i9kwj5soe
Merged from branch containing improvements to 'Frame' widget

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
    def _update_layout(self):
72
72
        """ Updates layout """
73
73
        
74
 
        # Natural an minimum sizes
75
 
        n_width = int(self.natural_width * self.get_parent().get_widthu())
76
 
        n_height = int(self.natural_height * self.get_parent().get_heightu())
77
 
        
78
 
        m_width = self.minimum_width
79
 
        m_height = self.minimum_height
80
 
        
81
 
        # Preferred size is the natural one, except if lower than minimum
82
 
        if n_width >= m_width:
83
 
            tmp_width = n_width
84
 
        else:
85
 
            tmp_width = m_width
86
 
        if n_height >= m_height:
87
 
            tmp_height = n_height
88
 
        else:
89
 
            tmp_height = m_height
90
 
            
91
 
        # Account for size ratios
92
 
        if self.size_ratio > 0:
93
 
            tmp_width = int(self.size_ratio * tmp_height)
94
 
        elif self.size_ratio < 0:
95
 
            tmp_height = int(self.size_ratio * tmp_width)
96
 
        
97
 
        # Set size
98
 
        self.set_widthu(int(tmp_width))
99
 
        self.set_heightu(int(tmp_height))
 
74
        if self.get_parent():
 
75
        
 
76
            # Natural an minimum sizes
 
77
            n_width = int(self.natural_width * self.get_parent().get_widthu())
 
78
            n_height = int(self.natural_height * self.get_parent().get_heightu())
 
79
            
 
80
            m_width = self.minimum_width
 
81
            m_height = self.minimum_height
 
82
            
 
83
            # Preferred size is the natural one, except if lower than minimum
 
84
            if n_width >= m_width:
 
85
                tmp_width = n_width
 
86
            else:
 
87
                tmp_width = m_width
 
88
            if n_height >= m_height:
 
89
                tmp_height = n_height
 
90
            else:
 
91
                tmp_height = m_height
 
92
                
 
93
            # Account for size ratios
 
94
            if self.size_ratio > 0:
 
95
                tmp_width = int(self.size_ratio * tmp_height)
 
96
            elif self.size_ratio < 0:
 
97
                tmp_height = int(self.size_ratio * tmp_width)
 
98
            
 
99
            # Set size
 
100
            self.set_widthu(int(tmp_width))
 
101
            self.set_heightu(int(tmp_height))
100
102
 
101
 
        # Natural and minimum positions
102
 
        n_x = self.natural_x * self.get_parent().get_widthu()
103
 
        n_y = self.natural_y * self.get_parent().get_heightu()
104
 
        
105
 
        m_x = self.minimum_x
106
 
        m_y = self.minimum_y
107
 
        
108
 
        if n_x >= m_x:
109
 
            tmp_x = n_x
110
 
        else:
111
 
            tmp_x = m_x
112
 
        if n_y >= m_y:
113
 
            tmp_y = n_y
114
 
        else:
115
 
            tmp_y = m_y
116
 
        
117
 
        tmp_x = float(tmp_x)
118
 
        tmp_y = float(tmp_y)
119
 
        self.set_positionu(tmp_x, tmp_y)
 
103
            # Natural and minimum positions
 
104
            n_x = self.natural_x * self.get_parent().get_widthu()
 
105
            n_y = self.natural_y * self.get_parent().get_heightu()
 
106
            
 
107
            m_x = self.minimum_x
 
108
            m_y = self.minimum_y
 
109
            
 
110
            if n_x >= m_x:
 
111
                tmp_x = n_x
 
112
            else:
 
113
                tmp_x = m_x
 
114
            if n_y >= m_y:
 
115
                tmp_y = n_y
 
116
            else:
 
117
                tmp_y = m_y
 
118
            
 
119
            tmp_x = float(tmp_x)
 
120
            tmp_y = float(tmp_y)
 
121
            self.set_positionu(tmp_x, tmp_y)
120
122
        
121
123
    def get_natural_width(self):
122
124
        """ Retrieve natural width """