1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 20:22:55 +08:00

Add better focus handling and padding/margin updates.

This commit is contained in:
Dean Herbert 2017-02-20 21:11:09 +09:00
parent e3fa49dda7
commit 6a83620589
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
2 changed files with 20 additions and 7 deletions

View File

@ -4,10 +4,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Primitives;
using osu.Framework.MathUtils;
using osu.Framework.Threading;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using OpenTK; using OpenTK;
@ -45,7 +46,7 @@ namespace osu.Game.Online.Chat.Drawables
Direction = FlowDirections.Vertical, Direction = FlowDirections.Vertical,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Spacing = new Vector2(1, 1) Padding = new MarginPadding { Left = 20, Right = 20 }
} }
} }
} }

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
@ -20,10 +21,12 @@ using osu.Game.Online.Chat.Drawables;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using OpenTK.Graphics;
using osu.Framework.Input;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
public class ChatOverlay : OverlayContainer, IOnlineComponent public class ChatOverlay : FocusedOverlayContainer, IOnlineComponent
{ {
private DrawableChannel channelDisplay; private DrawableChannel channelDisplay;
@ -50,7 +53,8 @@ namespace osu.Game.Overlays
{ {
Depth = float.MaxValue, Depth = float.MaxValue,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(0.1f).Opacity(0.4f), Colour = Color4.Black,
Alpha = 0.9f,
}, },
content = new Container content = new Container
{ {
@ -62,13 +66,14 @@ namespace osu.Game.Overlays
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Height = 50, Height = 40,
Padding = new MarginPadding(5), Padding = new MarginPadding(5),
Children = new Drawable[] Children = new Drawable[]
{ {
inputTextBox = new FocusedTextBox inputTextBox = new FocusedTextBox
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.Both,
Height = 1,
PlaceholderText = "type your message", PlaceholderText = "type your message",
Exit = () => State = Visibility.Hidden, Exit = () => State = Visibility.Hidden,
OnCommit = postMessage, OnCommit = postMessage,
@ -79,6 +84,13 @@ namespace osu.Game.Overlays
}); });
} }
protected override bool OnFocus(InputState state)
{
//this is necessary as inputTextBox is masked away and therefore can't get focus :(
inputTextBox.TriggerFocus();
return false;
}
private void postMessage(TextBox sender, bool newText) private void postMessage(TextBox sender, bool newText)
{ {
var postText = sender.Text; var postText = sender.Text;