如何创建Firefox的插件,单按钮(同样喜欢Echofon)? [英] How to create Firefox plugin with single button (same like Echofon)?

查看:226
本文介绍了如何创建Firefox的插件,单按钮(同样喜欢Echofon)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要如何建立 Firefox的插件自定义菜单紧凑同样喜欢Firefox窗口即可。
刚才我在Echofon看到的。这里是形象,它看起来真棒!

I want to how to create Firefox plugin with custom compact menu same like Firefox window. Just now I saw in Echofon. Here is the image, and it looks awesome!

所以,请你告诉我,我们怎么能在插件窗口创建这样的。

So, Please tell me, how we can create like that in plugin window.

推荐答案

我不认为有一个简单的解决方案。一个人必须删除默认的窗口标题栏(通过 chromemargin 属性),并通过自己的更换(使用 < XUL:标题栏> )。然后它必须以风格向右看所有的操作系​​统和主题(Windows XP中定期,Windows XP的经典主题,VISTA / 7的Aero,Vista / 7的无航空,...)。你可以得到code的通过查看镀铬所需量的IM pression://browser/skin/browser.css ,搜索appmenu - 按钮和标题栏。请记住,你只能看到款式供一个操作系统 - Firefox使用不同的主题为不同的操作系统

I don't think that there is a simple solution. One has to remove the default window title bar (via chromemargin attribute) and replace it by his own (using <xul:titlebar>). And then it has to be styled to look right with all the operating systems and themes (Windows XP regular, Windows XP classic theme, Vista/7 with Aero, Vista/7 without Aero, ...). You can get an impression of the amount of code required by looking at chrome://browser/skin/browser.css, search for "appmenu-button" and "titlebar". Keep in mind that you only see the styles for one OS - Firefox uses different themes for different operating systems.

我得到了一个例子在一起主要是在Windows 7正与航空(下拉箭头,需要由不同的图像被取代,按钮位置还是错了,当窗口最大化)。窗口本身( test.xul )看起来是这样的:

I got an example together that is mostly working on Windows 7 with Aero (dropdown arrow needs to be replaced by a different image and button position is still wrong when the window is maximized). The window itself (test.xul) looks like this:

<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="test.css" type="text/css"?>

<window
    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    title="Test window"
    width="800"
    height="500"
    chromemargin="0,-1,-1,-1">
  <titlebar id="titlebar" allowevents="true">
    <button id="appmenu-button" type="menu" label="Test">
      <menupopup/>
    </button>
    <spacer id="titlebar-spacer" flex="1"/>
    <hbox id="titlebar-buttonbox">
      <toolbarbutton class="titlebar-button" id="titlebar-min"
          oncommand="window.minimize();"/>
      <toolbarbutton class="titlebar-button" id="titlebar-max"
          oncommand="window.windowState == 1 ? window.restore() : window.maximize();"/>
      <toolbarbutton class="titlebar-button" id="titlebar-close"
          oncommand="window.close();"/>
    </hbox>
  </titlebar>


  <description flex="1">window content</description>
</window>

而在 test.css 的样式有以下几种(主要来自 browser.css 复制):

And the styles in test.css are the following (mostly copied from browser.css):

:root {
  -moz-appearance: -moz-win-borderless-glass;
  background-color: transparent;
}

#appmenu-button:hover:active,
#appmenu-button[open] {
  border-radius: 0;
}
#appmenu-button {
  -moz-appearance: none;
  -moz-user-focus: ignore;
  background-clip: padding-box;
  border-radius: 0 0 4px 4px;
  color: white;
  text-shadow: 0 0 1px rgba(0,0,0,.7),
               0 1px 1.5px rgba(0,0,0,.5);
  font-weight: bold;
  padding: 0 1.5em .05em;
  margin: 2px 0 2px;
  background-image: -moz-linear-gradient(rgb(247,182,82), rgb(215,98,10) 95%);
  border: 2px solid rgba(83,42,6,.9);
  border-top-style: none;
  -moz-border-left-colors: rgba(255,255,255,.5) rgba(83,42,6,.9);
  -moz-border-bottom-colors: rgba(255,255,255,.5) rgba(83,42,6,.9);
  -moz-border-right-colors: rgba(255,255,255,.5) rgba(83,42,6,.9);
  margin-bottom: -1px; /* compensate white outer border */
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset,
              0 0 2px 1px rgba(255,255,255,.25) inset;
}
#appmenu-button:hover:not(:active):not([open]) {
  background-image: -moz-radial-gradient(center bottom, farthest-side, rgba(252,240,89,.5) 10%, rgba(252,240,89,0) 70%),
                    -moz-radial-gradient(center bottom, farthest-side, rgb(236,133,0), rgba(255,229,172,0)),
                    -moz-linear-gradient(rgb(246,170,69), rgb(209,74,0) 95%);
  border-color: rgba(83,42,6,.9);
  box-shadow: 0 1px 0 rgba(255,255,255,.1) inset,
              0 0 2px 1px rgba(250,234,169,.7) inset,
              0 -1px 0 rgba(250,234,169,.5) inset;
}
#appmenu-button:hover:active,
#appmenu-button[open] {
  background-image: -moz-linear-gradient(rgb(246,170,69), rgb(209,74,0) 95%);
  box-shadow: 0 2px 3px rgba(0,0,0,.4) inset,
              0 1px 1px rgba(0,0,0,.2) inset;
}

#appmenu-button > .button-box {
  border-style: none;
  padding: 0px;
  margin: 0px;
}

#titlebar-spacer {
  pointer-events: none;
}

#titlebar-buttonbox {
  -moz-appearance: -moz-window-button-box;
  -moz-margin-end: 20px;
}
:root[sizemode="maximized"] #titlebar-buttonbox {
  -moz-appearance: -moz-window-button-box-maximized;
}

#titlebar-min {
  -moz-appearance: -moz-window-button-minimize;
}
#titlebar-max {
  -moz-appearance: -moz-window-button-maximize;
}
:root[sizemode=maximized] #titlebar-max {
  -moz-appearance: -moz-window-button-restore;
}
#titlebar-close {
  -moz-appearance: -moz-window-button-close;
}

我用下面的命令窗口打开:

I opened the window with the following command:

window.open("chrome://.../test.xul", "_blank", "chrome,all,centerscreen,resizable");

这是最终的结果:

这篇关于如何创建Firefox的插件,单按钮(同样喜欢Echofon)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