4 * This file is part of CameraPlus.
6 * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 var stack = new Array();
25 function __push(tools) {
26 if (stack.length >= 1) {
27 hide(stack[stack.length - 1]);
30 var container = createContainer(tools);
31 stack.push(container);
36 function push(tools) {
37 var container = __push(tools);
38 return container.tools;
42 if (stack.length == 0) {
46 var container = stack.pop();
48 destroyContainer(container);
50 if (stack.length == 0) {
54 container = stack[stack.length - 1];
57 return container.tools;
60 function show(container) {
61 container.tools.width = dock.width;
62 container.tools.height = dock.height;
63 container.tools.visible = true;
66 function hide(container) {
67 container.tools.visible = false;
70 function createContainer(tools) {
71 var container = toolsContainer.createObject(dock);
72 container.tools = tools;
73 container.owner = tools.parent;
74 container.tools.parent = dock;
79 function destroyContainer(container) {
80 container.tools.parent = container.owner;
81 container.tools = null;
82 container.owner = null;
86 function pushAndShow(tools) {
87 var container = __push(tools);
89 return container.tools;
93 while (stack.length > 0) {
99 return stack.length == 0 ? true : false;
102 function showLast() {
103 show(stack[stack.length - 1])
106 function hideLast() {
107 hide(stack[stack.length - 1])
110 function calculateChildrenWidth(children) {
113 for (var x = 0; x < children.length; x++) {
114 if (children[x].visible) {
115 totalWidth += children[x].width;
122 function countVisibleChildren(children) {
125 for (var x = 0; x < children.length; x++) {
126 if (children[x].visible) {