Skip to content

Restore Main_no_icons2 behavior for inline subitems #1172

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

Merged
merged 4 commits into from
Oct 15, 2022

Conversation

among-us-official
Copy link

Fix regression caused by b89aaed.
#1088 (comment)

The original commit fixed a bug where the icons would not be generated for the second column's icon size. However, the bugged behavior had masked a discrepancy between the icons generated for the inlined submenus (inserted as buttons) in CMenuContainer::AddStandardItems and the drawing settings for them in MenuSkin::LoadSkin. Here are the snippets in order:

CItemManager::TIconSizeType iconSizeType;
int refreshFlags;
if (bSearchProvider7 || m_bSubMenu)
{
iconSizeType=CItemManager::ICON_SIZE_TYPE_SMALL;
refreshFlags=CItemManager::INFO_SMALL_ICON;
}
else if (s_bWin7Style)
{
iconSizeType=CItemManager::ICON_SIZE_TYPE_EXTRA_LARGE;
refreshFlags=CItemManager::INFO_EXTRA_LARGE_ICON;
}
else if (mainIconSize==MenuSkin::ICON_SIZE_LARGE)
{
iconSizeType=CItemManager::ICON_SIZE_TYPE_LARGE;
refreshFlags=CItemManager::INFO_LARGE_ICON;
}
else if (mainIconSize==MenuSkin::ICON_SIZE_SMALL)
{
iconSizeType=CItemManager::ICON_SIZE_TYPE_SMALL;
refreshFlags=CItemManager::INFO_SMALL_ICON;
}
else
{
iconSizeType=CItemManager::ICON_SIZE_TYPE_SMALL;
refreshFlags=0;
}
if (pStdItem->link)
refreshFlags|=CItemManager::INFO_LINK|CItemManager::INFO_METRO;
if ((refreshFlags&CItemManager::INFO_ICON)==0)
item.pItemInfo=NULL;

case COLUMN2_INLINE:
settings.iconSize=Main2_icon_size!=ICON_SIZE_NONE?Main2_icon_size:Main_icon_size;

