~ted/unity/menu-ref

« back to all changes in this revision

Viewing changes to dash/FilterBasicButton.cpp

  • Committer: Jay Taoko
  • Date: 2012-09-18 11:55:33 UTC
  • mfrom: (2696.3.6 unity.dash-to-preview)
  • mto: This revision was merged to the branch mainline in revision 2719.
  • Revision ID: jay.taoko@canonical.com-20120918115533-ksgl1o12m1wfxy9r
* Merged with Unity trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
  SetAcceptKeyNavFocusOnMouseDown(false);
72
72
  SetAcceptKeyNavFocusOnMouseEnter(true);
73
73
 
 
74
  //SetRedirectRenderingToTexture(true);
 
75
  //SetCopyPreviousFboTexture(false);
 
76
  clear_before_draw_ = true;
 
77
 
74
78
  key_nav_focus_change.connect([&] (nux::Area*, bool, nux::KeyNavDirection)
75
79
  {
76
80
    QueueDraw();
128
132
  return ret;
129
133
}
130
134
 
131
 
void FilterBasicButton::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
 
135
void FilterBasicButton::SetClearBeforeDraw(bool clear_before_draw)
 
136
{
 
137
  clear_before_draw_ = clear_before_draw;
 
138
}
 
139
 
 
140
void FilterBasicButton::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)
132
141
{
133
142
  nux::Geometry const& geo = GetGeometry();
134
143
 
135
 
  gPainter.PaintBackground(GfxContext, geo);
136
144
  // set up our texture mode
137
145
  nux::TexCoordXForm texxform;
138
146
  texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
140
148
 
141
149
  // clear what is behind us
142
150
  unsigned int alpha = 0, src = 0, dest = 0;
143
 
  GfxContext.GetRenderStates().GetBlend(alpha, src, dest);
144
 
  GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
 
151
  graphics_engine.GetRenderStates().GetBlend(alpha, src, dest);
 
152
  if (RedirectedAncestor() && clear_before_draw_)
 
153
  {
 
154
    // This is necessary when doing redirected rendering.
 
155
    // Clean the area below this view before drawing anything.
 
156
    graphics_engine.GetRenderStates().SetBlend(false);
 
157
    graphics_engine.QRP_Color(GetX(), GetY(), GetWidth(), GetHeight(), nux::Color(0.0f, 0.0f, 0.0f, 0.0f));
 
158
  }
 
159
  graphics_engine.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
145
160
 
146
161
  nux::Color col = nux::color::Black;
147
162
  col.alpha = 0;
148
 
  GfxContext.QRP_Color(geo.x,
 
163
  graphics_engine.QRP_Color(geo.x,
149
164
                       geo.y,
150
165
                       geo.width,
151
166
                       geo.height,
159
174
  else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRESSED)
160
175
    texture = active_->GetTexture();
161
176
 
162
 
  GfxContext.QRP_1Tex(geo.x,
 
177
  graphics_engine.QRP_1Tex(geo.x,
163
178
                      geo.y,
164
179
                      geo.width,
165
180
                      geo.height,
169
184
 
170
185
  if (HasKeyboardFocus())
171
186
  {
172
 
    GfxContext.QRP_1Tex(geo.x,
 
187
    graphics_engine.QRP_1Tex(geo.x,
173
188
                        geo.y,
174
189
                        geo.width,
175
190
                        geo.height,
178
193
                        nux::Color(1.0f, 1.0f, 1.0f, 1.0f));
179
194
  }
180
195
 
181
 
  GfxContext.GetRenderStates().SetBlend(alpha, src, dest);
 
196
  graphics_engine.GetRenderStates().SetBlend(alpha, src, dest);
182
197
}
183
198
 
184
199
} // namespace dash