Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Theme support for Log Panel #2203

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Editor/AGS.Editor/GUI/LogPanel.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions Editor/AGS.Editor/GUI/LogPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,5 +302,29 @@ private void logTextBox_VScroll(object sender, EventArgs e)
_glue = IsScrollAtBottom();
}
}

private void LoadColorTheme(ColorTheme t)
{

t.SetColor("log-panel/background", c => BackColor = c);
t.SetColor("log-panel/splitter", c => splitContainer.BackColor = c);
t.SetColor("log-panel/background", c => logTextBox.BackColor = c);
t.SetColor("log-panel/foreground", c => logTextBox.ForeColor = c);
t.PropertyGridHelper(propertyGrid, "log-panel/grid");
if (t.Has("tool-bar"))
{
t.SetColor("tool-bar/background", c => toolStrip.BackColor = c);
toolStrip.Renderer = t.GetToolStripRenderer("tool-bar");
}
}

private void LogPanel_Load(object sender, EventArgs e)
{
if (!DesignMode)
{
Hacks.SetRichTextBoxMargins(logTextBox, 12, 12);
Factory.GUIController.ColorThemes.Apply(LoadColorTheme);
}
}
}
}
11 changes: 11 additions & 0 deletions Editor/AGS.Editor/Hacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public static class Hacks
private const int EM_REPLACESEL = 0x00C2;
private const int EM_GETSCROLLPOS = WM_USER + 221;
private const int EM_SETSCROLLPOS = WM_USER + 222;
private const int EM_SETMARGINS = 0xD3;
private const int EC_LEFTMARGIN = 0x1;
private const int EC_RIGHTMARGIN = 0x2;
// TreeView messages
private const int TV_FIRST = 0x1100;
private const int TVM_GETEDITCONTROL = (TV_FIRST + 15);
Expand Down Expand Up @@ -89,6 +92,14 @@ public static void ReplaceSelectedText(this RichTextBox rtb, int at, int length,
Marshal.FreeHGlobal(strPtr);
}

/// <summary>
/// Sets RichTextBox's margins
/// </summary>
public static void SetRichTextBoxMargins(this RichTextBox rtb, int left, int right)
{
SendMessage(rtb.Handle, EM_SETMARGINS, (EC_LEFTMARGIN | EC_RIGHTMARGIN), (IntPtr)(right * 0x10000 + left));
}

// Hack to get around the fact that the BeforeLabelEdit event provides no way to
// let you change the text they're about to edit
public static void SetTreeViewEditText(TreeView tree, string myText)
Expand Down