Since previously mainIconSize was always equal to Main_icon_size (first column's icons), the correct icons were created for the subitems. This workaround restores the old, more correct behavior by saving mainIconSize and restoring it after the related code is over.

Maybe a more permanent solution is to refactor the icon code to run after AddStandardItems, when we know about the icon sizes for each item?

@AppVeyorBot
Copy link

Build Open-Shell-Menu 4.4.180-judrkdjd completed (commit 125b522da9 by @among-us-official)

@ge0rdi ge0rdi self-requested a review October 13, 2022 16:23
@blackcrack
Copy link

a thank you button.. 🤔 or an 🤗 button would nice at the reacting 😊

@ge0rdi
Copy link
Member

ge0rdi commented Oct 14, 2022

@bonzibudd

Could you, please, verify that Insert sub-items as buttons option works correctly for you using build from this PR?
Note that you should back-up your setting prior to using PR build and then also remove it after testing.

@bonzibudd
Copy link
Member

Yes, I believe it is working normally now!

@ge0rdi
Copy link
Member

ge0rdi commented Oct 14, 2022

@among-us-official

I was rather thinking about change like this (applicable on master):

diff --git a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp
index b6d6967..a859ab2 100644
--- a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp
+++ b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp
@@ -1071,7 +1071,7 @@ void CMenuContainer::AddStandardItems( void )
 		const StdMenuItem *pInlineParent=NULL;
 		int searchProviderIndex=-1;
 		m_SearchProvidersCount=0;
-		MenuSkin::TIconSize mainIconSize=s_Skin.Main_icon_size;
+		bool bSecondColumn = false;
 		for (const StdMenuItem *pStdItem=m_pStdItem;;pStdItem++)
 		{
 			if (pStdItem->id==MENU_LAST)
@@ -1089,9 +1089,8 @@ void CMenuContainer::AddStandardItems( void )
 			if (m_bSubMenu && pStdItem->id==s_ShutdownCommand)
 				continue;
 
-			const bool bTwoColumns = (!m_bSubMenu && s_Skin.TwoColumns);
-			if (pStdItem->id==MENU_COLUMN_BREAK && bTwoColumns)
-				mainIconSize=s_Skin.Main2_icon_size;
+			if (pStdItem->id==MENU_COLUMN_BREAK && !m_bSubMenu && s_Skin.TwoColumns)
+				bSecondColumn = true;
 
 			int stdOptions=GetStdOptions(pStdItem->id);
 			if (!(stdOptions&MENU_ENABLED)) continue;
@@ -1272,6 +1271,10 @@ void CMenuContainer::AddStandardItems( void )
 			item.bSplit=item.bFolder && (item.pStdItem->settings&StdMenuItem::MENU_SPLIT_BUTTON)!=0;
 
 			// get icon
+			MenuSkin::TIconSize mainIconSize = s_Skin.Main_icon_size;
+			if (bSecondColumn && !item.bInline)
+				mainIconSize = s_Skin.Main2_icon_size;
+
 			CItemManager::TIconSizeType iconSizeType;
 			int refreshFlags;
 			if (bSearchProvider7 || m_bSubMenu)

It should be simpler (no need for weird old value storing/restoring) and hopefully clear too.
What do you think?

@among-us-official
Copy link
Author

That's clearer, yeah.

@ge0rdi
Copy link
Member

ge0rdi commented Oct 14, 2022

Oki. Could you modify the PR then? And test whether it works as expected?

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@among-us-official
Copy link
Author

@ge0rdi Tested it, works.

ge0rdi
ge0rdi previously approved these changes Oct 14, 2022
@ge0rdi
Copy link
Member

ge0rdi commented Oct 14, 2022

@among-us-official
Thank you.

@bonzibudd
Could you, please, test once more with latest build?

@bonzibudd
Copy link
Member

bonzibudd commented Oct 14, 2022

Just tried with the newer build, while my default config with the sub-items works fine, using Main2_icon_size=small with sub-items results in corrupted icons.
image

Initial commit works fine:
image

Any thoughts?

@ge0rdi
Copy link
Member

ge0rdi commented Oct 14, 2022

@bonzibudd
Could you share the skin you are using and your settings?

@ge0rdi
Copy link
Member

ge0rdi commented Oct 14, 2022

Also, it's quite weird that first line looks good and only subsequent are corrupted.
Maybe some caching issue?
Could you try Settings -> Backup -> Clear cached information ?

@bonzibudd
Copy link
Member

Small Main2 w subitems.zip

Skin is just a quick edit to my existing skin that adds main2_icon_size=small to the start of the script. The XML adds the sub-items as they are shown in the picture. Interestingly, when I clear the cache, the top row also corrupts.
image

@among-us-official
Copy link
Author

@bonzibudd Thanks so much for testing!! Can't believe that in less than a day I've forgotten what that MenuSkin::ICON_SIZE_NONE check was doing. I've put it back in, it should now work correctly.

@AppVeyorBot
Copy link

@bonzibudd
Copy link
Member

@among-us-official Yes, it seems to be working again. Thank you for your help with this!

@ge0rdi
Copy link
Member

ge0rdi commented Oct 15, 2022

Can't believe that in less than a day I've forgotten what that MenuSkin::ICON_SIZE_NONE check was doing. I've put it back in, it should now work correctly.

You could have explained why it is needed like that :)
But I guess I have figured it out too.

It is clear from sking manager's code that Main2_icon_size is used for second column except when the column is inline and Main2_icon_size is none. In such case Main_icon_size is used instead.

Now the code in menu container matches the one in skin manager. So hopefully it will be final fix :)

@ge0rdi ge0rdi self-requested a review October 15, 2022 06:42
@ge0rdi
Copy link
Member

ge0rdi commented Oct 15, 2022

I have tested the change as well and it looks that everything works as expected.
@among-us-official @bonzibudd Thank you guys.

@ge0rdi ge0rdi merged commit 9606e11 into Open-Shell:master Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants