Convert layout code to use logical directions.