feat: add tab pop-out
This commit is contained in:
@@ -136,6 +136,7 @@ internal class Tab {
|
|||||||
public UnreadMode UnreadMode = UnreadMode.Unseen;
|
public UnreadMode UnreadMode = UnreadMode.Unseen;
|
||||||
public bool DisplayTimestamp = true;
|
public bool DisplayTimestamp = true;
|
||||||
public InputChannel? Channel;
|
public InputChannel? Channel;
|
||||||
|
public bool PopOut;
|
||||||
|
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
public uint Unread;
|
public uint Unread;
|
||||||
@@ -184,6 +185,7 @@ internal class Tab {
|
|||||||
UnreadMode = this.UnreadMode,
|
UnreadMode = this.UnreadMode,
|
||||||
DisplayTimestamp = this.DisplayTimestamp,
|
DisplayTimestamp = this.DisplayTimestamp,
|
||||||
Channel = this.Channel,
|
Channel = this.Channel,
|
||||||
|
PopOut = this.PopOut,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+9
@@ -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>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Alliance Member.
|
/// Looks up a localized string similar to Alliance Member.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -473,4 +473,7 @@
|
|||||||
<data name="Options_SharedMode_Warning" xml:space="preserve">
|
<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>
|
<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>
|
||||||
|
<data name="ChatLog_Tabs_PopOut" xml:space="preserve">
|
||||||
|
<value>Pop out</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|||||||
+43
-2
@@ -317,9 +317,12 @@ internal sealed class ChatLog : IUiComponent {
|
|||||||
private HideState _hideState = HideState.None;
|
private HideState _hideState = HideState.None;
|
||||||
|
|
||||||
public void Draw() {
|
public void Draw() {
|
||||||
if (this.DrawChatLog()) {
|
if (!this.DrawChatLog()) {
|
||||||
this._commandHelp?.Draw();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._commandHelp?.Draw();
|
||||||
|
this.DrawPopOuts();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <returns>true if window was rendered</returns>
|
/// <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++) {
|
for (var tabI = 0; tabI < this.Ui.Plugin.Config.Tabs.Count; tabI++) {
|
||||||
var tab = this.Ui.Plugin.Config.Tabs[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 unread = tabI == this.LastTab || tab.UnreadMode == UnreadMode.None || tab.Unread == 0 ? "" : $" ({tab.Unread})";
|
||||||
var draw = ImGui.BeginTabItem($"{tab.Name}{unread}###log-tab-{tabI}");
|
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))) {
|
if (ImGui.BeginChild("##chat2-tab-sidebar", new Vector2(-1, childHeight))) {
|
||||||
for (var tabI = 0; tabI < this.Ui.Plugin.Config.Tabs.Count; tabI++) {
|
for (var tabI = 0; tabI < this.Ui.Plugin.Config.Tabs.Count; tabI++) {
|
||||||
var tab = this.Ui.Plugin.Config.Tabs[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 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);
|
var clicked = ImGui.Selectable($"{tab.Name}{unread}###log-tab-{tabI}", this.LastTab == tabI);
|
||||||
@@ -841,6 +850,12 @@ internal sealed class ChatLog : IUiComponent {
|
|||||||
anyChanged = true;
|
anyChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui.SameLine();
|
||||||
|
if (ImGuiUtil.IconButton(FontAwesomeIcon.WindowRestore, tooltip: Language.ChatLog_Tabs_PopOut)) {
|
||||||
|
tab.PopOut = true;
|
||||||
|
anyChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (anyChanged) {
|
if (anyChanged) {
|
||||||
this.Ui.Plugin.SaveConfig();
|
this.Ui.Plugin.SaveConfig();
|
||||||
}
|
}
|
||||||
@@ -849,6 +864,32 @@ internal sealed class ChatLog : IUiComponent {
|
|||||||
ImGui.EndPopup();
|
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) {
|
private unsafe int Callback(ImGuiInputTextCallbackData* data) {
|
||||||
var ptr = new ImGuiInputTextCallbackDataPtr(data);
|
var ptr = new ImGuiInputTextCallbackDataPtr(data);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user