Zren / material-decoration

Material-ish window decoration theme for KWin, with LIM, based on zzag's original design.
GNU General Public License v2.0
200 stars 17 forks source link

Option to show menu on hover #16

Closed mojtaba82 closed 3 years ago

mojtaba82 commented 4 years ago

Hi. Thank you fot this nice decortion. Please add feature to show menu only when hover on title bar.

Zren commented 4 years ago

I already have background opacity animations, so making a reveal on hover animation isn't too difficult. The hard part is having the entire menu drawn in sync as the current bg hover animation is per button. I will need another QAnimation, probably in AppMenuButtonGroup. I'll also need to rename the existing opacity property to backgroundOpacity, or hoverTween as the foreground color was also mixed on hover.

This code snippet will make all buttons transparent, and reveal just 1 button on hover.

QColor AppMenuButton::foregroundColor() const
{
    // ...
    } else {
        QColor hoverColor = Button::foregroundColor();
        QColor normalColor = QColor(hoverColor);
        normalColor.setAlphaF(0);

        return KColorUtils::mix(
            normalColor,
            hoverColor,
            opacity());
    }
}

I also need to determine if the menu should be revealed if the caption area is hovered, or if anywhere in the titlebar is hovered. If the latter, then the hover events need to be handled in Decoration. I can still keep the new opacity property in AppMenuButtonGroup though.

nicman23 commented 3 years ago

can we have this without any animation?

vosian commented 3 years ago

I'm also interested on this, even without animations

Zren commented 3 years ago

The menuonhover branch has this feature. I now need to add a config option.

I need to figure out how I want to handle the caption. It currently "dodges" the menu which isn't needed when the menu is hidden.

I should probably do a comprehensive alignment option like Breeze.

Zren commented 3 years ago

Hmm. According to the Unity video https://youtu.be/nzFXRz-b3Ns?t=40

mojtaba82 commented 3 years ago

I fork this nice decoration. and add a branch named captionmenufeatcher and merge caption and menu like unity lim. It work but I'm not professional in programming. I would be glad if you test it. Thanks

nicman23 commented 3 years ago

hey adding to this, could we have the title of the window instead of empty space?

so on no hover -> title

on hover -> menu

mojtaba82 commented 3 years ago

@nicman23

hey adding to this, could we have the title of the window instead of empty space? so on no hover -> title on hover -> menu

I implement this feature you want. you can compile and test it. https://github.com/mojtaba82/material-decoration

Zren commented 3 years ago
Zren commented 3 years ago

I've merged this feature and titlebar alignment to the master branch.

https://user-images.githubusercontent.com/416367/107437606-3e559b80-6afd-11eb-93a4-81d6525b715d.mp4

nicman23 commented 3 years ago

small bug report, the menu is visible on window creation not the title

Zren commented 3 years ago

Thanks for reporting the bug @nicman23. I fixed that bug and made the titlebar repaint when toggling always show.

trmdi commented 3 years ago

Is this a related bug?

https://user-images.githubusercontent.com/11857205/108386766-897b5700-723f-11eb-91a0-feeb5dfcc870.mp4

mojtaba82 commented 3 years ago

I have same problem occasionally.

Zren commented 3 years ago

The hover animation isn't checking if the menu is open atm. I did experience that once, but it rarely happens with Breeze's contextmenu.

Looks like I need to check (m_currentIndex != -1) in the updateOpacity func.

setOpacity(m_alwaysShow || m_hovered ? 1 : 0);
trmdi commented 3 years ago

To reproduce it, you need to click at points sit at the lower-half part of buttons... image

mojtaba82 commented 3 years ago

To reproduce it, you need to click at points sit at the lower-half part of buttons... image

I cinfirm this.

Zren commented 3 years ago

Should be fixed with https://github.com/Zren/material-decoration/commit/d0267814ec81be025f732e9ef85a28076f56a813 and https://github.com/Zren/material-decoration/commit/8873774202153d793936e75437b7924a9cf43198.

Thanks @trmdi for your PR #34. I expanded on it to add a bool showing property which represents the alwaysShow || hovered || isMenuOpen().