Restrict ClickThrough to what it was originally intended for.

This commit is contained in:
Paul Chote
2011-01-05 23:09:45 +13:00
parent 5254deedcb
commit 7cabe920db
21 changed files with 25 additions and 55 deletions

View File

@@ -15,7 +15,8 @@ namespace OpenRA.Widgets
public class BackgroundWidget : Widget public class BackgroundWidget : Widget
{ {
public readonly string Background = "dialog"; public readonly string Background = "dialog";
public readonly bool ClickThrough = false;
public override void DrawInner( WorldRenderer wr ) public override void DrawInner( WorldRenderer wr )
{ {
WidgetUtils.DrawPanel(Background, RenderBounds); WidgetUtils.DrawPanel(Background, RenderBounds);
@@ -23,10 +24,16 @@ namespace OpenRA.Widgets
public BackgroundWidget() : base() { } public BackgroundWidget() : base() { }
public override bool HandleMouseInput(MouseInput mi)
{
return !ClickThrough;
}
protected BackgroundWidget(BackgroundWidget other) protected BackgroundWidget(BackgroundWidget other)
: base(other) : base(other)
{ {
Background = other.Background; Background = other.Background;
ClickThrough = other.ClickThrough;
} }
public override Widget Clone() { return new BackgroundWidget(this); } public override Widget Clone() { return new BackgroundWidget(this); }

View File

@@ -167,14 +167,9 @@ namespace OpenRA.Widgets
public static void ShowDropDown<T>(Widget w, IEnumerable<T> ts, Func<T, int, LabelWidget> ft) public static void ShowDropDown<T>(Widget w, IEnumerable<T> ts, Func<T, int, LabelWidget> ft)
{ {
var dropDown = new ScrollPanelWidget() var dropDown = new ScrollPanelWidget();
{ dropDown.Bounds = new Rectangle(w.RenderOrigin.X, w.RenderOrigin.Y + w.Bounds.Height, w.Bounds.Width, 100);
Bounds = new Rectangle(w.RenderOrigin.X, w.RenderOrigin.Y + w.Bounds.Height, w.Bounds.Width, 100), dropDown.ItemSpacing = 1;
Visible = true,
ClickThrough = false,
OnMouseUp = mi => true,
ItemSpacing = 1
};
List<LabelWidget> items = new List<LabelWidget>(); List<LabelWidget> items = new List<LabelWidget>();
List<Widget> dismissAfter = new List<Widget>(); List<Widget> dismissAfter = new List<Widget>();
@@ -182,8 +177,6 @@ namespace OpenRA.Widgets
{ {
var ww = ft(t, dropDown.Bounds.Width - dropDown.ScrollbarWidth); var ww = ft(t, dropDown.Bounds.Width - dropDown.ScrollbarWidth);
dismissAfter.Add(ww); dismissAfter.Add(ww);
ww.ClickThrough = false;
ww.IsVisible = () => true;
ww.OnMouseMove = mi => items.Do(lw => ww.OnMouseMove = mi => items.Do(lw =>
{ {
lw.Background = null; ww.Background = "dialog2"; lw.Background = null; ww.Background = "dialog2";

View File

@@ -27,7 +27,6 @@ namespace OpenRA.Widgets
public string Height = "0"; public string Height = "0";
public string Delegate = null; public string Delegate = null;
public string EventHandler = null; public string EventHandler = null;
public bool ClickThrough = true;
public bool Visible = true; public bool Visible = true;
public readonly List<Widget> Children = new List<Widget>(); public readonly List<Widget> Children = new List<Widget>();
@@ -63,7 +62,6 @@ namespace OpenRA.Widgets
Width = widget.Width; Width = widget.Width;
Height = widget.Height; Height = widget.Height;
Delegate = widget.Delegate; Delegate = widget.Delegate;
ClickThrough = widget.ClickThrough;
Visible = widget.Visible; Visible = widget.Visible;
Bounds = widget.Bounds; Bounds = widget.Bounds;

View File

@@ -447,7 +447,6 @@ Background@MAP_CHOOSER:
Id:MAP_TEMPLATE Id:MAP_TEMPLATE
Width:PARENT_RIGHT-28 Width:PARENT_RIGHT-28
Height:25 Height:25
ClickThrough:false
X:2 X:2
Y:0 Y:0
Visible:false Visible:false

View File

@@ -204,7 +204,6 @@ Container@INGAME_ROOT:
Y:WINDOW_BOTTOM - HEIGHT - 30 Y:WINDOW_BOTTOM - HEIGHT - 30
Width: 760 Width: 760
Height: 200 Height: 200
ClickThrough: True
DrawBackground: False DrawBackground: False
RemoveTime:250 RemoveTime:250
ChatEntry@CHAT_ENTRY: ChatEntry@CHAT_ENTRY:
@@ -213,7 +212,6 @@ Container@INGAME_ROOT:
Y:WINDOW_BOTTOM - HEIGHT Y:WINDOW_BOTTOM - HEIGHT
Width: 760 Width: 760
Height: 30 Height: 30
ClickThrough: True
Background@DEVELOPERMODE_BG: Background@DEVELOPERMODE_BG:
Id:DEVELOPERMODE_BG Id:DEVELOPERMODE_BG
Delegate:DeveloperModeDelegate Delegate:DeveloperModeDelegate
@@ -414,7 +412,6 @@ Container@OBSERVER_ROOT:
Y:WINDOW_BOTTOM - HEIGHT - 30 Y:WINDOW_BOTTOM - HEIGHT - 30
Width: 760 Width: 760
Height: 200 Height: 200
ClickThrough: True
DrawBackground: False DrawBackground: False
RemoveTime:250 RemoveTime:250
ChatEntry@CHAT_ENTRY: ChatEntry@CHAT_ENTRY:
@@ -423,7 +420,6 @@ Container@OBSERVER_ROOT:
Y:WINDOW_BOTTOM - HEIGHT Y:WINDOW_BOTTOM - HEIGHT
Width: 760 Width: 760
Height: 30 Height: 30
ClickThrough: True
Background@FMVPLAYER: Background@FMVPLAYER:
Id:FMVPLAYER Id:FMVPLAYER
Width:WINDOW_RIGHT Width:WINDOW_RIGHT

View File

@@ -73,7 +73,6 @@ Background@MAINMENU_BG:
Text:Video Player Text:Video Player
Bold:True Bold:True
Background@PERF_BG: Background@PERF_BG:
ClickThrough:true
Id:PERF_BG Id:PERF_BG
Background:dialog4 Background:dialog4
Delegate:PerfDebugDelegate Delegate:PerfDebugDelegate
@@ -218,7 +217,6 @@ Background@MUSIC_MENU:
Id:MUSIC_TEMPLATE Id:MUSIC_TEMPLATE
Width:PARENT_RIGHT-28 Width:PARENT_RIGHT-28
Height:25 Height:25
ClickThrough:false
X:2 X:2
Y:0 Y:0
Visible:false Visible:false

View File

@@ -26,7 +26,6 @@ Background@REPLAYBROWSER_BG:
Id:REPLAY_TEMPLATE Id:REPLAY_TEMPLATE
Width:PARENT_RIGHT-28 Width:PARENT_RIGHT-28
Height:25 Height:25
ClickThrough:false
X:2 X:2
Y:0 Y:0
Visible:false Visible:false

View File

@@ -120,7 +120,6 @@ Background@JOINSERVER_BG:
Id:SERVER_TEMPLATE Id:SERVER_TEMPLATE
Width:PARENT_RIGHT-28 Width:PARENT_RIGHT-28
Height:25 Height:25
ClickThrough:false
X:2 X:2
Y:0 Y:0
Visible:false Visible:false

View File

@@ -31,7 +31,6 @@ Background@VIDEOPLAYER_MENU:
Id:VIDEO_TEMPLATE Id:VIDEO_TEMPLATE
Width:PARENT_RIGHT-28 Width:PARENT_RIGHT-28
Height:25 Height:25
ClickThrough:false
X:2 X:2
Y:0 Y:0
Visible:false Visible:false

View File

@@ -417,7 +417,6 @@ Background@MAP_CHOOSER:
Id:MAP_TEMPLATE Id:MAP_TEMPLATE
Width:PARENT_RIGHT-28 Width:PARENT_RIGHT-28
Height:25 Height:25
ClickThrough:false
X:2 X:2
Y:0 Y:0
Visible:false Visible:false

View File

@@ -203,7 +203,6 @@ Container@INGAME_ROOT:
Y:WINDOW_BOTTOM - HEIGHT - 30 Y:WINDOW_BOTTOM - HEIGHT - 30
Width: 760 Width: 760
Height: 200 Height: 200
ClickThrough: True
DrawBackground: False DrawBackground: False
RemoveTime:250 RemoveTime:250
ChatEntry@CHAT_ENTRY: ChatEntry@CHAT_ENTRY:
@@ -212,7 +211,6 @@ Container@INGAME_ROOT:
Y:WINDOW_BOTTOM - HEIGHT Y:WINDOW_BOTTOM - HEIGHT
Width: 760 Width: 760
Height: 30 Height: 30
ClickThrough: True
Background@DEVELOPERMODE_BG: Background@DEVELOPERMODE_BG:
Id:DEVELOPERMODE_BG Id:DEVELOPERMODE_BG
Delegate:DeveloperModeDelegate Delegate:DeveloperModeDelegate

View File

@@ -220,7 +220,6 @@ Background@MUSIC_MENU:
Id:MUSIC_TEMPLATE Id:MUSIC_TEMPLATE
Width:PARENT_RIGHT-28 Width:PARENT_RIGHT-28
Height:25 Height:25
ClickThrough:false
X:2 X:2
Y:0 Y:0
Visible:false Visible:false

View File

@@ -122,7 +122,6 @@ Background@JOINSERVER_BG:
Id:SERVER_TEMPLATE Id:SERVER_TEMPLATE
Width:PARENT_RIGHT-28 Width:PARENT_RIGHT-28
Height:25 Height:25
ClickThrough:false
X:2 X:2
Y:0 Y:0
Visible:false Visible:false

View File

@@ -32,7 +32,6 @@ Background@VIDEOPLAYER_MENU:
Id:VIDEO_TEMPLATE Id:VIDEO_TEMPLATE
Width:PARENT_RIGHT-28 Width:PARENT_RIGHT-28
Height:25 Height:25
ClickThrough:false
X:2 X:2
Y:0 Y:0
Visible:false Visible:false

View File

@@ -1,18 +1,15 @@
Container: Background@MAINMENU_BG:
ClickThrough:true Id:MAINMENU_BG
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:250
Height:65
Delegate:MainMenuButtonsDelegate
Children: Children:
Background@MAINMENU_BG: Button@MAINMENU_BUTTON_QUIT:
Id:MAINMENU_BG Id:MAINMENU_BUTTON_QUIT
X:(WINDOW_RIGHT - WIDTH)/2 X:45
Y:(WINDOW_BOTTOM - HEIGHT)/2 Y:20
Width:250 Width:160
Height:65 Height:25
Delegate:MainMenuButtonsDelegate Text:Quit
Children:
Button@MAINMENU_BUTTON_QUIT:
Id:MAINMENU_BUTTON_QUIT
X:45
Y:20
Width:160
Height:25
Text:Quit

View File

@@ -447,7 +447,6 @@ Background@MAP_CHOOSER:
Id:MAP_TEMPLATE Id:MAP_TEMPLATE
Width:PARENT_RIGHT-28 Width:PARENT_RIGHT-28
Height:25 Height:25
ClickThrough:false
X:2 X:2
Y:0 Y:0
Visible:false Visible:false

View File

@@ -211,7 +211,6 @@ Container@INGAME_ROOT:
Y:WINDOW_BOTTOM - HEIGHT - 30 Y:WINDOW_BOTTOM - HEIGHT - 30
Width: 760 Width: 760
Height: 200 Height: 200
ClickThrough: True
DrawBackground: False DrawBackground: False
RemoveTime:250 RemoveTime:250
ChatEntry@CHAT_ENTRY: ChatEntry@CHAT_ENTRY:
@@ -220,7 +219,6 @@ Container@INGAME_ROOT:
Y:WINDOW_BOTTOM - HEIGHT Y:WINDOW_BOTTOM - HEIGHT
Width: 760 Width: 760
Height: 30 Height: 30
ClickThrough: True
Background@DEVELOPERMODE_BG: Background@DEVELOPERMODE_BG:
Id:DEVELOPERMODE_BG Id:DEVELOPERMODE_BG
Delegate:DeveloperModeDelegate Delegate:DeveloperModeDelegate
@@ -421,7 +419,6 @@ Container@OBSERVER_ROOT:
Y:WINDOW_BOTTOM - HEIGHT - 30 Y:WINDOW_BOTTOM - HEIGHT - 30
Width: 760 Width: 760
Height: 200 Height: 200
ClickThrough: True
DrawBackground: False DrawBackground: False
RemoveTime:250 RemoveTime:250
ChatEntry@CHAT_ENTRY: ChatEntry@CHAT_ENTRY:
@@ -430,7 +427,6 @@ Container@OBSERVER_ROOT:
Y:WINDOW_BOTTOM - HEIGHT Y:WINDOW_BOTTOM - HEIGHT
Width: 760 Width: 760
Height: 30 Height: 30
ClickThrough: True
Background@FMVPLAYER: Background@FMVPLAYER:
Id:FMVPLAYER Id:FMVPLAYER
Width:WINDOW_RIGHT Width:WINDOW_RIGHT

View File

@@ -219,7 +219,6 @@ Background@MUSIC_MENU:
Id:MUSIC_TEMPLATE Id:MUSIC_TEMPLATE
Width:PARENT_RIGHT-28 Width:PARENT_RIGHT-28
Height:25 Height:25
ClickThrough:false
X:2 X:2
Y:0 Y:0
Visible:false Visible:false

View File

@@ -26,7 +26,6 @@ Background@REPLAYBROWSER_BG:
Id:REPLAY_TEMPLATE Id:REPLAY_TEMPLATE
Width:PARENT_RIGHT-28 Width:PARENT_RIGHT-28
Height:25 Height:25
ClickThrough:false
X:2 X:2
Y:0 Y:0
Visible:false Visible:false

View File

@@ -120,7 +120,6 @@ Background@JOINSERVER_BG:
Id:SERVER_TEMPLATE Id:SERVER_TEMPLATE
Width:PARENT_RIGHT-28 Width:PARENT_RIGHT-28
Height:25 Height:25
ClickThrough:false
X:2 X:2
Y:0 Y:0
Visible:false Visible:false

View File

@@ -31,7 +31,6 @@ Background@VIDEOPLAYER_MENU:
Id:VIDEO_TEMPLATE Id:VIDEO_TEMPLATE
Width:PARENT_RIGHT-28 Width:PARENT_RIGHT-28
Height:25 Height:25
ClickThrough:false
X:2 X:2
Y:0 Y:0
Visible:false Visible:false