feat: add tab pop-out
This commit is contained in:
parent
fed6b9c5a6
commit
04783fcf02
|
@ -136,6 +136,7 @@ internal class Tab {
|
|||
public UnreadMode UnreadMode = UnreadMode.Unseen;
|
||||
public bool DisplayTimestamp = true;
|
||||
public InputChannel? Channel;
|
||||
public bool PopOut;
|
||||
|
||||
[NonSerialized]
|
||||
public uint Unread;
|
||||
|
@ -184,6 +185,7 @@ internal class Tab {
|
|||
UnreadMode = this.UnreadMode,
|
||||
DisplayTimestamp = this.DisplayTimestamp,
|
||||
Channel = this.Channel,
|
||||
PopOut = this.PopOut,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
9
ChatTwo/Resources/Language.Designer.cs
generated
9
ChatTwo/Resources/Language.Designer.cs
generated
|
@ -123,6 +123,15 @@ namespace ChatTwo.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Pop out.
|
||||
/// </summary>
|
||||
internal static string ChatLog_Tabs_PopOut {
|
||||
get {
|
||||
return ResourceManager.GetString("ChatLog_Tabs_PopOut", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Alliance Member.
|
||||
/// </summary>
|
||||
|
|
|
@ -473,4 +473,7 @@
|
|||
<data name="Options_SharedMode_Warning" xml:space="preserve">
|
||||
<value>This option is not recommended. No support will be offered if you enable this option. This option will hurt the performance of {0}.</value>
|
||||
</data>
|
||||
<data name="ChatLog_Tabs_PopOut" xml:space="preserve">
|
||||
<value>Pop out</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
|
@ -317,9 +317,12 @@ internal sealed class ChatLog : IUiComponent {
|
|||
private HideState _hideState = HideState.None;
|
||||
|
||||
public void Draw() {
|
||||
if (this.DrawChatLog()) {
|
||||
this._commandHelp?.Draw();
|
||||
if (!this.DrawChatLog()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._commandHelp?.Draw();
|
||||
this.DrawPopOuts();
|
||||
}
|
||||
|
||||
/// <returns>true if window was rendered</returns>
|
||||
|
@ -725,6 +728,9 @@ internal sealed class ChatLog : IUiComponent {
|
|||
|
||||
for (var tabI = 0; tabI < this.Ui.Plugin.Config.Tabs.Count; tabI++) {
|
||||
var tab = this.Ui.Plugin.Config.Tabs[tabI];
|
||||
if (tab.PopOut) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var unread = tabI == this.LastTab || tab.UnreadMode == UnreadMode.None || tab.Unread == 0 ? "" : $" ({tab.Unread})";
|
||||
var draw = ImGui.BeginTabItem($"{tab.Name}{unread}###log-tab-{tabI}");
|
||||
|
@ -766,6 +772,9 @@ internal sealed class ChatLog : IUiComponent {
|
|||
if (ImGui.BeginChild("##chat2-tab-sidebar", new Vector2(-1, childHeight))) {
|
||||
for (var tabI = 0; tabI < this.Ui.Plugin.Config.Tabs.Count; tabI++) {
|
||||
var tab = this.Ui.Plugin.Config.Tabs[tabI];
|
||||
if (tab.PopOut) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var unread = tabI == this.LastTab || tab.UnreadMode == UnreadMode.None || tab.Unread == 0 ? "" : $" ({tab.Unread})";
|
||||
var clicked = ImGui.Selectable($"{tab.Name}{unread}###log-tab-{tabI}", this.LastTab == tabI);
|
||||
|
@ -841,6 +850,12 @@ internal sealed class ChatLog : IUiComponent {
|
|||
anyChanged = true;
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGuiUtil.IconButton(FontAwesomeIcon.WindowRestore, tooltip: Language.ChatLog_Tabs_PopOut)) {
|
||||
tab.PopOut = true;
|
||||
anyChanged = true;
|
||||
}
|
||||
|
||||
if (anyChanged) {
|
||||
this.Ui.Plugin.SaveConfig();
|
||||
}
|
||||
|
@ -849,6 +864,32 @@ internal sealed class ChatLog : IUiComponent {
|
|||
ImGui.EndPopup();
|
||||
}
|
||||
|
||||
private void DrawPopOuts() {
|
||||
foreach (var tab in this.Ui.Plugin.Config.Tabs.Where(tab => tab.PopOut)) {
|
||||
this.DrawPopOut(tab);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawPopOut(Tab tab) {
|
||||
ImGui.SetNextWindowSize(new Vector2(350, 350) * ImGuiHelpers.GlobalScale, ImGuiCond.FirstUseEver);
|
||||
if (!ImGui.Begin($"{tab.Name}##popout", ref tab.PopOut)) {
|
||||
goto End;
|
||||
}
|
||||
|
||||
ImGui.PushID($"popout-{tab.Name}");
|
||||
|
||||
this.DrawMessageLog(tab, ImGui.GetContentRegionAvail().Y, false);
|
||||
|
||||
ImGui.PopID();
|
||||
|
||||
End:
|
||||
ImGui.End();
|
||||
|
||||
if (!tab.PopOut) {
|
||||
this.Ui.Plugin.SaveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe int Callback(ImGuiInputTextCallbackData* data) {
|
||||
var ptr = new ImGuiInputTextCallbackDataPtr(data);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user