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

some patch code for tab and table #56

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 3 additions & 0 deletions dock_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ func NewDockContainer(dock *Dock, dockable Dockable) *DockContainer {
d.AddChild(d.content)
return d
}
func (d *DockContainer) Header() *dockHeader {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning a private struct from a public API is not acceptable. Why do you feel you need to get access to this private, internal, field? It is being protected specifically to help prevent unexpected changes to its state and as such, I'm unlikely to want it exposed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this action there is no way to fetch the dock title's panel

return d.header
}

// Dockables returns the list of Dockables within this DockContainer, in tab order.
func (d *DockContainer) Dockables() []Dockable {
Expand Down
6 changes: 6 additions & 0 deletions dock_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"strconv"

"github.com/richardwilkes/toolbox/i18n"

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this empty line.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is goland's import grouping, it will also automatically separate it if you change it manually

"github.com/richardwilkes/unison/enums/paintstyle"
)

Expand Down Expand Up @@ -49,6 +50,11 @@ type dockHeader struct {
dragInsertIndex int
}

func (d *dockHeader) CurrentDockTabLabel() *Label {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? If you want to know the title of the current tab, you can call .CurrentDockable().Title(). There is no need to access it from here.

Copy link
Author

@ddkwork ddkwork May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, title is just a string not a panel, we need to get the label where the title is located in order to add a context menu in its coordinates to close all the tabs with one click.

index := d.owner.CurrentDockableIndex()
tabs, _ := d.partition()
return tabs[index].title
}
func newDockHeader(dc *DockContainer) *dockHeader {
d := &dockHeader{
DockHeaderTheme: DefaultDockHeaderTheme,
Expand Down
5 changes: 5 additions & 0 deletions panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"strings"

"github.com/richardwilkes/toolbox"

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this empty line.

"github.com/richardwilkes/unison/enums/pathop"
)

Expand Down Expand Up @@ -68,6 +69,10 @@ type Panel struct {
TooltipImmediate bool
}

func (p *Panel) SetParent(panel *Panel) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I think I've stated before, I will not add a .SetParent(*Panel) method. If you want to set the parent, call .AddChild(Paneler) or .AddChildAtIndex(Paneler,int) on the parent instead. This will ensure all of the other things that clients expect to happen, do happen, unlike with what this method is doing.

p.parent = panel
}

// NewPanel creates a new panel.
func NewPanel() *Panel {
p := &Panel{}
Expand Down