mirror of https://github.com/sipwise/jitsi.git
parent
510925a175
commit
1cd6a92981
|
After Width: | Height: | Size: 831 B |
|
After Width: | Height: | Size: 778 B |
@ -0,0 +1,145 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.gui.main.call;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class FullScreenLayout implements LayoutManager
|
||||
{
|
||||
public static final String CENTER = "CENTER";
|
||||
|
||||
public static final String SOUTH = "SOUTH";
|
||||
|
||||
private Component center;
|
||||
|
||||
private final boolean overlay;
|
||||
|
||||
private Component south;
|
||||
|
||||
public FullScreenLayout(boolean overlay)
|
||||
{
|
||||
this.overlay = overlay;
|
||||
}
|
||||
|
||||
public void addLayoutComponent(String name, Component comp)
|
||||
{
|
||||
if (CENTER.equals(name))
|
||||
{
|
||||
center = comp;
|
||||
}
|
||||
else if (SOUTH.equals(name))
|
||||
{
|
||||
south = comp;
|
||||
}
|
||||
}
|
||||
|
||||
private Component[] getLayoutComponents()
|
||||
{
|
||||
if (center == null)
|
||||
{
|
||||
if (south == null)
|
||||
{
|
||||
return new Component[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
return new Component[]
|
||||
{ south };
|
||||
}
|
||||
}
|
||||
else if (south == null)
|
||||
{
|
||||
return new Component[]
|
||||
{ center };
|
||||
}
|
||||
else
|
||||
{
|
||||
return new Component[]
|
||||
{ center, south };
|
||||
}
|
||||
}
|
||||
|
||||
public void layoutContainer(Container parent)
|
||||
{
|
||||
Dimension parentSize = parent.getSize();
|
||||
int southWidth;
|
||||
int southHeight;
|
||||
|
||||
if (south == null)
|
||||
{
|
||||
southWidth = southHeight = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Dimension southSize = south.getPreferredSize();
|
||||
|
||||
southWidth = southSize.width;
|
||||
southHeight = southSize.height;
|
||||
}
|
||||
|
||||
if (center != null)
|
||||
{
|
||||
int yOffset = overlay ? 0 : southHeight;
|
||||
|
||||
center.setBounds(0, yOffset, parentSize.width, parentSize.height
|
||||
- 2 * yOffset);
|
||||
}
|
||||
if (south != null)
|
||||
{
|
||||
south.setBounds((parentSize.width - southWidth) / 2,
|
||||
parentSize.height - southHeight, southWidth, southHeight);
|
||||
}
|
||||
}
|
||||
|
||||
public Dimension minimumLayoutSize(Container parent)
|
||||
{
|
||||
Component[] components = getLayoutComponents();
|
||||
Dimension size = new Dimension(0, 0);
|
||||
|
||||
for (int i = 0; i < components.length; i++)
|
||||
{
|
||||
Dimension componentSize = components[i].getMinimumSize();
|
||||
|
||||
size.width = Math.max(size.width, componentSize.width);
|
||||
if (overlay)
|
||||
size.height = Math.max(size.height, componentSize.height);
|
||||
else
|
||||
size.height += componentSize.height;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Dimension preferredLayoutSize(Container parent)
|
||||
{
|
||||
Component[] components = getLayoutComponents();
|
||||
Dimension size = new Dimension(0, 0);
|
||||
|
||||
for (int i = 0; i < components.length; i++)
|
||||
{
|
||||
Dimension componentSize = components[i].getPreferredSize();
|
||||
|
||||
size.width = Math.max(size.width, componentSize.width);
|
||||
if (overlay)
|
||||
size.height = Math.max(size.height, componentSize.height);
|
||||
else
|
||||
size.height += componentSize.height;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void removeLayoutComponent(Component comp)
|
||||
{
|
||||
if (comp.equals(center))
|
||||
{
|
||||
center = null;
|
||||
}
|
||||
else if (comp.equals(south))
|
||||
{
|
||||
south = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.gui.main.call;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Lubomir Marinov
|
||||
*/
|
||||
public class VideoLayout extends FitLayout
|
||||
{
|
||||
public static final String LOCAL = "LOCAL";
|
||||
|
||||
private static final float LOCAL_TO_REMOTE_RATIO = 0.25f;
|
||||
|
||||
public static final String REMOTE = "REMOTE";
|
||||
|
||||
private Component local;
|
||||
|
||||
private Component remote;
|
||||
|
||||
public void addLayoutComponent(String name, Component comp)
|
||||
{
|
||||
super.addLayoutComponent(name, comp);
|
||||
|
||||
if ((name == null) || name.equals(REMOTE))
|
||||
remote = comp;
|
||||
else if (name.equals(LOCAL))
|
||||
local = comp;
|
||||
}
|
||||
|
||||
protected Component getComponent(Container parent)
|
||||
{
|
||||
return getRemote();
|
||||
}
|
||||
|
||||
public Component getLocal()
|
||||
{
|
||||
return local;
|
||||
}
|
||||
|
||||
public Component getRemote()
|
||||
{
|
||||
return remote;
|
||||
}
|
||||
|
||||
public void layoutContainer(Container parent)
|
||||
{
|
||||
super.layoutContainer(parent);
|
||||
|
||||
Component local = getLocal();
|
||||
if (local != null)
|
||||
{
|
||||
Dimension parentSize = parent.getSize();
|
||||
int height = Math.round(parentSize.height * LOCAL_TO_REMOTE_RATIO);
|
||||
|
||||
super.layoutComponent(local, new Rectangle(0, parentSize.height
|
||||
- height, Math.round(parentSize.width * LOCAL_TO_REMOTE_RATIO),
|
||||
height), Component.LEFT_ALIGNMENT, Component.BOTTOM_ALIGNMENT);
|
||||
}
|
||||
}
|
||||
|
||||
public Dimension minimumLayoutSize(Container parent)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return super.minimumLayoutSize(parent);
|
||||
}
|
||||
|
||||
public Dimension preferredLayoutSize(Container parent)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return super.preferredLayoutSize(parent);
|
||||
}
|
||||
|
||||
public void removeLayoutComponent(Component comp)
|
||||
{
|
||||
super.removeLayoutComponent(comp);
|
||||
|
||||
if (remote == comp)
|
||||
remote = null;
|
||||
else if (local == comp)
|
||||
local = null;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue