]> git.tdb.fi Git - libs/gltk.git/commitdiff
Style update: add spaces around assignments
authorMikko Rasa <tdb@tdb.fi>
Tue, 5 Oct 2010 10:26:03 +0000 (10:26 +0000)
committerMikko Rasa <tdb@tdb.fi>
Tue, 5 Oct 2010 10:26:03 +0000 (10:26 +0000)
27 files changed:
source/button.cpp
source/connector.cpp
source/container.cpp
source/dialog.cpp
source/dropdown.cpp
source/entry.cpp
source/geometry.cpp
source/graphic.cpp
source/hslider.cpp
source/indicator.cpp
source/label.cpp
source/list.cpp
source/logic.cpp
source/panel.cpp
source/part.cpp
source/resources.cpp
source/root.cpp
source/slider.cpp
source/state.cpp
source/state.h
source/style.cpp
source/table.cpp
source/text.cpp
source/toggle.cpp
source/userinterface.h
source/vslider.cpp
source/widget.cpp

index e7548386e0467cd6f8caec148973098b2fe7bffa..5871a5fabd0c7db23b2a0dfea1a5c6e6902f0368 100644 (file)
@@ -24,20 +24,20 @@ Button::Button(const Resources &r, const std::string &t):
 
 void Button::set_text(const std::string &t)
 {
-       text=t;
+       text = t;
 }
 
 void Button::set_icon(const GL::Texture2D *i)
 {
-       icon=i;
+       icon = i;
 }
 
 void Button::button_press(int, int, unsigned btn)
 {
        if(btn==1)
        {
-               pressed=true;
-               state|=ACTIVE;
+               pressed = true;
+               state |= ACTIVE;
        }
 }
 
