Chromium interface analysis Summary (6) tool menu structure

Source: Internet
Author: User
Tags gtk

Chromium uses simplemenumodel to implement menus based on cross-platform requirements. All menu models inherit from this class, you need to construct the corresponding menu based on the provided model for each platform implementation. The menu model of this tool is the wrenchmenumodel class and also inherited from simplemenumodel. Chromium uses GTK + to create the interface on the Linux platform. The menugtk class is responsible for interpreting and constructing the menu model. All menus must go through the ** menumodel to gtkmenuitem process. If you want to add or delete a menu item, you can directly modify the corresponding menumodel, and then the menugtk class automatically generates the corresponding menu.

Chromium adds buttons on the menu, while GTK does not provide the corresponding controls. Therefore, chromium compiles a custom menu item class to inherit from the menu item class of GTK +. The structure of the zoom menu item is as follows:

The full-screen button is the most complex button, because there is only one label on all other buttons, and an icon is added to this full-screen button, and the icon will change the style according to different States. No wonder it is so complicated. This button is normal when building the model. Like other buttons, there is only one more icon_idr, which is used to represent the icon resource ID. Other buttons are default-1, it is idr_fullschromiumeen_menu_button. When the menugtk class builds a menu based on the model, it really starts:

When constructing a menu item in menugtk: buildsubmenufrommodel, The buildbuttonmenuitem function is called to process menu items of the type_button_item type, if a valid image ID (idr_fullschromiumeen_menu_button) is obtained from the menu item model in buildbuttonmenuitem, The setupimageicon function is called to set the icon for the menu item, the setupimageicon function only connects the "show" signal to this menu item, which is processed by the onsubmenushowbuttonimage function. That is to say, this function is called when the menu item needs to be displayed, in this function, you can call geticonsetforid to obtain the icon resource and set it to this menu item. There is a statement in geticonsetforid: "if
(ID = idr_fullschromiumeen_menu_button) return fullschromiumeen_icon_set _; returnnull; "is that a coincidence! The returned fullschromiumeen_icon_set is initialized in the gtkthemeservice: rebuildmenuiconsets function. Of course, this function only processes this icon. Chromium has only one troublesome purpose: make full-screen buttons look more like system controls. Because the buttons with labels are highlighted in the background and reversed in the text when being activated, the system will not process the buttons with images, so chromium will do it on its own. If you want to add more icon buttons in the menu, you can skip the troublesome process of chromium and directly add the image to the button, so that there will be no "like system" behavior, you can also add more gtkiconset in the gtkthemeservice class to achieve the effect of chromium.

Chromium uses simplemenumodel to implement menus based on cross-platform requirements. All menu models inherit from this class, you need to construct the corresponding menu based on the provided model for each platform implementation. The menu model of this tool is the wrenchmenumodel class and also inherited from simplemenumodel. Chromium uses GTK + to create the interface on the Linux platform. The menugtk class is responsible for interpreting and constructing the menu model. All menus must go through the ** menumodel to gtkmenuitem process. If you want to add or delete a menu item, you can directly modify the corresponding menumodel, and then the menugtk class automatically generates the corresponding menu.

Chromium adds buttons on the menu, while GTK does not provide the corresponding controls. Therefore, chromium compiles a custom menu item class to inherit from the menu item class of GTK +. The structure of the zoom menu item is as follows:

The full-screen button is the most complex button, because there is only one label on all other buttons, and an icon is added to this full-screen button, and the icon will change the style according to different States. No wonder it is so complicated. This button is normal when building the model. Like other buttons, there is only one more icon_idr, which is used to represent the icon resource ID. Other buttons are default-1, it is idr_fullschromiumeen_menu_button. When the menugtk class builds a menu based on the model, it really starts:

When constructing a menu item in menugtk: buildsubmenufrommodel, The buildbuttonmenuitem function is called to process menu items of the type_button_item type, if a valid image ID (idr_fullschromiumeen_menu_button) is obtained from the menu item model in buildbuttonmenuitem, The setupimageicon function is called to set the icon for the menu item, the setupimageicon function only connects the "show" signal to this menu item, which is processed by the onsubmenushowbuttonimage function. That is to say, this function is called when the menu item needs to be displayed, in this function, you can call geticonsetforid to obtain the icon resource and set it to this menu item. There is a statement in geticonsetforid: "if
(ID = idr_fullschromiumeen_menu_button) return fullschromiumeen_icon_set _; returnnull; "is that a coincidence! The returned fullschromiumeen_icon_set is initialized in the gtkthemeservice: rebuildmenuiconsets function. Of course, this function only processes this icon. Chromium has only one troublesome purpose: make full-screen buttons look more like system controls. Because the buttons with labels are highlighted in the background and reversed in the text when being activated, the system will not process the buttons with images, so chromium will do it on its own. If you want to add more icon buttons in the menu, you can skip the troublesome process of chromium and directly add the image to the button, so that there will be no "like system" behavior, you can also add more gtkiconset in the gtkthemeservice class to achieve the effect of chromium.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.