~thomir-deactivatedaccount/unity/switcher-autopilot-test

« back to all changes in this revision

Viewing changes to plugins/unityshell/src/ShortcutView.cpp

  • Committer: Didier Roche
  • Date: 2012-03-13 11:57:33 UTC
  • mto: This revision was merged to the branch mainline in revision 2126.
  • Revision ID: didier.roche@canonical.com-20120313115733-c85oulbsszhg2hmp
Xfixes.h is used by plugins/unityshell/src/PointerBarrier* but wasn't listed in the pc file configuration. It was picked by chance by another dep

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 * Authored by: Andrea Azzarone <azzaronea@gmail.com>
17
17
 *              Jay Taoko <jay.taoko@canonical.com>
18
18
 */
19
 
 
 
19
 
20
20
#include "ShortcutView.h"
21
21
 
22
22
#include <glib/gi18n-lib.h>
53
53
  std::string header = "<b>";
54
54
  header += _("Keyboard Shortcuts");
55
55
  header += "</b>";
56
 
 
57
 
  nux::StaticText* header_view = new nux::StaticText(header, NUX_TRACKER_LOCATION);
 
56
  
 
57
  nux::StaticText* header_view = new nux::StaticText(header.c_str(), NUX_TRACKER_LOCATION);
58
58
  header_view->SetTextPointSize(20/1.33);
59
59
  header_view->SetFontName("Ubuntu");
60
60
  layout_->AddView(header_view, 1 , nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
61
 
 
62
 
  layout_->AddView(new HSeparator(), 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
63
 
 
64
 
  columns_layout_ = new nux::HLayout();
 
61
  
 
62
  layout_->AddView(new HSeparator(), 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);  
 
63
    
 
64
  columns_layout_ = new nux::HLayout();  
65
65
  columns_layout_->SetSpaceBetweenChildren(30);
66
66
  layout_->AddLayout(columns_layout_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
67
 
 
 
67
  
68
68
  // Column 1...
69
69
  columns_.push_back(new nux::VLayout());
70
70
  columns_layout_->AddLayout(columns_[0], 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
71
 
 
 
71
  
72
72
  // Column 2...
73
73
  columns_.push_back(new nux::VLayout());
74
74
  columns_layout_->AddLayout(columns_[1], 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
94
94
nux::LinearLayout* View::CreateSectionLayout(const char* section_name)
95
95
{
96
96
  nux::VLayout* layout = new nux::VLayout(NUX_TRACKER_LOCATION);
97
 
 
98
 
  std::string name("<b>");
99
 
  name += glib::String(g_markup_escape_text(section_name, -1)).Str();
 
97
  
 
98
  std::string name = "<b>";
 
99
  name += std::string(section_name);
100
100
  name += "</b>";
101
101
 
102
 
  nux::StaticText* section_name_view = new nux::StaticText(name, NUX_TRACKER_LOCATION);
 
102
 
 
103
  nux::StaticText* section_name_view = new nux::StaticText(name.c_str(), NUX_TRACKER_LOCATION);
103
104
  section_name_view->SetTextPointSize(SECTION_NAME_FONT_SIZE);
104
105
  section_name_view->SetFontName("Ubuntu");
105
106
  layout->AddView(new nux::SpaceLayout(10, 10, 10, 10), 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_MATCHCONTENT);
116
117
  nux::HLayout* description_layout = new nux::HLayout(NUX_TRACKER_LOCATION);
117
118
 
118
119
  glib::String shortkey(g_markup_escape_text(hint->shortkey().c_str(), -1));
119
 
 
 
120
  
120
121
  std::string skey = "<b>";
121
122
  skey += shortkey.Str();
122
123
  skey += "</b>";
127
128
  shortkey_view->SetTextPointSize(SHORTKEY_ENTRY_FONT_SIZE);
128
129
  shortkey_view->SetMinimumWidth(SHORTKEY_COLUMN_WIDTH);
129
130
  shortkey_view->SetMaximumWidth(SHORTKEY_COLUMN_WIDTH);
130
 
 
 
131
  
131
132
  glib::String es_desc(g_markup_escape_text(hint->description().c_str(), -1));
132
133
 
133
134
  nux::StaticText* description_view = new nux::StaticText(es_desc.Value(), NUX_TRACKER_LOCATION);
151
152
  layout->AddLayout(description_layout, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
152
153
  layout->SetSpaceBetweenChildren(INTER_SPACE_SHORTKEY_DESCRIPTION);
153
154
  description_layout->SetContentDistribution(nux::MAJOR_POSITION_START);
154
 
 
 
155
  
155
156
   auto on_shortkey_changed = [](std::string const& new_shortkey, nux::StaticText* view) {
156
157
      std::string skey = "<b>";
157
158
      skey += new_shortkey;
158
159
      skey += "</b>";
159
 
 
 
160
      
160
161
      view->SetText(skey);
161
162
   };
162
 
 
 
163
  
163
164
  hint->shortkey.changed.connect(sigc::bind(sigc::slot<void, std::string const&, nux::StaticText*>(on_shortkey_changed), shortkey_view));
164
165
 
165
166
  return layout;
177
178
{
178
179
  nux::Geometry base = GetGeometry();
179
180
  nux::Geometry background_geo;
180
 
 
 
181
  
181
182
  background_geo.width = base.width;
182
183
  background_geo.height = base.height;
183
184
  background_geo.x = (base.width - background_geo.width)/2;
187
188
}
188
189
 
189
190
void View::DrawOverlay(nux::GraphicsEngine& GfxContext, bool force_draw, nux::Geometry clip)
190
 
{
 
191
{  
191
192
  layout_->ProcessDraw(GfxContext, force_draw);
192
193
}
193
194
 
195
196
{
196
197
  int i = 0;
197
198
  int column = 0;
198
 
 
 
199
  
199
200
  for (auto category : model_->categories())
200
201
  {
201
202
    // Three sections in the fist column...
202
203
    if (i > 2)
203
204
      column = 1;
204
 
 
 
205
      
205
206
    nux::LinearLayout* section_layout = CreateSectionLayout(category.c_str());
206
207
    nux::LinearLayout* intermediate_layout = CreateIntermediateLayout();
207
208
    intermediate_layout->SetContentDistribution(nux::MAJOR_POSITION_START);
208
 
 
 
209
    
209
210
    for (auto hint : model_->hints()[category])
210
211
    {
211
212
      //std::string str_value = hint->prefix() + hint->value() + hint->postfix();
212
213
      //boost::replace_all(str_value, "&", "&amp;");
213
214
      //boost::replace_all(str_value, "<", "&lt;");
214
215
      //boost::replace_all(str_value, ">", "&gt;");
215
 
 
 
216
      
216
217
      intermediate_layout->AddLayout(CreateShortKeyEntryLayout(hint), 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);
217
218
    }
218
 
 
 
219
    
219
220
    section_layout->AddLayout(intermediate_layout, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
220
221
 
221
222
    if (i == 0 or i==1 or i==3 or i==4)
228
229
    }
229
230
 
230
231
    columns_[column]->AddView(section_layout, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);
231
 
 
 
232
      
232
233
    i++;
233
234
  }
234
235
}
235
 
 
 
236
  
236
237
} // namespace shortcut
237
238
} // namespace unity