@@ -45,8 +45,8 @@ void Button::button_release(int x, int y, unsigned btn)
 {
        if(pressed && btn==1)
        {
-               state&=~ACTIVE;
-               pressed=false;
+               state &= ~ACTIVE;
+               pressed = false;
 
                if(geom.is_inside_relative(x, y))
                        signal_clicked.emit();
@@ -58,9 +58,9 @@ void Button::pointer_motion(int x, int y)
        if(pressed)
        {
                if(!geom.is_inside_relative(x, y))
-                       state&=~ACTIVE;
+                       state &= ~ACTIVE;
                else
-                       state|=ACTIVE;
+                       state |= ACTIVE;
        }
 }
 
@@ -71,8 +71,8 @@ void Button::render_special(const Part &part) const
        if(part.get_name()=="icon" && icon)
        {
                Geometry rgeom;
-               rgeom.w=icon->get_width();
-               rgeom.h=icon->get_height();
+               rgeom.w = icon->get_width();
+               rgeom.h = icon->get_height();
                part.get_alignment().apply(rgeom, geom, part.get_margin());
 
                icon->bind();
@@ -106,7 +106,7 @@ Button::Loader::Loader(Button &btn):
 
 void Button::Loader::text(const std::string &t)
 {
-       static_cast<Button &>(wdg).text=t;
+       static_cast<Button &>(wdg).text = t;
 }
 
 } // namespace GLtk
index 2ee35c8ec8720decce212f6aef0c694f58e3fdc7..690a57bc21bb553e05b249905b4bf5b39ef20ae3 100644 (file)
@@ -21,11 +21,11 @@ Connector::~Connector()
 
 void Connector::connect(const Logic &logic)
 {
-       const list<Logic::WidgetBinding> &logic_binds=logic.get_bindings();
+       const list<Logic::WidgetBinding> &logic_binds = logic.get_bindings();
 
        for(list<Logic::WidgetBinding>::const_iterator i=logic_binds.begin(); i!=logic_binds.end(); ++i)
        {
-               map<string, ConnAction *>::const_iterator j=actions.find(i->type);
+               map<string, ConnAction *>::const_iterator j = actions.find(i->type);
                if(j!=actions.end())
                        j->second->connect(*this, *i->wdg, i->data);
                else
@@ -35,14 +35,14 @@ void Connector::connect(const Logic &logic)
 
 void Connector::add(const string &type, ConnAction *act)
 {
-       map<string, ConnAction *>::iterator i=actions.find(type);
+       map<string, ConnAction *>::iterator i = actions.find(type);
        if(i!=actions.end())
        {
                delete i->second;
-               i->second=act;
+               i->second = act;
        }
        else
-               actions[type]=act;
+               actions[type] = act;
 }
 
 } // namespace GLtk
index a46492d4ea3a1b7bb5e464952d7db846db4633c8..2ce2c5efc367213c584197d158c1327b6a2eda4b 100644 (file)
@@ -63,11 +63,11 @@ Widget *Container::get_child_at(int x, int y)
 
 Widget *Container::get_descendant_at(int x, int y)
 {
-       Widget *wdg=get_child_at(x, y);
-       if(Container *cont=dynamic_cast<Container *>(wdg))
+       Widget *wdg = get_child_at(x, y);
+       if(Container *cont = dynamic_cast<Container *>(wdg))
        {
-               const Geometry &cgeom=wdg->get_geometry();
-               Widget *wdg2=cont->get_descendant_at(x-cgeom.x, y-cgeom.y);
+               const Geometry &cgeom = wdg->get_geometry();
+               Widget *wdg2 = cont->get_descendant_at(x-cgeom.x, y-cgeom.y);
                if(wdg2)
                        return wdg2;
        }
@@ -78,17 +78,17 @@ void Container::button_press(int x, int y, unsigned btn)
 {
        if(click_focus)
        {
-               const Geometry &cgeom=click_focus->get_geometry();
+               const Geometry &cgeom = click_focus->get_geometry();
                click_focus->button_press(x-cgeom.x, y-cgeom.y, btn);
        }
        else
        {
-               if(Widget *wdg=get_child_at(x, y))
+               if(Widget *wdg = get_child_at(x, y))
                {
-                       click_focus=wdg;
-                       click_button=btn;
+                       click_focus = wdg;
+                       click_button = btn;
 
-                       const Geometry &cgeom=wdg->get_geometry();
+                       const Geometry &cgeom = wdg->get_geometry();
                        wdg->button_press(x-cgeom.x, y-cgeom.y, btn);
                }
        }
@@ -98,19 +98,19 @@ void Container::button_release(int x, int y, unsigned btn)
 {
        if(click_focus)
        {
-               Widget *wdg=click_focus;
+               Widget *wdg = click_focus;
 
                if(btn==click_button)
-                       click_focus=0;
+                       click_focus = 0;
 
-               const Geometry &cgeom=wdg->get_geometry();
+               const Geometry &cgeom = wdg->get_geometry();
                wdg->button_release(x-cgeom.x, y-cgeom.y, btn);
        }
        else
        {
-               if(Widget *wdg=get_child_at(x, y))
+               if(Widget *wdg = get_child_at(x, y))
                {
-                       const Geometry &cgeom=wdg->get_geometry();
+                       const Geometry &cgeom = wdg->get_geometry();
                        wdg->button_release(x-cgeom.x, y-cgeom.y, btn);
                }
        }
@@ -120,15 +120,15 @@ void Container::pointer_motion(int x, int y)
 {
        if(click_focus)
        {
-               const Geometry &cgeom=click_focus->get_geometry();
+               const Geometry &cgeom = click_focus->get_geometry();
                click_focus->pointer_motion(x-cgeom.x, y-cgeom.y);
        }
        else
        {
-               Widget *wdg=get_child_at(x, y);
+               Widget *wdg = get_child_at(x, y);
                if(wdg)
                {
-                       const Geometry &cgeom=wdg->get_geometry();
+                       const Geometry &cgeom = wdg->get_geometry();
                        wdg->pointer_motion(x-cgeom.x, y-cgeom.y);
                }
        }
@@ -137,7 +137,7 @@ void Container::pointer_motion(int x, int y)
 void Container::pointer_leave()
 {
        Widget::pointer_leave();
-       click_focus=0;
+       click_focus = 0;
 }
 
 Container::Child *Container::create_child(Widget *wdg)
@@ -156,13 +156,13 @@ Container::Child::Child(Container &c, Widget *w):
 Container::Child::~Child()
 {
        if(widget==container.click_focus)
-               container.click_focus=0;
+               container.click_focus = 0;
 }
 
 void Container::Child::visibility_changed(bool v)
 {
        if(!v && widget==container.click_focus)
-               container.click_focus=0;
+               container.click_focus = 0;
 }
 
 } // namespace GLtk
index 5eea60964ec3d694ff94b001cc8a7702473824d8..3e09783dcb5eb36350d4c4158b9139ae33ed7fd0 100644 (file)
@@ -41,7 +41,7 @@ void Dialog::response(int code)
 {
        on_response(code);
        signal_response.emit(code);
-       stale=true;
+       stale = true;
 }
 
 } // namespace GLtk
index d7119b7cfb72cec92d54bbf7ed2d1b02ff7b3c71..b911df370de3579e89d3430a8882362346071e14 100644 (file)
@@ -81,15 +81,15 @@ void Dropdown::button_press(int x, int y, unsigned btn)
                Container::button_press(x, y, btn);
                if(!click_focus)
                {
-                       dropped=false;
-                       state&=~ACTIVE;
+                       dropped = false;
+                       state &= ~ACTIVE;
                        signal_ungrab_pointer.emit();
                }
        }
        else if(btn==1)
        {
-               dropped=true;
-               state|=ACTIVE;
+               dropped = true;
+               state |= ACTIVE;
                signal_grab_pointer.emit();
        }
 }
@@ -113,15 +113,15 @@ void Dropdown::on_geometry_change()
 void Dropdown::resize_list()
 {
        // XXX This is a hack.
-       unsigned n_items=list.get_n_items();
-       const Style &stl=list.get_style();
-       const GL::Font &font=*stl.get_font();
-       unsigned h=min(max(n_items, 1U), 10U)*static_cast<unsigned>((font.get_ascent()-font.get_descent())*font.get_default_size());
+       unsigned n_items = list.get_n_items();
+       const Style &stl = list.get_style();
+       const GL::Font &font = *stl.get_font();
+       unsigned h = min(max(n_items, 1U), 10U)*static_cast<unsigned>((font.get_ascent()-font.get_descent())*font.get_default_size());
        for(std::list<Part>::const_iterator i=stl.get_parts().begin(); i!=stl.get_parts().end(); ++i)
                if(i->get_name()=="items")
                {
-                       const Sides &margin=i->get_margin();
-                       h+=margin.top+margin.bottom;
+                       const Sides &margin = i->get_margin();
+                       h += margin.top+margin.bottom;
                }
        list.set_geometry(Geometry(0, -h, geom.w, h));
 }
@@ -130,8 +130,8 @@ void Dropdown::list_item_selected(unsigned index, const std::string &item)
 {
        if(dropped)
        {
-               dropped=false;
-               state&=~ACTIVE;
+               dropped = false;
+               state &= ~ACTIVE;
                signal_ungrab_pointer.emit();
        }
 
index 7d5ecb66986d4ef9580745ca3c5594c942cd0182..91bd9c0ce82072219bdd46efa48e2d40e39392dc 100644 (file)
@@ -31,8 +31,8 @@ Entry::Entry(const Resources &r, const string &t):
 
 void Entry::set_text(const string &t)
 {
-       text=t;
-       edit_pos=text.size();
+       text = t;
+       edit_pos = text.size();
 }
 
 void Entry::set_multiline(bool m)
@@ -56,16 +56,16 @@ void Entry::key_press(unsigned key, unsigned, wchar_t ch)
        {
                unsigned row, col;
                text.offset_to_coords(edit_pos, row, col);
-               edit_pos=text.coords_to_offset(row+1, col);
+               edit_pos = text.coords_to_offset(row+1, col);
        }
        else if(key==Input::KEY_UP && multiline)
        {
                unsigned row, col;
                text.offset_to_coords(edit_pos, row, col);
                if(row>0)
-                       edit_pos=text.coords_to_offset(row-1, col);
+                       edit_pos = text.coords_to_offset(row-1, col);
                else
-                       edit_pos=0;
+                       edit_pos = 0;
        }
        else if(key==Input::KEY_BACKSPACE)
        {
@@ -98,7 +98,7 @@ void Entry::render_special(const Part &part) const
                unsigned row, col;
                text.offset_to_coords(edit_pos, row, col);
 
-               Geometry rgeom=text.coords_to_geometry(row, col);
+               Geometry rgeom = text.coords_to_geometry(row, col);
                part.get_alignment().apply(rgeom, geom, part.get_margin());
 
                GL::push_matrix();
index 0e46743b626ecf9edfffaa3b2b2de00bd0d2d25b..8163022ccdc981220280c938864427afb66c4630 100644 (file)
@@ -43,33 +43,33 @@ void Alignment::apply(Geometry &geom, const Geometry &parent) const
 {
        if(parent.w>geom.w)
        {
-               geom.w+=static_cast<unsigned>((parent.w-geom.w)*w);
-               geom.x+=static_cast<int>((parent.w-geom.w)*x);
+               geom.w += static_cast<unsigned>((parent.w-geom.w)*w);
+               geom.x += static_cast<int>((parent.w-geom.w)*x);
        }
        if(parent.h>geom.h)
        {
-               geom.h+=static_cast<unsigned>((parent.h-geom.h)*h);
-               geom.y+=static_cast<int>((parent.h-geom.h)*y);
+               geom.h += static_cast<unsigned>((parent.h-geom.h)*h);
+               geom.y += static_cast<int>((parent.h-geom.h)*y);
        }
 }
 
 void Alignment::apply(Geometry &geom, const Geometry &parent, const Sides &margin) const
 {
-       unsigned pw=parent.w-margin.left-margin.right;
-       unsigned ph=parent.h-margin.bottom-margin.top;
+       unsigned pw = parent.w-margin.left-margin.right;
+       unsigned ph = parent.h-margin.bottom-margin.top;
 
-       geom.x+=margin.left;
-       geom.y+=margin.bottom;
+       geom.x += margin.left;
+       geom.y += margin.bottom;
 
        if(pw>geom.w)
        {
-               geom.w+=static_cast<unsigned>((pw-geom.w)*w);
-               geom.x+=static_cast<int>((pw-geom.w)*x);
+               geom.w += static_cast<unsigned>((pw-geom.w)*w);
+               geom.x += static_cast<int>((pw-geom.w)*x);
        }
        if(ph>geom.h)
        {
-               geom.h+=static_cast<unsigned>((ph-geom.h)*h);
-               geom.y+=static_cast<int>((ph-geom.h)*y);
+               geom.h += static_cast<unsigned>((ph-geom.h)*h);
+               geom.y += static_cast<int>((ph-geom.h)*y);
        }
 }
 
index 9b613a74bf0a83381f2c7cf02aacf5326844a377..db2afa2cfa0340018b2424cc18865a2ae5a51b85 100644 (file)
@@ -29,10 +29,10 @@ void Graphic::render(unsigned wd, unsigned ht) const
        create_texcoords(slice.x, slice.x+slice.w, border.left, border.right, texture->get_width(), u);
        create_texcoords(slice.y, slice.y+slice.h, border.bottom, border.top, texture->get_height(), v);
 
-       unsigned xmin=border.left ? 0 : 1;
-       unsigned xmax=x.size()-(border.right ? 2 : 3);
-       unsigned ymin=border.bottom ? 0 : 1;
-       unsigned ymax=y.size()-(border.top ? 2 : 3);
+       unsigned xmin = border.left ? 0 : 1;
+       unsigned xmax = x.size()-(border.right ? 2 : 3);
+       unsigned ymin = border.bottom ? 0 : 1;
+       unsigned ymax = y.size()-(border.top ? 2 : 3);
 
        texture->bind();
        GL::Immediate imm((GL::COLOR4_UBYTE, GL::TEXCOORD2, GL::VERTEX2));
@@ -40,10 +40,10 @@ void Graphic::render(unsigned wd, unsigned ht) const
        imm.begin(GL::QUADS);
        for(unsigned i=ymin; i<=ymax; ++i)
        {
-               unsigned i2=(i==0 ? 0 : i==y.size()-2 ? 2 : 1);
+               unsigned i2 = (i==0 ? 0 : i==y.size()-2 ? 2 : 1);
                for(unsigned j=xmin; j<=xmax; ++j)
                {
-                       unsigned j2=(j==0 ? 0 : j==x.size()-2 ? 2 : 1);
+                       unsigned j2 = (j==0 ? 0 : j==x.size()-2 ? 2 : 1);
                        imm.texcoord(u[j2], v[i2]);
                        imm.vertex(x[j], y[i]);
                        imm.texcoord(u[j2+1], v[i2]);
@@ -63,9 +63,9 @@ void Graphic::create_coords(float low, float high, float brd1, float brd2, float
        coords.push_back(low+brd1);
        if(repeat)
        {
-               float space=high-low-brd1-brd2;
-               unsigned div=max(static_cast<unsigned>(space/block), 1U);
-               float delta=space/div;
+               float space = high-low-brd1-brd2;
+               unsigned div = max(static_cast<unsigned>(space/block), 1U);
+               float delta = space/div;
                for(unsigned i=1; i<div; ++i)
                        coords.push_back(low+brd1+delta*i);
        }
@@ -95,13 +95,13 @@ Graphic::Loader::Loader(Graphic &g, Resources &r):
 
 void Graphic::Loader::texture(const string &n)
 {
-       graph.texture=res.get<GL::Texture2D>(n);
-       graph.slice=Geometry(0, 0, graph.texture->get_width(), graph.texture->get_height());
+       graph.texture = res.get<GL::Texture2D>(n);
+       graph.slice = Geometry(0, 0, graph.texture->get_width(), graph.texture->get_height());
 }
 
 void Graphic::Loader::slice(unsigned x, unsigned y, unsigned w, unsigned h)
 {
-       graph.slice=Geometry(x, y, w, h);
+       graph.slice = Geometry(x, y, w, h);
 }
 
 void Graphic::Loader::border()
index 1575072fe782cc16689ac2009e33a94f86b4846c..ad447c7b017e627964b3f82e384f90442e16bbe0 100644 (file)
@@ -25,7 +25,7 @@ void HSlider::button_press(int x, int y, unsigned btn)
 {
        if(btn==1 && geom.is_inside_relative(x, y) && max>min)
        {
-               int sx=static_cast<int>((geom.w-slider_size)*(value-min)/(max-min));
+               int sx = static_cast<int>((geom.w-slider_size)*(value-min)/(max-min));
                if(x<sx)
                        set_value(value-step*10);
                else if(x>=static_cast<int>(sx+slider_size))
@@ -51,11 +51,11 @@ void HSlider::render_special(const Part &part) const
 {
        if(part.get_name()=="slider")
        {
-               Alignment align=part.get_alignment();
+               Alignment align = part.get_alignment();
                if(max>min)
-                       align.x=(value-min)/(max-min);
+                       align.x = (value-min)/(max-min);
 
-               Geometry pgeom=part.get_geometry();
+               Geometry pgeom = part.get_geometry();
                align.apply(pgeom, geom, part.get_margin());
 
                GL::push_matrix();
@@ -67,14 +67,14 @@ void HSlider::render_special(const Part &part) const
 
 void HSlider::on_geometry_change()
 {
-       drag_area_size=geom.w-slider_size;
+       drag_area_size = geom.w-slider_size;
 }
 
 void HSlider::on_style_change()
 {
        for(PartSeq::const_iterator i=style->get_parts().begin(); i!=style->get_parts().end(); ++i)
                if(i->get_name()=="slider")
-                       slider_size=i->get_geometry().w;
+                       slider_size = i->get_geometry().w;
 
        on_geometry_change();
 }
index 7f4ac4b87a88d807abada60336826c65dc58644f..d0e75586b288098e812432e75e3db8dbee9fa21c 100644 (file)
@@ -13,16 +13,16 @@ namespace GLtk {
 Indicator::Indicator(const Resources &r):
        Widget(r)
 {
-       focusable=false;
+       focusable = false;
        update_style();
 }
 
 void Indicator::set_active(bool a)
 {
        if(a)
-               state|=ACTIVE;
+               state |= ACTIVE;
        else
-               state&=~ACTIVE;
+               state &= ~ACTIVE;
 }
 
 } // namespace GLtk
index a91f821406292d4672053782b79ce1b3f9b70bae..60c3f431f9e35ca05016fc25366574d93a48474b 100644 (file)
@@ -18,32 +18,32 @@ Label::Label(const Resources &r, const string &t):
        Widget(r),
        text()
 {
-       focusable=false;
+       focusable = false;
        update_style();
        set_text(t);
 }
 
 void Label::autosize()
 {
-       const list<Part> &parts=style->get_parts();
-       const Part *text_part=0;
+       const list<Part> &parts = style->get_parts();
+       const Part *text_part = 0;
        for(list<Part>::const_iterator i=parts.begin(); (!text_part && i!=parts.end()); ++i)
                if(i->get_name()=="text")
-                       text_part=&*i;
+                       text_part = &*i;
 
-       geom.h=text.get_height();
-       geom.w=text.get_width();
+       geom.h = text.get_height();
+       geom.w = text.get_width();
        if(text_part)
        {
-               const Sides &margin=text_part->get_margin();
-               geom.w+=margin.left+margin.right;
-               geom.h+=margin.top+margin.bottom;
+               const Sides &margin = text_part->get_margin();
+               geom.w += margin.left+margin.right;
+               geom.h += margin.top+margin.bottom;
        }
 }
 
 void Label::set_text(const string &t)
 {
-       text=t;
+       text = t;
 }
 
 void Label::render_special(const Part &part) const
@@ -66,7 +66,7 @@ Label::Loader::Loader(Label &l):
 
 void Label::Loader::text(const string &t)
 {
-       static_cast<Label &>(wdg).text=t;
+       static_cast<Label &>(wdg).text = t;
 }
 
 } // namespace GLtk
index cc9f707efa1d9dadf008e585101f0a6365c15782..afa7573ecb837a6fd45d04810105e4b85e651bf5 100644 (file)
@@ -60,7 +60,7 @@ void List::remove(unsigned i)
        if(sel_index>static_cast<int>(i))
                --sel_index;
        else if(sel_index==static_cast<int>(i))
-               sel_index=-1;
+               sel_index = -1;
 
        recalculate_parameters();
 }
@@ -68,7 +68,7 @@ void List::remove(unsigned i)
 void List::clear()
 {
        items.clear();
-       sel_index=-1;
+       sel_index = -1;
 
        recalculate_parameters();
 }
@@ -76,10 +76,10 @@ void List::clear()
 void List::set_selected_index(int i)
 {
        if(i<0)
-               sel_index=-1;
+               sel_index = -1;
        else if(i<static_cast<int>(items.size()))
        {
-               sel_index=i;
+               sel_index = i;
                signal_item_selected.emit(sel_index, items[sel_index]);
        }
        else
@@ -100,12 +100,12 @@ void List::button_press(int x, int y, unsigned btn)
        if(!click_focus && btn==1)
        {
                if(items_part)
-                       y+=items_part->get_margin().top;
+                       y += items_part->get_margin().top;
 
-               unsigned i=(geom.h-1-y)/row_height;
+               unsigned i = (geom.h-1-y)/row_height;
                if(i<n_visible && first+i<items.size())
                {
-                       sel_index=first+i;
+                       sel_index = first+i;
 
                        signal_item_selected.emit(sel_index, items[sel_index]);
                }
@@ -116,22 +116,22 @@ void List::render_special(const Part &part) const
 {
        if(part.get_name()=="items")
        {
-               const GL::Font &font=*style->get_font();
-               const float font_size=font.get_default_size();
-               const GL::Color &color=style->get_font_color();
-               const Sides &margin=part.get_margin();
+               const GL::Font &font = *style->get_font();
+               const float font_size = font.get_default_size();
+               const GL::Color &color = style->get_font_color();
+               const Sides &margin = part.get_margin();
 
-               Geometry pgeom=geom;
-               pgeom.h=row_height;
-               pgeom.w-=margin.left+margin.right;
+               Geometry pgeom = geom;
+               pgeom.h = row_height;
+               pgeom.w -= margin.left+margin.right;
 
                for(unsigned i=0; (i<n_visible && first+i<items.size()); ++i)
                {
                        Geometry rgeom;
-                       rgeom.w=static_cast<unsigned>(font.get_string_width(items[first+i])*font_size);
-                       rgeom.h=row_height;
-                       rgeom.x=margin.left;
-                       rgeom.y=geom.h-margin.top-(i+1)*row_height-static_cast<int>(font.get_descent()*font_size);
+                       rgeom.w = static_cast<unsigned>(font.get_string_width(items[first+i])*font_size);
+                       rgeom.h = row_height;
+                       rgeom.x = margin.left;
+                       rgeom.y = geom.h-margin.top-(i+1)*row_height-static_cast<int>(font.get_descent()*font_size);
                        part.get_alignment().apply(rgeom, pgeom);
 
                        GL::push_matrix();
@@ -147,15 +147,15 @@ void List::render_special(const Part &part) const
        {
                if(sel_index>=static_cast<int>(first) && sel_index<static_cast<int>(first+n_visible))
                {
-                       const Sides &margin=part.get_margin();
+                       const Sides &margin = part.get_margin();
 
-                       Geometry pgeom=geom;
-                       pgeom.h=row_height;
-                       pgeom.w-=margin.left+margin.right;
+                       Geometry pgeom = geom;
+                       pgeom.h = row_height;
+                       pgeom.w -= margin.left+margin.right;
 
-                       Geometry rgeom=part.get_geometry();
-                       rgeom.y+=geom.h-margin.top-row_height*(sel_index-first+1);
-                       rgeom.x+=margin.left;
+                       Geometry rgeom = part.get_geometry();
+                       rgeom.y += geom.h-margin.top-row_height*(sel_index-first+1);
+                       rgeom.x += margin.left;
                        part.get_alignment().apply(rgeom, pgeom);
 
                        GL::push_matrix();
@@ -179,13 +179,13 @@ void List::on_style_change()
 {
        reposition_slider();
 
-       items_part=0;
+       items_part = 0;
        for(list<Part>::const_iterator i=style->get_parts().begin(); i!=style->get_parts().end(); ++i)
                if(i->get_name()=="items")
-                       items_part=&*i;
+                       items_part = &*i;
 
-       const GL::Font &font=*style->get_font();
-       row_height=static_cast<unsigned>((font.get_ascent()-font.get_descent())*font.get_default_size());
+       const GL::Font &font = *style->get_font();
+       row_height = static_cast<unsigned>((font.get_ascent()-font.get_descent())*font.get_default_size());
 
        recalculate_parameters();
 }
@@ -195,7 +195,7 @@ void List::reposition_slider()
        for(list<Part>::const_iterator i=style->get_parts().begin(); i!=style->get_parts().end(); ++i)
                if(i->get_name()=="slider")
                {
-                       Geometry sgeom=i->get_geometry();
+                       Geometry sgeom = i->get_geometry();
                        i->get_alignment().apply(sgeom, geom, i->get_margin());
                        slider.set_geometry(sgeom);
                }
@@ -203,21 +203,21 @@ void List::reposition_slider()
 
 void List::recalculate_parameters()
 {
-       unsigned h=geom.h;
+       unsigned h = geom.h;
        if(items_part)
        {
-               const Sides &margin=items_part->get_margin();
-               h-=margin.top+margin.bottom;
+               const Sides &margin = items_part->get_margin();
+               h -= margin.top+margin.bottom;
        }
 
-       n_visible=h/row_height;
+       n_visible = h/row_height;
 
        if(first+n_visible>items.size())
        {
                if(items.size()>n_visible)
-                       first=items.size()-n_visible;
+                       first = items.size()-n_visible;
                else
-                       first=0;
+                       first = 0;
        }
 
        if(items.size()>n_visible)
@@ -235,7 +235,7 @@ void List::recalculate_parameters()
 void List::slider_value_changed(double value)
 {
        if(items.size()>n_visible)
-               first=items.size()-n_visible-static_cast<unsigned>(value);
+               first = items.size()-n_visible-static_cast<unsigned>(value);
 }
 
 
index 16444892a591b752aa7eff5e95b0f1bf67bfc07e..85ec710def369c7b6764e0cb69f0e628f03e8af6 100644 (file)
@@ -21,16 +21,16 @@ Logic::Loader::Loader(Logic &l, const map<string, Widget *> &w):
 
 void Logic::Loader::bind(const string &wdg, const string &data)
 {
-       map<string, Widget *>::const_iterator i=widgets.find(wdg);
+       map<string, Widget *>::const_iterator i = widgets.find(wdg);
        if(i==widgets.end())
                throw KeyError("Unknown widget", wdg);
 
-       string::size_type colon=data.find(':');
+       string::size_type colon = data.find(':');
        WidgetBinding act;
-       act.wdg=i->second;
-       act.type=data.substr(0, colon);
+       act.wdg = i->second;
+       act.type = data.substr(0, colon);
        if(colon!=string::npos)
-               act.data=data.substr(colon+1);
+               act.data = data.substr(colon+1);
        logic.bindings.push_back(act);
 }
 
index 4d7e1a9df3d0aa814aa225c9dc47038d58fc3f68..59553b45de0122136a4c410ebf06a50ed378f6e4 100644 (file)
@@ -49,9 +49,9 @@ void Panel::raise(Widget &wdg)
 
 Widget *Panel::get_final_input_focus() const
 {
-       if(Panel *panel=dynamic_cast<Panel *>(input_focus))
+       if(Panel *panel = dynamic_cast<Panel *>(input_focus))
        {
-               Widget *focus=panel->get_final_input_focus();
+               Widget *focus = panel->get_final_input_focus();
                if(focus)
                        return focus;
        }
@@ -62,12 +62,12 @@ void Panel::button_press(int x, int y, unsigned btn)
 {
        if(pointer_grabbed)
        {
-               const Geometry &cgeom=pointer_focus->get_geometry();
+               const Geometry &cgeom = pointer_focus->get_geometry();
                pointer_focus->button_press(x-cgeom.x, y-cgeom.y, btn);
        }
        else
        {
-               if(Widget *wdg=get_child_at(x, y))
+               if(Widget *wdg = get_child_at(x, y))
                {
                        set_pointer_focus(wdg);
                        if(wdg->is_focusable())
@@ -81,7 +81,7 @@ void Panel::button_release(int x, int y, unsigned btn)
 {
        if(pointer_grabbed)
        {
-               const Geometry &cgeom=pointer_focus->get_geometry();
+               const Geometry &cgeom = pointer_focus->get_geometry();
                pointer_focus->button_release(x-cgeom.x, y-cgeom.y, btn);
        }
        else
@@ -92,7 +92,7 @@ void Panel::pointer_motion(int x, int y)
 {
        if(pointer_grabbed)
        {
-               const Geometry &cgeom=pointer_focus->get_geometry();
+               const Geometry &cgeom = pointer_focus->get_geometry();
                pointer_focus->pointer_motion(x-cgeom.x, y-cgeom.y);
        }
        else
@@ -147,7 +147,7 @@ void Panel::set_pointer_focus(Widget *wdg)
                if(pointer_focus)
                        pointer_focus->pointer_leave();
 
-               pointer_focus=wdg;
+               pointer_focus = wdg;
 
                if(pointer_focus)
                        pointer_focus->pointer_enter();
@@ -161,7 +161,7 @@ void Panel::set_input_focus(Widget *wdg)
                if(input_focus)
                        input_focus->focus_out();
 
-               input_focus=wdg;
+               input_focus = wdg;
 
                if(input_focus)
                {
@@ -193,18 +193,18 @@ Panel::Loader::Loader(Panel &p, map<string, Widget *> &m):
 template<typename T>
 void Panel::Loader::child(const string &n)
 {
-       RefPtr<T> chl=new T(pnl.res);
+       RefPtr<T> chl = new T(pnl.res);
        load_sub(*chl);
        pnl.add(*chl.get());
-       wdg_map[n]=chl.release();
+       wdg_map[n] = chl.release();
 }
 
 void Panel::Loader::panel(const string &n)
 {
-       RefPtr<Panel> p=new Panel(pnl.res);
+       RefPtr<Panel> p = new Panel(pnl.res);
        load_sub(*p, wdg_map);
        pnl.add(*p.get());
-       wdg_map[n]=p.release();
+       wdg_map[n] = p.release();
 }
 
 
@@ -226,7 +226,7 @@ void Panel::Child::visibility_changed(bool v)
 {
        if(!v)
        {
-               Panel &panel=static_cast<Panel &>(container);
+               Panel &panel = static_cast<Panel &>(container);
                if(widget==panel.pointer_focus)
                        panel.set_pointer_focus(0);
                if(widget==panel.input_focus)
@@ -236,7 +236,7 @@ void Panel::Child::visibility_changed(bool v)
 
 void Panel::Child::request_focus()
 {
-       Panel &panel=static_cast<Panel &>(container);
+       Panel &panel = static_cast<Panel &>(container);
        panel.set_input_focus(widget);
        if(panel.parent && panel.visible)
                panel.set_focus();
@@ -244,23 +244,23 @@ void Panel::Child::request_focus()
 
 void Panel::Child::grab_pointer()
 {
-       Panel &panel=static_cast<Panel &>(container);
+       Panel &panel = static_cast<Panel &>(container);
        if(!panel.pointer_grabbed)
        {
                panel.set_pointer_focus(widget);
-               panel.pointer_grabbed=true;
+               panel.pointer_grabbed = true;
                panel.signal_grab_pointer.emit();
        }
 }
 
 void Panel::Child::ungrab_pointer()
 {
-       Panel &panel=static_cast<Panel &>(container);
+       Panel &panel = static_cast<Panel &>(container);
        if(panel.pointer_grabbed && panel.pointer_focus==widget)
        {
                // XXX Should set to the widget under pointer
                panel.set_pointer_focus(0);
-               panel.pointer_grabbed=false;
+               panel.pointer_grabbed = false;
                panel.signal_ungrab_pointer.emit();
        }
 }
index 1f58b6187d679c983ad044310b20b5b739e1a6c5..b75e98ff7491cddca368cfc0061cf0ee8774fe2a 100644 (file)
@@ -19,7 +19,7 @@ Part::Part(const string &n):
        name(n)
 {
        for(unsigned i=0; i<N_STATES_; ++i)
-               graphic[i]=0;
+               graphic[i] = 0;
 }
 
 const Graphic *Part::get_graphic(State state) const
@@ -35,7 +35,7 @@ void Part::render(const Geometry &parent, State state) const
        if(!graphic[state])
                return;
 
-       Geometry rgeom=geom;
+       Geometry rgeom = geom;
        align.apply(rgeom, parent, margin);
        GL::translate(rgeom.x, rgeom.y, 0);
        graphic[state]->render(rgeom.w, rgeom.h);
@@ -58,30 +58,30 @@ Part::Loader::~Loader()
        for(unsigned i=0; i<N_STATES_; ++i)
                if(part.graphic[i])
                {
-                       const Sides &shadow=part.graphic[i]->get_shadow();
-                       part.geom.w=max(part.geom.w, part.graphic[i]->get_width()-shadow.left-shadow.right);
-                       part.geom.h=max(part.geom.h, part.graphic[i]->get_height()-shadow.bottom-shadow.top);
+                       const Sides &shadow = part.graphic[i]->get_shadow();
+                       part.geom.w = max(part.geom.w, part.graphic[i]->get_width()-shadow.left-shadow.right);
+                       part.geom.h = max(part.geom.h, part.graphic[i]->get_height()-shadow.bottom-shadow.top);
                }
 }
 
 void Part::Loader::graphic(State s, const string &n)
 {
-       Graphic *grph=res.get<Graphic>(n);
+       Graphic *grph = res.get<Graphic>(n);
        for(int i=0; i<N_STATES_; ++i)
                if((i&s)==s)
-                       part.graphic[i]=grph;
+                       part.graphic[i] = grph;
 }
 
 void Part::Loader::align(float x, float y)
 {
-       part.align.x=x;
-       part.align.y=y;
+       part.align.x = x;
+       part.align.y = y;
 }
 
 void Part::Loader::fill(float w, float h)
 {
-       part.align.w=w;
-       part.align.h=h;
+       part.align.w = w;
+       part.align.h = h;
 }
 
 void Part::Loader::margin()
@@ -91,8 +91,8 @@ void Part::Loader::margin()
 
 void Part::Loader::size(unsigned w, unsigned h)
 {
-       part.geom.w=w;
-       part.geom.h=h;
+       part.geom.w = w;
+       part.geom.h = h;
 }
 
 } // namespace GLtk
index b1b129b757fd6a65139a9cfb00c6a8663e75af17..7415beb5473312e57fcabb29d6691114aa733fc1 100644 (file)
@@ -26,7 +26,7 @@ Resources::Resources():
 
 void Resources::set_path(const FS::Path &p)
 {
-       path=p;
+       path = p;
 }
 
 const GL::Font &Resources::get_default_font() const
@@ -39,16 +39,16 @@ const GL::Font &Resources::get_default_font() const
 
 GL::Font *Resources::create_font(const string &name)
 {
-       RefPtr<GL::Font> fnt=new GL::Font;
+       RefPtr<GL::Font> fnt = new GL::Font;
        DataFile::load(*fnt, (path/name).str(), *this);
        if(!default_font)
-               default_font=fnt.get();
+               default_font = fnt.get();
        return fnt.release();
 }
 
 GL::Texture2D *Resources::create_texture(const string &name)
 {
-       RefPtr<GL::Texture2D> tex=new GL::Texture2D;
+       RefPtr<GL::Texture2D> tex = new GL::Texture2D;
        tex->load_image((path/name).str());
        tex->set_min_filter(GL::LINEAR);
        return tex.release();
@@ -66,22 +66,22 @@ Resources::Loader::Loader(Resources &r):
 
 void Resources::Loader::default_font(const string &name)
 {
-       res.default_font=res.get<GL::Font>(name);
+       res.default_font = res.get<GL::Font>(name);
 }
 
 void Resources::Loader::font(const string &name)
 {
-       RefPtr<GL::Font> fnt=new GL::Font;
+       RefPtr<GL::Font> fnt = new GL::Font;
        load_sub(*fnt, res);
        res.add(name, fnt.get());
        if(!res.default_font)
-               res.default_font=fnt.get();
+               res.default_font = fnt.get();
        fnt.release();
 }
 
 void Resources::Loader::style(const string &name)
 {
-       RefPtr<Style> stl=new Style(res);
+       RefPtr<Style> stl = new Style(res);
        load_sub(*stl, res);
        res.add(name, stl.get());
        stl.release();
index c7a2657005426ecc0f20eff1de7c9f8cb18a0e86..9023b7cb5c0f0f89578dbd864f12228dab9d5f88 100644 (file)
@@ -38,44 +38,44 @@ void Root::tick()
        if(tooltip_timeout && Time::now()>tooltip_timeout)
        {
                std::string tip;
-               if(Widget *wdg=get_descendant_at(pointer_x, pointer_y))
+               if(Widget *wdg = get_descendant_at(pointer_x, pointer_y))
                {
-                       tip=wdg->get_tooltip();
-                       tooltip_target=wdg;
+                       tip = wdg->get_tooltip();
+                       tooltip_target = wdg;
                }
                else
                {
-                       tip=signal_tooltip.emit(pointer_x, pointer_y);
-                       tooltip_target=this;
+                       tip = signal_tooltip.emit(pointer_x, pointer_y);
+                       tooltip_target = this;
                }
 
                if(!tip.empty())
                {
                        if(!lbl_tooltip)
                        {
-                               lbl_tooltip=new Label(res);
+                               lbl_tooltip = new Label(res);
                                add(*lbl_tooltip);
                                lbl_tooltip->set_style("tooltip");
                        }
 
                        lbl_tooltip->set_text(tip);
                        lbl_tooltip->autosize();
-                       const Geometry &tip_geom=lbl_tooltip->get_geometry();
-                       unsigned x=pointer_x+10;
-                       unsigned y=pointer_y-10-lbl_tooltip->get_geometry().h;
+                       const Geometry &tip_geom = lbl_tooltip->get_geometry();
+                       unsigned x = pointer_x+10;
+                       unsigned y = pointer_y-10-lbl_tooltip->get_geometry().h;
                        if(x+tip_geom.w>geom.w)
                        {
                                if(pointer_x>static_cast<int>(tip_geom.w+2))
-                                       x=pointer_x-2-tip_geom.w;
+                                       x = pointer_x-2-tip_geom.w;
                                else
-                                       x=geom.w-tip_geom.w;
+                                       x = geom.w-tip_geom.w;
                        }
                        lbl_tooltip->set_position(x, y);
                        raise(*lbl_tooltip);
                        lbl_tooltip->set_visible(true);
                }
 
-               tooltip_timeout=Time::TimeStamp();
+               tooltip_timeout = Time::TimeStamp();
        }
 }
 
@@ -83,7 +83,7 @@ void Root::button_press_event(int x, int y, unsigned btn, unsigned mod)
 {
        if(visible)
        {
-               Widget *old_focus=pointer_focus;
+               Widget *old_focus = pointer_focus;
 
                translate_coords(x, y);
                button_press(x, y, btn);
@@ -97,7 +97,7 @@ void Root::button_release_event(int x, int y, unsigned btn, unsigned mod)
 {
        if(visible)
        {
-               Widget *old_focus=pointer_focus;
+               Widget *old_focus = pointer_focus;
 
                translate_coords(x, y);
                button_release(x, y, btn);
@@ -116,15 +116,15 @@ void Root::pointer_motion_event(int x, int y)
 
                if(!tooltip_target)
                {
-                       pointer_x=x;
-                       pointer_y=y;
-                       tooltip_timeout=Time::now()+700*Time::msec;
+                       pointer_x = x;
+                       pointer_y = y;
+                       tooltip_timeout = Time::now()+700*Time::msec;
                }
                else if(get_descendant_at(x, y)!=tooltip_target)
                {
                        if(lbl_tooltip)
                                lbl_tooltip->set_visible(false);
-                       tooltip_target=0;
+                       tooltip_target = 0;
                }
 
                if(!pointer_focus)
@@ -136,7 +136,7 @@ void Root::key_press_event(unsigned key, unsigned mod, wchar_t ch)
 {
        if(visible)
        {
-               Widget *old_focus=input_focus;
+               Widget *old_focus = input_focus;
 
                key_press(Input::key_from_sys(key), mod, ch);
 
@@ -149,7 +149,7 @@ void Root::key_release_event(unsigned key, unsigned mod)
 {
        if(visible)
        {
-               Widget *old_focus=input_focus;
+               Widget *old_focus = input_focus;
 
                key_release(Input::key_from_sys(key), mod);
 
@@ -160,8 +160,8 @@ void Root::key_release_event(unsigned key, unsigned mod)
 
 void Root::translate_coords(int &x, int &y)
 {
-       x=x*geom.w/window.get_width();
-       y=geom.h-1-y*geom.h/window.get_height();
+       x = x*geom.w/window.get_width();
+       y = geom.h-1-y*geom.h/window.get_height();
 }
 
 } // namespace GLtk
index ead5664a303fae8e88ac26c9e0967629a5b02ceb..425f721f0ccf052bd0eb74a78b44eaca80570498 100644 (file)
@@ -22,16 +22,16 @@ Slider::Slider(const Resources &r):
 
 void Slider::set_value(double v)
 {
-       double old_value=value;
+       double old_value = value;
 
        if(v<min)
-               value=min;
+               value = min;
        else if(v>max)
-               value=max;
+               value = max;
        else
        {
-               unsigned steps=static_cast<unsigned>((v-min)/step+0.5);
-               value=min+steps*step;
+               unsigned steps = static_cast<unsigned>((v-min)/step+0.5);
+               value = min+steps*step;
        }
 
        if(value!=old_value)
@@ -40,23 +40,23 @@ void Slider::set_value(double v)
 
 void Slider::set_range(double a, double b)
 {
-       min=a;
-       max=b;
+       min = a;
+       max = b;
        set_value(value);
 }
 
 void Slider::set_step(double s)
 {
-       step=s;
+       step = s;
        set_value(value);
 }
 
 void Slider::start_drag(int p)
 {
-       dragging=true;
-       drag_start_pos=p;
-       drag_start_value=value;
-       state|=ACTIVE;
+       dragging = true;
+       drag_start_pos = p;
+       drag_start_value = value;
+       state |= ACTIVE;
 }
 
 void Slider::drag(int p)
@@ -67,8 +67,8 @@ void Slider::drag(int p)
 
 void Slider::end_drag()
 {
-       dragging=false;
-       state&=~ACTIVE;
+       dragging = false;
+       state &= ~ACTIVE;
 }
 
 
index 6eaf33613591fc5a0786e55fea9f16fdc0e6367c..80c4292efdef93f77d039b90224082f2fc687415 100644 (file)
@@ -17,22 +17,22 @@ istream &operator>>(istream &is, State &state)
        string str;
        is>>str;
 
-       unsigned start=0;
-       state=NORMAL;
+       unsigned start = 0;
+       state = NORMAL;
 
        while(1)
        {
-               string::size_type underscore=str.find('_', start);
+               string::size_type underscore = str.find('_', start);
                if(!str.compare(start, underscore-start, "NORMAL"))
-                       state|=NORMAL;
+                       state |= NORMAL;
                else if(!str.compare(start, underscore-start, "HOVER"))
-                       state|=HOVER;
+                       state |= HOVER;
                else if(!str.compare(start, underscore-start, "ACTIVE"))
-                       state|=ACTIVE;
+                       state |= ACTIVE;
                else if(!str.compare(start, underscore-start, "FOCUS"))
-                       state|=FOCUS;
+                       state |= FOCUS;
                else if(!str.compare(start, underscore-start, "DISABLED"))
-                       state|=DISABLED;
+                       state |= DISABLED;
                else
                {
                        is.setstate(ios_base::failbit);
@@ -41,7 +41,7 @@ istream &operator>>(istream &is, State &state)
 
                if(underscore==std::string::npos)
                        break;
-               start=underscore+1;
+               start = underscore+1;
        }
 
        return is;
index 688d8dcb3baa60cbf7afb0f97302f0275545026f..7c2828aae0ab47f24b672fc368ef0dd8ceeedbd4 100644 (file)
@@ -16,25 +16,25 @@ namespace GLtk {
 
 enum State
 {
-       NORMAL=0,   //< Default state
-       HOVER=1,    //< Pointer over the widget
-       ACTIVE=2,   //< Widget is active (e.g. pressed button)
-       FOCUS=4,    //< Widget has input focus
-       DISABLED=8, //< Widget is unresponsive
-       N_STATES_=16 //< Sentry value
+       NORMAL = 0,   //< Default state
+       HOVER = 1,    //< Pointer over the widget
+       ACTIVE = 2,   //< Widget is active (e.g. pressed button)
+       FOCUS = 4,    //< Widget has input focus
+       DISABLED = 8, //< Widget is unresponsive
+       N_STATES_ = 16 //< Sentry value
 };
 
 inline State operator|(State a, State b)
 { return static_cast<State>(static_cast<int>(a)|static_cast<int>(b)); }
 
 inline State operator|=(State &a, State b)
-{ a=a|b; return a; }
+{ a = a|b; return a; }
 
 inline State operator&(State a, State b)
 { return static_cast<State>(static_cast<int>(a)&static_cast<int>(b)); }
 
 inline State operator&=(State &a, State b)
-{ a=a&b; return a; }
+{ a = a&b; return a; }
 
 inline State operator~(State a)
 { return static_cast<State>(~static_cast<int>(a)); }
index 0d6e424e2163b048d65c3c76af46b7792cb87acc..0bc931188e7e93ee9356cae9e90bf79112d27ecd 100644 (file)
@@ -30,7 +30,7 @@ Style::Loader::Loader(Style &s, Resources &r):
 
 void Style::Loader::font_color(float r, float g, float b)
 {
-       style.font_color=GL::Color(r, g, b);
+       style.font_color = GL::Color(r, g, b);
 }
 
 void Style::Loader::part()
index 7f0ae796f9c7077599990ee1fd563fe64bec0b29..085a44237f979bbe9013534c9c160881d75b14eb 100644 (file)
@@ -23,13 +23,13 @@ Table::Table(const Resources &r):
        data(1),
        col_w(1)
 {
-       focusable=false;
+       focusable = false;
        update_style();
 }
 
 void Table::set_rows(unsigned r)
 {
-       rows=r;
+       rows = r;
        data.resize(rows*columns);
 }
 
@@ -40,7 +40,7 @@ void Table::set_columns(unsigned c)
                for(unsigned j=0; j<min(c, columns); ++j)
                        new_data[i*c+j].swap(data[i*columns+j]);
        data.swap(new_data);
-       columns=c;
+       columns = c;
 
        col_w.resize(columns);
 }
@@ -49,7 +49,7 @@ void Table::set_column_width(unsigned c, unsigned w)
 {
        if(c>=columns)
                throw InvalidParameterValue("Column index out of bounds");
-       col_w[c]=w;
+       col_w[c] = w;
 }
 
 void Table::set_cell_text(unsigned r, unsigned c, const string &t)
@@ -57,40 +57,40 @@ void Table::set_cell_text(unsigned r, unsigned c, const string &t)
        if(r>=rows || c>=columns)
                throw InvalidParameterValue("Cell coordinates out of bounds");
 
-       data[r*columns+c]=t;
+       data[r*columns+c] = t;
 }
 
 void Table::render_special(const Part &part) const
 {
        if(part.get_name()=="cells")
        {
-               const GL::Font *const font=style->get_font();
-               const float font_size=font->get_default_size();
+               const GL::Font *const font = style->get_font();
+               const float font_size = font->get_default_size();
 
-               unsigned free_width=geom.w;
+               unsigned free_width = geom.w;
                for(unsigned i=0; i<columns; ++i)
-                       free_width-=col_w[i];
+                       free_width -= col_w[i];
 
                Geometry cgeom;
-               cgeom.h=geom.h/rows;
-               cgeom.y=geom.h-cgeom.h;
+               cgeom.h = geom.h/rows;
+               cgeom.y = geom.h-cgeom.h;
 
                for(unsigned i=0; i<rows; ++i)
                {
-                       cgeom.x=0;
+                       cgeom.x = 0;
                        for(unsigned j=0; j<columns; ++j)
                        {
                                if(col_w[j])
-                                       cgeom.w=col_w[j];
+                                       cgeom.w = col_w[j];
                                else
-                                       cgeom.w=free_width/columns;
+                                       cgeom.w = free_width/columns;
 
-                               const string &text=data[i*columns+j];
+                               const string &text = data[i*columns+j];
                                Geometry rgeom;
-                               rgeom.x=cgeom.x;
-                               rgeom.y=cgeom.y;
-                               rgeom.w=static_cast<unsigned>(font->get_string_width(text)*font_size);
-                               rgeom.h=static_cast<unsigned>((font->get_ascent()-font->get_descent())*font_size);
+                               rgeom.x = cgeom.x;
+                               rgeom.y = cgeom.y;
+                               rgeom.w = static_cast<unsigned>(font->get_string_width(text)*font_size);
+                               rgeom.h = static_cast<unsigned>((font->get_ascent()-font->get_descent())*font_size);
 
                                part.get_alignment().apply(rgeom, cgeom, part.get_margin());
 
@@ -100,10 +100,10 @@ void Table::render_special(const Part &part) const
                                font->draw_string(text);
                                GL::pop_matrix();
 
-                               cgeom.x+=cgeom.w;
+                               cgeom.x += cgeom.w;
                        }
 
-                       cgeom.y-=cgeom.h;
+                       cgeom.y -= cgeom.h;
                }
        }
 }
index d18d7b5ba6c03fc233026afd178220d30b2babe0..5fc546c21dfe30a0c2eb9eb30662703490bf0c7e 100644 (file)
@@ -29,31 +29,31 @@ void Text::set_style(const Style *s)
 {
        style = s;
 
-       float font_size=style->get_font()->get_default_size();
+       float font_size = style->get_font()->get_default_size();
        for(vector<Line>::iterator i=lines.begin(); i!=lines.end(); ++i)
-               i->width=static_cast<unsigned>(style->get_font()->get_string_width(text.substr(i->start, i->length))*font_size);
+               i->width = static_cast<unsigned>(style->get_font()->get_string_width(text.substr(i->start, i->length))*font_size);
 }
 
 unsigned Text::get_width() const
 {
-       unsigned width=0;
+       unsigned width = 0;
        for(vector<Line>::const_iterator i=lines.begin(); i!=lines.end(); ++i)
-               width=max(width, i->width);
+               width = max(width, i->width);
        return width;
 }
 
 unsigned Text::get_height() const
 {
-       const GL::Font *font=style->get_font();
-       float font_size=font->get_default_size();
-       unsigned line_height=static_cast<unsigned>((font->get_ascent()-font->get_descent())*font_size);
-       unsigned line_spacing=line_height*6/5;
+       const GL::Font *font = style->get_font();
+       float font_size = font->get_default_size();
+       unsigned line_height = static_cast<unsigned>((font->get_ascent()-font->get_descent())*font_size);
+       unsigned line_spacing = line_height*6/5;
        return line_height+(lines.size()-1)*line_spacing;
 }
 
 void Text::set(const string &t)
 {
-       text=t;
+       text = t;
        find_lines();
 }
 
@@ -68,10 +68,10 @@ void Text::erase(unsigned pos, unsigned len)
                find_lines();
        else
        {
-               i->length-=len;
+               i->length -= len;
 
                for(++i; i!=lines.end(); ++i)
-                       i->start-=len;
+                       i->start -= len;
        }
 }
 
@@ -86,10 +86,10 @@ void Text::insert(unsigned pos, const string &s)
                vector<Line>::iterator i;
                for(i=lines.begin(); (i!=lines.end() && i->start+i->length<pos); ++i) ;
 
-               i->length+=s.size();
+               i->length += s.size();
 
                for(++i; i!=lines.end(); ++i)
-                       i->start+=s.size();
+                       i->start += s.size();
        }
 }
 
@@ -104,16 +104,16 @@ void Text::offset_to_coords(unsigned offs, unsigned &row, unsigned &col) const
 {
        if(lines.empty())
        {
-               row=0;
-               col=0;
+               row = 0;
+               col = 0;
                return;
        }
 
        for(unsigned i=0; i<lines.size(); ++i)
                if(offs>=lines[i].start && offs<=lines[i].start+lines[i].length)
                {
-                       row=i;
-                       col=offs-lines[i].start;
+                       row = i;
+                       col = offs-lines[i].start;
                        return;
                }
 }
@@ -129,23 +129,23 @@ unsigned Text::coords_to_offset(unsigned row, unsigned col) const
 Geometry Text::coords_to_geometry(unsigned row, unsigned col) const
 {
        if(row>=lines.size())
-               row=lines.size()-1;
-       const Line &line=lines[row];
+               row = lines.size()-1;
+       const Line &line = lines[row];
        if(col>line.length)
-               col=line.length;
+               col = line.length;
 
-       const GL::Font *font=style->get_font();
-       float font_size=font->get_default_size();
-       unsigned line_height=static_cast<unsigned>((font->get_ascent()-font->get_descent())*font_size);
-       unsigned line_spacing=static_cast<unsigned>(font_size*6/5);
-       unsigned height=line_height+(lines.size()-1)*line_spacing;
-       int y_offset=static_cast<int>(-font->get_descent()*font_size);
+       const GL::Font *font = style->get_font();
+       float font_size = font->get_default_size();
+       unsigned line_height = static_cast<unsigned>((font->get_ascent()-font->get_descent())*font_size);
+       unsigned line_spacing = static_cast<unsigned>(font_size*6/5);
+       unsigned height = line_height+(lines.size()-1)*line_spacing;
+       int y_offset = static_cast<int>(-font->get_descent()*font_size);
 
        Geometry geom;
-       geom.w=line.width;
-       geom.h=height;
-       geom.x=static_cast<unsigned>(font->get_string_width(text.substr(line.start, col))*font_size);
-       geom.y=(lines.size()-1-row)*line_spacing+y_offset;
+       geom.w = line.width;
+       geom.h = height;
+       geom.x = static_cast<unsigned>(font->get_string_width(text.substr(line.start, col))*font_size);
+       geom.y = (lines.size()-1-row)*line_spacing+y_offset;
 
        return geom;
 }
@@ -155,24 +155,24 @@ void Text::render(const Part &part, const Geometry &geom) const
        if(lines.empty())
                return;
 
-       const GL::Font *font=style->get_font();
-       float font_size=font->get_default_size();
-       unsigned line_height=static_cast<unsigned>((font->get_ascent()-font->get_descent())*font_size);
-       unsigned line_spacing=static_cast<unsigned>(font_size*6/5);
-       unsigned height=line_height+(lines.size()-1)*line_spacing;
-       int y_offset=static_cast<int>(-font->get_descent()*font_size);
+       const GL::Font *font = style->get_font();
+       float font_size = font->get_default_size();
+       unsigned line_height = static_cast<unsigned>((font->get_ascent()-font->get_descent())*font_size);
+       unsigned line_spacing = static_cast<unsigned>(font_size*6/5);
+       unsigned height = line_height+(lines.size()-1)*line_spacing;
+       int y_offset = static_cast<int>(-font->get_descent()*font_size);
 
-       const GL::Color &color=style->get_font_color();
+       const GL::Color &color = style->get_font_color();
        GL::Immediate imm((GL::COLOR4_UBYTE, GL::TEXCOORD2, GL::VERTEX2));
        imm.color(color.r, color.g, color.b);
        for(unsigned i=0; i<lines.size(); ++i)
        {
-               const Line &line=lines[i];
+               const Line &line = lines[i];
 
                Geometry rgeom;
-               rgeom.w=line.width;
-               rgeom.h=height;
-               rgeom.y=(lines.size()-1-i)*line_spacing+y_offset;
+               rgeom.w = line.width;
+               rgeom.h = height;
+               rgeom.y = (lines.size()-1-i)*line_spacing+y_offset;
                part.get_alignment().apply(rgeom, geom, part.get_margin());
 
                GL::push_matrix();
@@ -194,21 +194,21 @@ Text &Text::operator=(const string &t)
 void Text::find_lines()
 {
        lines.clear();
-       float font_size=style->get_font()->get_default_size();
-       string::size_type start=0;
+       float font_size = style->get_font()->get_default_size();
+       string::size_type start = 0;
        while(1)
        {
-               string::size_type newline=text.find('\n', start);
+               string::size_type newline = text.find('\n', start);
 
                Line line;
-               line.start=start;
-               line.length=(newline==string::npos ? text.size() : newline)-start;
-               line.width=static_cast<unsigned>(style->get_font()->get_string_width(text.substr(line.start, line.length))*font_size);
+               line.start = start;
+               line.length = (newline==string::npos ? text.size() : newline)-start;
+               line.width = static_cast<unsigned>(style->get_font()->get_string_width(text.substr(line.start, line.length))*font_size);
                lines.push_back(line);
 
                if(newline==string::npos)
                        break;
-               start=newline+1;
+               start = newline+1;
        }
 }
 
index d31ff9f320faac8b4f081c369366003684c64c25..3b896bedb7290451a202f3dcab2efbe2f40cb965 100644 (file)
@@ -27,33 +27,33 @@ Toggle::Toggle(const Resources &r, const string &t):
 
 void Toggle::set_text(const string &t)
 {
-       text=t;
+       text = t;
 }
 
 void Toggle::set_exclusive(bool e)
 {
-       exclusive=e;
+       exclusive = e;
        if(exclusive && value)
                exclude_siblings();
 }
 
 void Toggle::set_value(bool v)
 {
-       value=v;
+       value = v;
        if(value)
        {
-               state|=ACTIVE;
+               state |= ACTIVE;
                if(exclusive && parent)
                        exclude_siblings();
        }
        else
-               state&=~ACTIVE;
+               state &= ~ACTIVE;
 }
 
 void Toggle::button_press(int, int, unsigned btn)
 {
        if(btn==1)
-               pressed=true;
+               pressed = true;
 }
 
 void Toggle::button_release(int x, int y, unsigned btn)
@@ -66,7 +66,7 @@ void Toggle::button_release(int x, int y, unsigned btn)
                        signal_toggled.emit(value);
                }
 
-               pressed=false;
+               pressed = false;
        }
 }
 
@@ -78,9 +78,9 @@ void Toggle::render_special(const Part &part) const
 
 void Toggle::exclude_siblings()
 {
-       const list<Widget *> &siblings=parent->get_children();
+       const list<Widget *> &siblings = parent->get_children();
        for(list<Widget *>::const_iterator i=siblings.begin(); i!=siblings.end(); ++i)
-               if(Toggle *tgl=dynamic_cast<Toggle *>(*i))
+               if(Toggle *tgl = dynamic_cast<Toggle *>(*i))
                        if(tgl!=this && tgl->get_exclusive() && tgl->get_value())
                                tgl->set_value(false);
 }
@@ -106,16 +106,16 @@ Toggle &Toggle::Loader::get_object() const
 
 void Toggle::Loader::finish()
 {
-       Toggle &tgl=static_cast<Toggle &>(wdg);
+       Toggle &tgl = static_cast<Toggle &>(wdg);
        if(tgl.value)
-               tgl.state|=ACTIVE;
+               tgl.state |= ACTIVE;
        else
-               tgl.state&=~ACTIVE;
+               tgl.state &= ~ACTIVE;
 }
 
 void Toggle::Loader::text(const string &t)
 {
-       static_cast<Toggle &>(wdg).text=t;
+       static_cast<Toggle &>(wdg).text = t;
 }
 
 } // namespace GLtk
index c821320b672e3a5445e935522eec1453faa460f1..c0750c003b5a15cc4e4bda9bf42d5f46ab91c329 100644 (file)
@@ -46,11 +46,11 @@ public:
        template<typename W>
        W &get_widget(const std::string &n) const
        {
-               std::map<std::string, Widget *>::const_iterator i=widgets.find(n);
+               std::map<std::string, Widget *>::const_iterator i = widgets.find(n);
                if(i==widgets.end())
                        throw KeyError("Unknown widget", n);
 
-               W *w=dynamic_cast<W *>(i->second);
+               W *w = dynamic_cast<W *>(i->second);
                if(!w)
                        throw Exception("Widget type mismatch");
 
@@ -60,7 +60,7 @@ public:
        template<typename W>
        void get_widget(const std::string &n, W *&w) const
        {
-               w=&get_widget<W>(n);
+               w = &get_widget<W>(n);
        }
 };
 
index 954bb19520702a24033468cecfbf8089bbf3e168..ed2e0bc5123d0a6cfad0b43cdf73f6faf15bc13c 100644 (file)
@@ -25,7 +25,7 @@ void VSlider::button_press(int x, int y, unsigned btn)
 {
        if(btn==1 && geom.is_inside_relative(x, y) && max>min)
        {
-               int sy=static_cast<int>((geom.h-slider_size)*(value-min)/(max-min));
+               int sy = static_cast<int>((geom.h-slider_size)*(value-min)/(max-min));
                if(y<sy)
                        set_value(value-step*10);
                else if(y>=static_cast<int>(sy+slider_size))
@@ -51,11 +51,11 @@ void VSlider::render_special(const Part &part) const
 {
        if(part.get_name()=="slider")
        {
-               Alignment align=part.get_alignment();
+               Alignment align = part.get_alignment();
                if(max>min)
-                       align.y=(value-min)/(max-min);
+                       align.y = (value-min)/(max-min);
 
-               Geometry pgeom=part.get_geometry();
+               Geometry pgeom = part.get_geometry();
                align.apply(pgeom, geom, part.get_margin());
 
                GL::push_matrix();
@@ -67,14 +67,14 @@ void VSlider::render_special(const Part &part) const
 
 void VSlider::on_geometry_change()
 {
-       drag_area_size=geom.h-slider_size;
+       drag_area_size = geom.h-slider_size;
 }
 
 void VSlider::on_style_change()
 {
        for(PartSeq::const_iterator i=style->get_parts().begin(); i!=style->get_parts().end(); ++i)
                if(i->get_name()=="slider")
-                       slider_size=i->get_geometry().h;
+                       slider_size = i->get_geometry().h;
 
        on_geometry_change();
 }
index 04c272a136242cea7b14e9adf1988da22fc9cf09..2af3b60b3024a96e5689637ed152e152b2eec275 100644 (file)
@@ -35,27 +35,27 @@ Widget::~Widget()
 
 void Widget::set_position(int x, int y)
 {
-       geom.x=x;
-       geom.y=y;
+       geom.x = x;
+       geom.y = y;
        on_geometry_change();
 }
 
 void Widget::set_size(unsigned w, unsigned h)
 {
-       geom.w=w;
-       geom.h=h;
+       geom.w = w;
+       geom.h = h;
        on_geometry_change();
 }
 
 void Widget::set_geometry(const Geometry &g)
 {
-       geom=g;
+       geom = g;
        on_geometry_change();
 }
 
 void Widget::set_style(const string &s)
 {
-       style_name=s;
+       style_name = s;
        update_style();
 }
 
@@ -69,14 +69,14 @@ void Widget::set_visible(bool v)
        if(v==visible)
                return;
 
-       visible=v;
+       visible = v;
 
        signal_visibility_changed.emit(visible);
 }
 
 void Widget::set_focusable(bool f)
 {
-       focusable=f;
+       focusable = f;
 }
 
 void Widget::set_focus()
@@ -111,33 +111,33 @@ void Widget::render() const
 
 void Widget::pointer_enter()
 {
-       state|=HOVER;
+       state |= HOVER;
 }
 
 void Widget::pointer_leave()
 {
-       state&=~HOVER;
+       state &= ~HOVER;
 }
 
 void Widget::focus_in()
 {
-       state|=FOCUS;
+       state |= FOCUS;
 }
 
 void Widget::focus_out()
 {
-       state&=~FOCUS;
+       state &= ~FOCUS;
 }
 
 void Widget::update_style()
 {
-       string sname=get_class();
+       string sname = get_class();
        if(!style_name.empty())
        {
-               sname+='-';
-               sname+=style_name;
+               sname += '-';
+               sname += style_name;
        }
-       style=res.get<Style>(sname);
+       style = res.get<Style>(sname);
        on_style_change();
 }
 
@@ -145,7 +145,7 @@ void Widget::set_parent(Container *p)
 {
        if(parent && p)
                throw InvalidState("Widget is already in a Container");
-       parent=p;
+       parent = p;
 
        on_reparent();
 }