[Vala] [Vala/Clutter] ClutterText.set_single_line_mode() problem



Hi,

Vala 0.16-0.4.fc17
Clutter 1.10.6-1.fc17

Here I have a stripped down program to demonstrate a problem I am having
with setting a ClutterText to single_line_mode. If I do
mainMenuListItem7.set_single_line_mode(true), and
stage.set_key_focus(mainMenuItem7), then the text box works as I need it to
(single line mode), but for some reason, the ClutterText objects in the
listColumn actor don't have their background colors set properly when I
call the method to change the selected item.

The list items appear to be behaving as if I have set them to single line
mode even when I explicitly call xxx.set_single_line_mode(false) on them.

A text actor in single line mode will not wrap text and will clip the
visible area to the predefined size


using Clutter;

/*
Gui: class called from main to define the ui before the clutter.main loop
is called
*/
public class Gui : GLib.Object {

private Stage stage;
private BinLayout stageLayout;

public MainMenu mainMenuScreen;

public Gui() {

stageLayout = new BinLayout(Clutter.BinAlignment.FILL,
Clutter.BinAlignment.FILL);
 // All the worlds a stage
stage = new Stage();
//stage.set_fullscreen(true);
stage.color = Color () { alpha = 255 };
stage.set_reactive(true);
stage.set_size(1280, 800);
stage.hide.connect (Clutter.main_quit);
stage.set_layout_manager(stageLayout);

mainMenuScreen = new MainMenu(stage);


stage.add(mainMenuScreen);

stage.show();


}

}



public class MainMenu : Actor {

private Actor listColumn; // 2nd column -- lists the result set of foodie
items

private Text mainMenuItem2;
private Text mainMenuItem6;
private Text mainMenuItem9;
private Text play;
private Text play2;
 private BoxLayout mainMenuLayout;
private BoxLayout listColLayout;


private Actor listColumnCurrentItem;
private int listColumnCurrentItemIndex;

private Color rowSelectionColor;


public MainMenu(Stage stage) {

this.set_margin_left(10);
this.set_margin_right(20);
this.set_margin_top(20);
this.set_margin_bottom(20);


rowSelectionColor = Color();
rowSelectionColor.red = 255;
rowSelectionColor.green = 255;
rowSelectionColor.blue = 255;
rowSelectionColor.alpha = 60;


listColumn = new Actor();

mainMenuLayout = new BoxLayout();
this.set_layout_manager(mainMenuLayout);
 listColLayout = new BoxLayout();
listColumn.set_layout_manager(listColLayout);
listColLayout.set_vertical(true);
listColLayout.set_spacing(15);
listColumn.set_height(800);


play = new Text();
play.set_font_name("Helvetica 25");
play.set_text("Click to highlight next row");
play.set_color(Color.from_string("white"));
play.set_background_color(Color.from_string("blue"));
play.set_opacity(255);
play.set_reactive(true);
play.button_press_event.connect(onPlayPress);

play2 = new Text();
play2.set_font_name("Helvetica 25");
play2.set_text("Click to highlight previous row");
play2.set_color(Color.from_string("white"));
play2.set_background_color(Color.from_string("blue"));
play2.set_opacity(255);
play2.set_reactive(true);
play2.button_press_event.connect(onPlayPress2);

 mainMenuItem2 = new Text();
mainMenuItem2.set_width(800);
mainMenuItem2.set_font_name("Helvetica 25");
mainMenuItem2.set_text(" LIST ITMES");
mainMenuItem2.set_color(Color.from_string("white"));
mainMenuItem2.set_opacity(255);
mainMenuItem2.set_name("header");

mainMenuItem6 = new Text();
mainMenuItem6.set_width(800);
mainMenuItem6.set_markup("<span face='Helvetica' size='25000'> First LIST
Item</span>\n<span face='Helvetica' size='20000'> A lengthy description for
this</span> ");
mainMenuItem6.set_color(Color.from_string("white"));
mainMenuItem6.set_opacity(255);

 mainMenuItem9 = new Text();
mainMenuItem9.set_width(800);
//mainMenuItem9.set_font_name("Helvetica 25");
mainMenuItem9.set_markup("<span face='Helvetica' size='25000'> List Item
2</span>\n<span face='Helvetica' size='20000'> A lengthy description for
this</span> ");
mainMenuItem9.set_color(Color.from_string("white"));
mainMenuItem9.set_opacity(255);

listColLayout.pack(play, false, false, false, Clutter.BoxAlignment.START,
Clutter.BoxAlignment.START);
listColLayout.pack(play2, false, false, false, Clutter.BoxAlignment.START,
Clutter.BoxAlignment.START);
listColLayout.pack(mainMenuItem2, false, false, false,
Clutter.BoxAlignment.START, Clutter.BoxAlignment.START);
listColLayout.pack(mainMenuItem6, false, false, false,
Clutter.BoxAlignment.START, Clutter.BoxAlignment.START);
listColLayout.pack(mainMenuItem9, false, false, false,
Clutter.BoxAlignment.START, Clutter.BoxAlignment.START);

listColumnCurrentItemIndex = 2;
listColumnCurrentItem =
listColumn.get_child_at_index(listColumnCurrentItemIndex);
listColumnCurrentItem.set_background_color(rowSelectionColor);

mainMenuLayout.pack(listColumn, true, false, false,
Clutter.BoxAlignment.START, Clutter.BoxAlignment.START);
}

   private bool onPlayPress (ButtonEvent event) {

if (listColumnCurrentItemIndex == 4) {
stdout.printf("%s", "out of bounds down");

   return true;
}


listColumnCurrentItem.set_background_color(null);
listColumnCurrentItemIndex++;
listColumnCurrentItem =
listColumn.get_child_at_index(listColumnCurrentItemIndex);
listColumnCurrentItem.set_background_color(rowSelectionColor);
stdout.printf("%d", listColumnCurrentItemIndex);

return true;
   }

   private bool onPlayPress2 (ButtonEvent event) {


if (listColumnCurrentItemIndex == 2) {
stdout.printf("%s", "out of bounds up");
   return true;
}

listColumnCurrentItem.set_background_color(null);
listColumnCurrentItemIndex--;
listColumnCurrentItem =
listColumn.get_child_at_index(listColumnCurrentItemIndex);
listColumnCurrentItem.set_background_color(rowSelectionColor);
stdout.printf("%d", listColumnCurrentItemIndex);

return true;
   }


}

int main (string[] args) {

Clutter.init(ref args);

var gui = new Gui();

Clutter.main();

return 0;
}

/*
valac -X -O2 -g --pkg clutter-1.0 Test.vala
*/

// -X -O2 for optimizations
// -g for debug

-- 
Duff


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]