Home | History | Annotate | Download | only in photoeditor
      1 /*
      2  * Copyright (C) 2010 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.photoeditor;
     18 
     19 import android.view.View;
     20 
     21 /**
     22  * Handler that adjusts layouts of toolbar's child views whose positions need being calculated
     23  * according to the current screen dimensions.
     24  */
     25 class ToolbarLayoutHandler {
     26 
     27     private final View tools;
     28 
     29     /**
     30      * Constructor should only be invoked after toolbar has done inflation and added all its child
     31      * views; then its child views could be found by findViewById calls.
     32      */
     33     public ToolbarLayoutHandler(View toolbar) {
     34         this.tools = toolbar;
     35     }
     36 
     37     /**
     38      * Layouts child tool views' positions that need being updated when toolbar is being layout.
     39      */
     40     public void extraLayout(int left, int top, int right, int bottom) {
     41         // Wheels need being centered vertically.
     42         int height = bottom - top;
     43 
     44         View scaleWheel = tools.findViewById(R.id.scale_wheel);
     45         scaleWheel.offsetTopAndBottom((height - scaleWheel.getHeight()) / 2);
     46 
     47         View colorWheel = tools.findViewById(R.id.color_wheel);
     48         colorWheel.offsetTopAndBottom((height - colorWheel.getHeight()) / 2);
     49     }
     50 }
     51