pyfa-org / Pyfa

Python fitting assistant, cross-platform fitting tool for EVE Online
GNU General Public License v3.0
1.6k stars 406 forks source link

Scale attribute tab column width to window size #1878

Open DarkFenX opened 5 years ago

DarkFenX commented 5 years ago

Currently width is static (set specifically for windows stats window size most likely), which leads to truncation of some attribute names / values:

image

blitzmann commented 5 years ago

I feel like this has been a long standing issue, and it's always bugged me as well. Never had a chance to look into it, so adding a help wanted tag in case someone wants to pick it up

DarkFenX commented 5 years ago

For the reference - how it looked before:

image

blitzmann commented 5 years ago

Oh, so not a long standing issue, only since attribute grouping... must have been thinking of something else then.

Will take a look

blitzmann commented 5 years ago

k, got a fix in place. Was kinda weird - you can set the column width based on the items within tree, however it relied on GetClientSize() which was returning (16,16) on windows (unsure on Linux). So I also had to manually set a large size to the Panel itself - I'm not sure why it never inherited the parent size...

But right now the columns should expand to the largest size item in the column. I will have to ask the wx group why the panel itself did not expand to it's parent - probably something I'm missing...

DarkFenX commented 5 years ago

@blitzmann is first column still statically sized?

image

image

Still seems to be bugged. I will remove "done" for now if you don't mind.

DarkFenX commented 5 years ago

Covops cloak on a fit looks like this:

image

Is there a way to put width limit to autosizing behavior (or downside it if sum of columns is too wide)?

blitzmann commented 5 years ago

Is there a way to put width limit to autosizing behavior (or downside it if sum of columns is too wide)?

Unfortunately no. I did briefly look into this, but it would involve a custom calculation that I didn't have time to do (find width of client area, find calculated width of each column, and cap them at 33% max, or whatever proportion we want).

Here's the code for how it determines size: https://github.com/wxWidgets/Phoenix/blob/master/wx/lib/agw/hypertreelist.py#L4529 (note the option for LIST_AUTOSIZE_CONTENT_OR_HEADER is actually bugged, at least for me, and result in an exception. Haven't yet reported this).

I believe the first column is still cutting off because it's technically in a tree, which causes it to have a bit of padding on the left side. I don't know if the calcs take that into consideration when doing it's calcs, butit doesn't look like it (might also be due to the images maybe?). We could probably add a margin of a few pixels for the first column, probably something like

self.paramList.SetColumnWidth(i, self.paramList._main_win.GetBestColumnWidth(i) + (5 if i == 0 else 0)

DarkFenX commented 5 years ago

Just to link issues - character editor (#1886) exhibits similar behavior now. Left column is sized according to category headers, but not to category contents.

blitzmann commented 5 years ago

as an update, character editor was fixed by setting explicit sizes for the columns, which is something we won't be able to do with the item stats since the window can be resized...

Unsure of what best course of action is besides developing custom calculations, and honestly unsure if it's worth it since there's always going to be either three columns full width but a horizontal scroll, or some columns cut off. :/

We could attempt the following to alleviate the issue:

DarkFenX commented 5 years ago

Imo perfect case would be to make 1st column wide enough to fit longest attribute name, and then remaining space for one attribute column (original item) or split 50/50 for two columns (modified item), no horizontal scrolling. Some clipping for values is alright, especially in the case on the screenshot.

Is there a way to autosize first column correctly? If not, we might put in platform-specific base values.

blitzmann commented 5 years ago

This would work:

        # column autosizing doesn't work quite like we want it to
        x, _ = self.paramList.GetClientSize()
        x -= 30 # still too much (probably due to scrollbar?), lob some off

        col1 = self.paramList._main_win.GetBestColumnWidth(0) + 25  # buffer because GetBestColumnWidth doesn't seem to account for tree padding?
        self.paramList.SetColumnWidth(0, col1)

        remainder = x - col1
        remainingColumns = self.paramList.GetMainWindow().GetColumnCount() - 1

        for i in range(remainingColumns):
            self.paramList.SetColumnWidth(i + 1, math.floor(remainder/remainingColumns))

However, it's dependent on the client size being calculated correctly, which currently isn't the case (it's not calculated correctly on load. If you switch between Raw and Normal view, the size seems to be calculated correctly). Until we can get the sizes fixed, think we should leave it alone. Feel free to play around with it though and see if you can figure it out.

I will try to get a simple example together for wxPython community -not sure if it's a bug or just me not understanding how size inheritance works