Switch all JavaScript variable names to firstWordLowerCase style to agree with the Style Guide.

svn path=/trunk/; revision=57
This commit is contained in:
Marina Zhurakhinskaya 2008-11-19 19:23:24 +00:00
parent 372021d05b
commit 5b31ce3415
2 changed files with 88 additions and 88 deletions

View File

@ -18,54 +18,54 @@ const PARTIAL_OPACITY = 0.4 * 255;
const FULL_OPACITY = 255;
function Button(text, button_color, pressed_button_color, min_width, min_height) {
this._init(text, button_color, pressed_button_color, min_width, min_height);
function Button(text, buttonColor, pressedButtonColor, minWidth, minHeight) {
this._init(text, buttonColor, pressedButtonColor, minWidth, minHeight);
}
Button.prototype = {
_init : function(text, button_color, pressed_button_color, stays_pressed, min_width, min_height) {
_init : function(text, buttonColor, pressedButtonColor, staysPressed, minWidth, minHeight) {
this._button_color = button_color
if (button_color == null)
this._button_color = DEFAULT_BUTTON_COLOR;
this._buttonColor = buttonColor
if (buttonColor == null)
this._buttonColor = DEFAULT_BUTTON_COLOR;
this._pressed_button_color = pressed_button_color
if (pressed_button_color == null)
this._pressed_button_color = DEFAULT_PRESSED_BUTTON_COLOR;
this._pressedButtonColor = pressedButtonColor
if (pressedButtonColor == null)
this._pressedButtonColor = DEFAULT_PRESSED_BUTTON_COLOR;
if (stays_pressed == null)
stays_pressed = false
if (min_width == null)
min_width = 0;
if (min_height == null)
min_height = 0;
if (staysPressed == null)
staysPressed = false
if (minWidth == null)
minWidth = 0;
if (minHeight == null)
minHeight = 0;
// if stays_pressed is true, this.active will be true past the first release of a button, untill a subsequent one (the button
// if staysPressed is true, this.active will be true past the first release of a button, untill a subsequent one (the button
// is unpressed) or untill release() is called explicitly
this._active = false;
this._is_between_press_and_release = false;
this._mouse_is_over_button = false;
this._isBetweenPressAndRelease = false;
this._mouseIsOverButton = false;
this.button = new Clutter.Group({reactive: true});
this._background = new Clutter.Rectangle({ color: this._button_color});
this._pressed_background = new Clutter.Rectangle({ color: this._pressed_button_color, opacity: NO_OPACITY});
this._background = new Clutter.Rectangle({ color: this._buttonColor});
this._pressedBackground = new Clutter.Rectangle({ color: this._pressedButtonColor, opacity: NO_OPACITY});
this._label = new Clutter.Label({ font_name: "Sans Bold 16px",
text: text});
this._label.set_position(5, 5);
let background_width = Math.max(this._label.get_width()+10, min_width);
let background_height = Math.max(this._label.get_height()+10, min_height);
this._background.set_width(background_width)
this._background.set_height(background_height)
this._pressed_background.set_width(background_width)
this._pressed_background.set_height(background_height)
let backgroundWidth = Math.max(this._label.get_width()+10, minWidth);
let backgroundHeight = Math.max(this._label.get_height()+10, minHeight);
this._background.set_width(backgroundWidth)
this._background.set_height(backgroundHeight)
this._pressedBackground.set_width(backgroundWidth)
this._pressedBackground.set_height(backgroundHeight)
this.button.add_actor(this._background);
this.button.add_actor(this._pressed_background);
this.button.add_actor(this._pressedBackground);
this.button.add_actor(this._label);
let me = this;
this.button.connect('button-press-event',
function(o, event) {
me._is_between_press_and_release = true;
Tweener.addTween(me._pressed_background,
me._isBetweenPressAndRelease = true;
Tweener.addTween(me._pressedBackground,
{ time: ANIMATION_TIME,
opacity: FULL_OPACITY,
transition: "linear"
@ -74,8 +74,8 @@ Button.prototype = {
});
this.button.connect('button-release-event',
function(o, event) {
me._is_between_press_and_release = false;
if (!stays_pressed || me._active) {
me._isBetweenPressAndRelease = false;
if (!staysPressed || me._active) {
me.release();
} else {
me._active = true;
@ -84,33 +84,33 @@ Button.prototype = {
});
this.button.connect('enter-event',
function(o, event) {
me._mouse_is_over_button = true;
me._mouseIsOverButton = true;
if (!me._active) {
Tweener.removeTweens(me._pressed_background);
me._pressed_background.set_opacity(PARTIAL_OPACITY);
Tweener.removeTweens(me._pressedBackground);
me._pressedBackground.set_opacity(PARTIAL_OPACITY);
}
return false;
});
this.button.connect('leave-event',
function(o, event) {
me._is_between_press_and_release = false;
me._mouse_is_over_button = false;
me._isBetweenPressAndRelease = false;
me._mouseIsOverButton = false;
if (!me._active) {
Tweener.removeTweens(me._pressed_background);
me._pressed_background.set_opacity(NO_OPACITY);
Tweener.removeTweens(me._pressedBackground);
me._pressedBackground.set_opacity(NO_OPACITY);
}
return false;
});
},
release : function() {
if (!this._is_between_press_and_release) {
if (!this._isBetweenPressAndRelease) {
this._active = false;
Tweener.removeTweens(this._pressed_background);
if (this._mouse_is_over_button) {
this._pressed_background.set_opacity(PARTIAL_OPACITY);
Tweener.removeTweens(this._pressedBackground);
if (this._mouseIsOverButton) {
this._pressedBackground.set_opacity(PARTIAL_OPACITY);
} else {
this._pressed_background.set_opacity(NO_OPACITY);
this._pressedBackground.set_opacity(NO_OPACITY);
}
}
}

View File

@ -24,7 +24,7 @@ const WINDOW_OPACITY = 0.9 * 255;
// counts we fall back to an algorithm. We need more schemes here
// unless we have a really good algorithm.
//
// Each triplet is [x_center, y_center, scale] where the scale
// Each triplet is [xCenter, yCenter, scale] where the scale
// is relative to the width of the desktop.
const POSITIONS = {
1: [[0.5, 0.5, 0.8]],
@ -55,7 +55,7 @@ Overlay.prototype = {
this._group.hide();
global.overlay_group.add_actor(this._group);
this._window_clones = []
this._windowClones = []
},
show : function() {
@ -64,52 +64,52 @@ Overlay.prototype = {
let global = Shell.global_get();
let windows = global.get_windows();
let desktop_window = null;
let desktopWindow = null;
let screen_width = global.screen_width
let screen_height = global.screen_height
let screenWidth = global.screen_width
let screenHeight = global.screen_height
for (let i = 0; i < windows.length; i++)
if (windows[i].get_window_type() == Meta.WindowType.DESKTOP)
desktop_window = windows[i];
desktopWindow = windows[i];
// The desktop windows are shown on top of a scaled down version of the
// desktop. This is positioned at the right side of the screen
this._desktop_width = screen_width * DESKTOP_SCALE;
this._desktop_height = screen_height * DESKTOP_SCALE;
this._desktop_x = screen_width - this._desktop_width - 10;
this._desktop_y = Panel.PANEL_HEIGHT + (screen_height - this._desktop_height - Panel.PANEL_HEIGHT) / 2;
this._desktopWidth = screenWidth * DESKTOP_SCALE;
this._desktopHeight = screenHeight * DESKTOP_SCALE;
this._desktopX = screenWidth - this._desktopWidth - 10;
this._desktopY = Panel.PANEL_HEIGHT + (screenHeight - this._desktopHeight - Panel.PANEL_HEIGHT) / 2;
// If a file manager is displaying desktop icons, there will be a desktop window.
// This window will have the size of the whole desktop. When such window is not present
// (e.g. when the preference for showing icons on the desktop is disabled by the user
// or we are running inside a Xephyr window), we should create a desktop rectangle
// to serve as the background.
if (desktop_window)
this._createDesktopClone(desktop_window);
if (desktopWindow)
this._createDesktopClone(desktopWindow);
else
this._createDesktopRectangle();
// Count the total number of windows so we know what layout scheme to use
let n_windows = 0;
let numberOfWindows = 0;
for (let i = 0; i < windows.length; i++) {
let w = windows[i];
if (w == desktop_window || w.is_override_redirect())
if (w == desktopWindow || w.is_override_redirect())
continue;
n_windows++;
numberOfWindows++;
}
// Now create actors for all the desktop windows. Do it in
// reverse order so that the active actor ends up on top
let window_index = 0;
let windowIndex = 0;
for (let i = windows.length - 1; i >= 0; i--) {
let w = windows[i];
if (w == desktop_window || w.is_override_redirect())
if (w == desktopWindow || w.is_override_redirect())
continue;
this._createWindowClone(w, n_windows - window_index - 1, n_windows);
this._createWindowClone(w, numberOfWindows - windowIndex - 1, numberOfWindows);
window_index++;
windowIndex++;
}
// All the the actors in the window group are completely obscured,
@ -132,11 +132,11 @@ Overlay.prototype = {
global.window_group.show()
this._group.hide();
for (let i = 0; i < this._window_clones.length; i++) {
this._window_clones[i].destroy();
for (let i = 0; i < this._windowClones.length; i++) {
this._windowClones[i].destroy();
}
this._window_clones = [];
this._windowClones = [];
}
},
@ -156,22 +156,22 @@ Overlay.prototype = {
// up identically.
// We are also using (0,0) coordinates in both cases which makes the background
// window animate out from behind the panel.
let desktop_rectangle = new Clutter.Rectangle({ color: global.stage.color,
let desktopRectangle = new Clutter.Rectangle({ color: global.stage.color,
reactive: true,
x: 0,
y: 0,
width: global.screen_width,
height: global.screen_height });
this._addDesktop(desktop_rectangle);
this._addDesktop(desktopRectangle);
},
_addDesktop : function(desktop) {
this._window_clones.push(desktop);
this._windowClones.push(desktop);
this._group.add_actor(desktop);
Tweener.addTween(desktop,
{ x: this._desktop_x,
y: this._desktop_y,
{ x: this._desktopX,
y: this._desktopY,
scale_x: DESKTOP_SCALE,
scale_y: DESKTOP_SCALE,
time: ANIMATION_TIME,
@ -185,26 +185,26 @@ Overlay.prototype = {
});
},
// window_index == 0 => top in stacking order
_computeWindowPosition : function(window_index, n_windows) {
if (n_windows in POSITIONS)
return POSITIONS[n_windows][window_index];
// windowIndex == 0 => top in stacking order
_computeWindowPosition : function(windowIndex, numberOfWindows) {
if (numberOfWindows in POSITIONS)
return POSITIONS[numberOfWindows][windowIndex];
// If we don't have a predefined scheme for this window count, overlap the windows
// along the diagonal of the desktop (improve this!)
let fraction = Math.sqrt(1/n_windows);
let fraction = Math.sqrt(1/numberOfWindows);
// The top window goes at the lower right - this is different from the
// fixed position schemes where the windows are in "reading order"
// and the top window goes at the upper left.
let pos = (n_windows - window_index - 1) / (n_windows - 1);
let x_center = (fraction / 2) + (1 - fraction) * pos;
let y_center = x_center;
let pos = (numberOfWindows - windowIndex - 1) / (numberOfWindows - 1);
let xCenter = (fraction / 2) + (1 - fraction) * pos;
let yCenter = xCenter;
return [x_center, y_center, fraction];
return [xCenter, yCenter, fraction];
},
_createWindowClone : function(w, window_index, n_windows) {
_createWindowClone : function(w, windowIndex, numberOfWindows) {
// We show the window using "clones" of the texture .. separate
// actors that mirror the original actors for the window. For
// animation purposes, it may be better to actually move the
@ -215,28 +215,28 @@ Overlay.prototype = {
x: w.x,
y: w.y });
let [x_center, y_center, fraction] = this._computeWindowPosition(window_index, n_windows);
let [xCenter, yCenter, fraction] = this._computeWindowPosition(windowIndex, numberOfWindows);
let desired_size = this._desktop_width * fraction;
let desiredSize = this._desktopWidth * fraction;
x_center = this._desktop_x + x_center * this._desktop_width;
y_center = this._desktop_y + y_center * this._desktop_height;
xCenter = this._desktopX + xCenter * this._desktopWidth;
yCenter = this._desktopY + yCenter * this._desktopHeight;
let size = clone.width;
if (clone.height > size)
size = clone.height;
// Never scale up
let scale = desired_size / size;
let scale = desiredSize / size;
if (scale > 1)
scale = 1;
this._group.add_actor(clone);
this._window_clones.push(clone);
this._windowClones.push(clone);
Tweener.addTween(clone,
{ x: x_center - 0.5 * scale * w.width,
y: y_center - 0.5 * scale * w.height,
{ x: xCenter - 0.5 * scale * w.width,
y: yCenter - 0.5 * scale * w.height,
scale_x: scale,
scale_y: scale,
time: ANIMATION_TIME,