<s> from __future__ import division <EOL> from . base import Layout <EOL> class VerticalTile ( Layout ) : <EOL> """<STR_LIT>""" <EOL> defaults = [ <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:1> , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:0> , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] <EOL> ratio = <NUM_LIT> <EOL> steps = <NUM_LIT> <EOL> def __init__ ( self , ** config ) : <EOL> Layout . __init__ ( self , ** config ) <EOL> self . add_defaults ( self . defaults ) <EOL> self . clients = [ ] <EOL> self . focused = None <EOL> self . maximized = None <EOL> def add ( self , window ) : <EOL> if self . clients and self . focused : <EOL> index = self . clients . index ( self . focused ) <EOL> self . clients . insert ( index + <NUM_LIT:1> , window ) <EOL> else : <EOL> self . clients . append ( window ) <EOL> self . focus ( window ) <EOL> def remove ( self , window ) : <EOL> if window not in self . clients : <EOL> return <EOL> index = self . clients . index ( window ) <EOL> self . clients . remove ( window ) <EOL> if not self . clients : <EOL> self . focused = None <EOL> self . maximized = None <EOL> return <EOL> if self . maximized is window : <EOL> self . maximized = None <EOL> if index == len ( self . clients ) : <EOL> index -= <NUM_LIT:1> <EOL> self . focus ( self . clients [ index ] ) <EOL> return self . focused <EOL> def clone ( self , group ) : <EOL> c = Layout . clone ( self , group ) <EOL> c . clients = [ ] <EOL> c . focused = None <EOL> return c <EOL> def configure ( self , window , screen ) : <EOL> if self . clients and window in self . clients : <EOL> n = len ( self . clients ) <EOL> index = self . clients . index ( window ) <EOL> if n > <NUM_LIT:1> : <EOL> border_width = self . border_width <EOL> else : <EOL> border_width = <NUM_LIT:0> <EOL> if window is self . focused : <EOL> border_color = self . group . qtile . colorPixel ( self . border_focus ) <EOL> else : <EOL> border_color = self . group . qtile . colorPixel ( self . border_normal ) <EOL> if n > <NUM_LIT:1> : <EOL> width = screen . width - self . border_width * <NUM_LIT:2> <EOL> else : <EOL> width = screen . width <EOL> if n > <NUM_LIT:1> : <EOL> main_area_height = int ( screen . height * self . ratio ) <EOL> sec_area_height = screen . height - main_area_height <EOL> main_pane_height = main_area_height - border_width * <NUM_LIT:2> <EOL> sec_pane_height = sec_area_height // ( n - <NUM_LIT:1> ) - border_width * <NUM_LIT:2> <EOL> normal_pane_height = ( screen . height // n ) - ( border_width * <NUM_LIT:2> ) <EOL> if self . maximized : <EOL> if window is self . maximized : <EOL> height = main_pane_height <EOL> else : <EOL> height = sec_pane_height <EOL> else : <EOL> height = normal_pane_height <EOL> else : <EOL> height = screen . height <EOL> y = screen . y <EOL> if n > <NUM_LIT:1> : <EOL> if self . maximized : <EOL> y += ( index * sec_pane_height ) + ( border_width * <NUM_LIT:2> * index ) <EOL> else : <EOL> y += ( index * normal_pane_height ) + ( border_width * <NUM_LIT:2> * index ) <EOL> if self . maximized and window is not self . maximized : <EOL> if index > self . clients . index ( self . maximized ) : <EOL> y = y - sec_pane_height + main_pane_height <EOL> window . place ( screen . x , y , width , height , border_width , <EOL> border_color , margin = self . margin ) <EOL> window . unhide ( ) <EOL> else : <EOL> window . hide ( ) <EOL> def blur ( self ) : <EOL> self . focused = None <EOL> def focus ( self , window ) : <EOL> self . focused = window <EOL> def focus_first ( self ) : <EOL> try : <EOL> return self . clients [ <NUM_LIT:0> ] <EOL> except IndexError : <EOL> pass <EOL> def focus_last ( self ) : <EOL> try : <EOL> return self . clients [ - <NUM_LIT:1> ] <EOL> except IndexError : <EOL> pass <EOL> def focus_next ( self , window ) : <EOL> if not self . clients : <EOL> return <EOL> try : <EOL> index = self . clients . index ( window ) <EOL> return self . clients [ index + <NUM_LIT:1> ] <EOL> except IndexError : <EOL> pass <EOL> def focus_previous ( self , window ) : <EOL> if not self . clients : <EOL> return <EOL> try : <EOL> index = self . clients . index ( window ) <EOL> return self . clients [ index - <NUM_LIT:1> ] <EOL> except IndexError : <EOL> pass <EOL> def grow ( self ) : <EOL> if self . ratio + self . steps < <NUM_LIT:1> : <EOL> self . ratio += self . steps <EOL> self . group . layoutAll ( ) <EOL> def shrink ( self ) : <EOL> if self . ratio - self . steps > <NUM_LIT:0> : <EOL> self . ratio -= self . steps <EOL> self . group . layoutAll ( ) <EOL> def cmd_next ( self ) : <EOL> self . focus_next ( self . focused ) <EOL> self . group . focus ( self . focused ) <EOL> def cmd_previous ( self ) : <EOL> self . focus_previous ( self . focused ) <EOL> self . group . focus ( self . focused ) <EOL> def cmd_down ( self ) : <EOL> self . focus_next ( self . focused ) <EOL> self . group . focus ( self . focused ) <EOL> def cmd_up ( self ) : <EOL> self . focus_previous ( self . focused ) <EOL> self . group . focus ( self . focused ) <EOL> def cmd_shuffle_up ( self ) : <EOL> index = self . clients . index ( self . focused ) <EOL> try : <EOL> self . clients [ index ] , self . clients [ index - <NUM_LIT:1> ] = self . clients [ index - <NUM_LIT:1> ] , self . clients [ index ] <EOL> except IndexError : <EOL> self . clients [ index ] , self . clients [ - <NUM_LIT:1> ] = self . clients [ - <NUM_LIT:1> ] , self . clients [ index ] <EOL> self . group . layoutAll ( ) <EOL> def cmd_shuffle_down ( self ) : <EOL> index = self . clients . index ( self . focused ) <EOL> try : <EOL> self . clients [ index ] , self . clients [ index + <NUM_LIT:1> ] = self . clients [ index + <NUM_LIT:1> ] , self . clients [ index ] <EOL> except IndexError : <EOL> self . clients [ index ] , self . clients [ <NUM_LIT:0> ] = self . clients [ <NUM_LIT:0> ] , self . clients [ index ] <EOL> self . group . layoutAll ( ) <EOL> def cmd_maximize ( self ) : <EOL> if self . clients : <EOL> self . maximized = self . focused <EOL> self . group . layoutAll ( ) <EOL> def cmd_normalize ( self ) : <EOL> self . maximized = None <EOL> self . group . layoutAll ( ) <EOL> def cmd_grow ( self ) : <EOL> if not self . maximized : <EOL> return <EOL> if self . focused is self . maximized : <EOL> self . grow ( ) <EOL> else : <EOL> self . shrink ( ) <EOL> def cmd_shrink ( self ) : <EOL> if not self . maximized : <EOL> return <EOL> if self . focused is self . maximized : <EOL> self . shrink ( ) <EOL> else : <EOL> self . grow ( ) </s>
