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

Allow selection of text in mod info panel #2610

Merged
merged 4 commits into from
Dec 14, 2018

Conversation

DasSkelett
Copy link
Member

@DasSkelett DasSkelett commented Dec 9, 2018

Feature request

#2591 asked for the ability to select and copy the text out of some labels in the mod info panel.
This was not possible because you cant copy text out of labels.

Changes

I changed the mod name (at the top), the mod author and the mod identifier label to not-editable textboxes with the same background and text color as the labels had before. Also I removed the per standard in textboxes activated border, so they are seamless.
They look like the labels before (in dark and in white themes, at least with mono on Kubuntu), but now you can copy text.
Some pics:
bright dark

Important

I directly manipulated the MainModInfo.Designer.cs in MonoDevelop, and as far as I know, Visual Studio doesn't really like this, so someone using VS should verify whether VS complains/changes something back by itself or not.
I also renamed the comments inside the Designer.cs for this, but you never know.

Closes #2591

Changed MetadataModuleName, MetadataIdentifier and MetadataModuleAuthor labels
to textboxes so you can copy the text
@yalov
Copy link
Contributor

yalov commented Dec 10, 2018

it isn't a white background on Win10.
And for the consistency other mega-tag values and description also could be ReadOnly TextBox

@DasSkelett
Copy link
Member Author

DasSkelett commented Dec 10, 2018

Which version/commit did you test @yalov? The first one with SystemColors.Menu or the last one with SystemColors.Control?

I'm not sure if it is needed to have the version number, the license or the release status as a textbox. I can't image that someone wants to copy that text. But for the sake of everything being the same, it would make sense indeed.

@DasSkelett
Copy link
Member Author

DasSkelett commented Dec 10, 2018

Ah I think I got it. For the ModuleName textbox I should use SystemColors.Control and for the lower ones SystemColors.Menu.
I'll change it and boot up Windows real quick to verify.

Ah ffs, that's still gray instead of white. Why are there so many colors? And why can't mono render in standard Windows colors as an option?

@HebaruSan HebaruSan added Enhancement New features or functionality GUI Issues affecting the interactive GUI Pull request labels Dec 10, 2018
@DasSkelett DasSkelett changed the title Allow selection of text in mod info panel WIP: Allow selection of text in mod info panel Dec 10, 2018
@DasSkelett
Copy link
Member Author

Ooooookay, I got it now, really:
Upper panel: Windows+Linux SystemColors.Control
Lower panel: Windows SystemColors.Window | Linux SystemColors.Control

See:
e_linux-bright e_linux-dark e_windows (The mod name textbox always has .Control)

I begin to assume this might be a mono implementation bug?

Nevertheless, either we go the complex way and set the background color of the labels during runtime with OS checks, or we just change all labels in the right column to textboxes, so at least they have the same colors. That would solve @yalov's request to.
The third way I see is to change the background color of the tab pages to the same as the upper panel (like it seems to be on Linux already), if that's possible. Theoretically the easiest way.

@HebaruSan
Copy link
Member

It's not a bug, just different styles of tabstrips. Mono's is how tabs looked in Windows 98.

Can you check what value MetadataTabPage.BackColor has on Windows? It seems to be Control on Linux in my testing. There's gotta be some value somewhere that already has the right color.

@DasSkelett
Copy link
Member Author

DasSkelett commented Dec 10, 2018

On Windows it throws the following error:

Unbehandelte Ausnahme: System.ArgumentException: Das Steuerelement unterstützt keine transparenten Hintergrundfarben.
   bei System.Windows.Forms.Control.set_BackColor(Color value)
   bei System.Windows.Forms.TextBoxBase.set_BackColor(Color value)
   bei CKAN.MainModInfo.<>c__DisplayClass2_0.<.ctor>b__0()
   bei CKAN.Util.Invoke[T](T obj, Action action)
   bei CKAN.MainModInfo..ctor()
   bei CKAN.Main.InitializeComponent()
   bei CKAN.Main..ctor(String[] cmdlineArgs, KSPManager mgr, GUIUser user, Boolean showConsole)
   bei CKAN.GUI.Main_(String[] args, KSPManager manager, Boolean showConsole)
   bei CKAN.CmdLine.MainClass.Gui(KSPManager manager, GuiOptions options, String[] args)
   bei CKAN.CmdLine.MainClass.RunSimpleAction(Options cmdline, CommonOptions options, String[] args, IUser user, KSPManager manager)
   bei CKAN.CmdLine.MainClass.Execute(KSPManager manager, CommonOptions opts, String[] args)
   bei CKAN.CmdLine.MainClass.Main(String[] args)

-> The control element does not support transparent backgrounds.
I tried to move it outside the Designer into the constructor of MainModInfo, but same error...

public MainModInfo()
{
    InitializeComponent()
    System.Drawing.Color newOne = MetadataTabPage.BackColor;
    Util.Invoke(MetadataModuleAuthorTextBox, () => MetadataModuleAuthorTextBox.BackColor = newOne);
    ...
}

@HebaruSan
Copy link
Member

Hmm, apparently the TextBox has some protected members that can enable transparency:

https://stackoverflow.com/questions/16050249/transparency-for-windows-forms-textbox

@DasSkelett
Copy link
Member Author

Yep, that works. Nice!
ckan1 ckan2

Created partial class  TransparentTextBox : TextBox in mainModInfo.Designer.cs
to be able to have a transparent background
Moved TransparentTextBox to new file and changed the other labels to textboxes too
@DasSkelett DasSkelett changed the title WIP: Allow selection of text in mod info panel Allow selection of text in mod info panel Dec 11, 2018
@HebaruSan HebaruSan self-requested a review December 13, 2018 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New features or functionality GUI Issues affecting the interactive GUI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants