Skip to content

Commit

Permalink
Solved layout issues (all, I hope)
Browse files Browse the repository at this point in the history
- The overview is now centered externally
- In the overview the scrollbar is activated automatically
- The slides are now centered
- The scrollbar for the notes is now also black&white
  • Loading branch information
David Vilar committed May 24, 2012
1 parent 7649661 commit cdb136e
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/classes/view/default.vala
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace org.westhoffswelt.pdfpresenter {

// As we are using our own kind of double buffer and blit in a one
// time action, we do not need gtk to double buffer as well.
this.set_double_buffered( true );
this.set_double_buffered( false );

this.current_slide_number = 0;

Expand Down
23 changes: 5 additions & 18 deletions src/classes/window/overview.vala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace org.westhoffswelt.pdfpresenter.Window {
/**
* An overview of all the slides in the form of a table
*/
public class Overview: Gtk.Alignment {
public class Overview: Gtk.ScrolledWindow {

/*
* The store of all the slides.
Expand All @@ -40,11 +40,6 @@ namespace org.westhoffswelt.pdfpresenter.Window {
*/
protected IconView slides_view;

/*
* The ScrolledWindow containing slides_view.
*/
protected ScrolledWindow sw;

/**
* We will need the metadata mainly for converting from user slides to
* real slides.
Expand Down Expand Up @@ -136,25 +131,22 @@ namespace org.westhoffswelt.pdfpresenter.Window {
* Constructor
*/
public Overview( Metadata.Pdf metadata, PresentationController presentation_controller, Presenter presenter ) {

this.sw = new ScrolledWindow(null, null);
this.slides = new ListStore(1, typeof(Pixbuf));
this.slides_view = new IconView.with_model(this.slides);
this.slides_view.selection_mode = SelectionMode.SINGLE;
var renderer = new CellRendererHighlight();
this.slides_view.pack_start(renderer, true);
this.slides_view.add_attribute(renderer, "pixbuf", 0);
this.slides_view.set_item_padding(0);
this.sw.add(this.slides_view);
this.add(this.sw);
this.sw.show_all();
this.add(this.slides_view);
this.show_all();

Color black;
Color white;
Color.parse("black", out black);
Color.parse("white", out white);
this.slides_view.modify_base(StateType.NORMAL, black);
Gtk.Scrollbar vscrollbar = (Gtk.Scrollbar) this.sw.get_vscrollbar();
Gtk.Scrollbar vscrollbar = (Gtk.Scrollbar) this.get_vscrollbar();
vscrollbar.modify_bg(StateType.NORMAL, white);
vscrollbar.modify_bg(StateType.ACTIVE, black);
vscrollbar.modify_bg(StateType.PRELIGHT, white);
Expand Down Expand Up @@ -242,15 +234,10 @@ namespace org.westhoffswelt.pdfpresenter.Window {
this.target_width = Options.min_overview_width;
this.slides_view.columns = (eff_max_width - 20) // Guess for scrollbar width
/ (Options.min_overview_width + 2 * padding + col_spacing);
this.set(0.5f,0.5f,0,1); // Expand the ScrolledWindow to full height
this.sw.set_policy(PolicyType.NEVER, PolicyType.ALWAYS);
} else {
this.slides_view.columns = tc;
this.set(0.5f,0.5f,0,0); // Don't expand the ScrolledWindow
// Never show vertical scrollbar, or else ScrolledWindow will be as short
// as possible.
this.sw.set_policy(PolicyType.NEVER, PolicyType.NEVER);
}
this.set_policy(PolicyType.NEVER, PolicyType.AUTOMATIC);
this.target_height = (int)Math.round(this.target_width / this.aspect_ratio);
this.last_structure_n_slides = this.n_slides;

Expand Down
2 changes: 0 additions & 2 deletions src/classes/window/presentation.vala
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ namespace org.westhoffswelt.pdfpresenter.Window {
this.key_press_event.connect( this.on_key_pressed );
this.button_press_event.connect( this.on_button_press );
this.scroll_event.connect( this.on_scroll );

this.update();
}

/**
Expand Down
42 changes: 28 additions & 14 deletions src/classes/window/presenter.vala
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ namespace org.westhoffswelt.pdfpresenter.Window {
protected HBox slideViews = null;

protected Overview overview = null;
protected Alignment centered_overview = null;
protected bool overview_added = false;

/**
* Number of slides inside the presentation
Expand Down Expand Up @@ -160,9 +162,9 @@ namespace org.westhoffswelt.pdfpresenter.Window {

// The next slide is right to the current one and takes up the
// remaining width
Requisition cv_requisition;
this.current_view.size_request(out cv_requisition);
current_allocated_width = cv_requisition.width;
//Requisition cv_requisition;
//this.current_view.size_request(out cv_requisition);
//current_allocated_width = cv_requisition.width;
Rectangle next_scale_rect;
var next_allocated_width = this.screen_geometry.width - current_allocated_width-4; // We leave a bit of margin between the two views
this.next_view = View.Pdf.from_metadata(
Expand Down Expand Up @@ -270,8 +272,6 @@ namespace org.westhoffswelt.pdfpresenter.Window {
// Store the slide count once
this.slide_count = metadata.get_slide_count();

this.update();

// Enable the render caching if it hasn't been forcefully disabled.
if ( !Options.disable_caching ) {
((Renderer.Caching)this.current_view.get_renderer()).set_cache(
Expand Down Expand Up @@ -312,17 +312,25 @@ namespace org.westhoffswelt.pdfpresenter.Window {
strict_views.pack_start(this.strict_prev_view, false, false, 0);
strict_views.pack_end(this.strict_next_view, false, false, 0);

var center_current_view = new Alignment(0.5f, 0.5f, 0, 0);
center_current_view.add(this.current_view);

var current_view_and_stricts = new VBox(false, 2);
current_view_and_stricts.pack_start(this.current_view, false, false, 2);
current_view_and_stricts.pack_start(center_current_view, false, false, 2);
current_view_and_stricts.pack_start(strict_views, false, false, 2);

//var center_current_view = new Alignment(0, (float)0.5, 0, 0);
//center_current_view.add(this.current_view);

this.slideViews.add( current_view_and_stricts );

var nextViewWithNotes = new VBox(false, 0);
nextViewWithNotes.pack_start( this.next_view, false, false, 0 );
var center_next_view = new Alignment(0.5f, 0.5f, 0, 0);
center_next_view.add(this.next_view);
nextViewWithNotes.pack_start( center_next_view, false, false, 0 );
var notes_sw = new ScrolledWindow(null, null);
Scrollbar notes_scrollbar = (Gtk.Scrollbar) notes_sw.get_vscrollbar();
notes_scrollbar.modify_bg(StateType.NORMAL, white);
notes_scrollbar.modify_bg(StateType.ACTIVE, black);
notes_scrollbar.modify_bg(StateType.PRELIGHT, white);
notes_sw.add( this.notes_view );
notes_sw.set_policy( PolicyType.AUTOMATIC, PolicyType.AUTOMATIC );
nextViewWithNotes.pack_start( notes_sw, true, true, 5 );
Expand Down Expand Up @@ -357,9 +365,11 @@ namespace org.westhoffswelt.pdfpresenter.Window {
this.add( fullLayout );

this.overview = new Overview( this.metadata, this.presentation_controller, this );
this.overview.no_show_all = true;
this.centered_overview = new Alignment(0.5f, 0.5f, 0, 1);
this.centered_overview.add(this.overview);
//this.centered_overview.no_show_all = true;
this.overview.set_n_slides( this.presentation_controller.get_user_n_slides() );
this.fullLayout.pack_start( this.overview, true, true, 0 );
//this.fullLayout.pack_start( this.overview, true, true, 0 );
this.presentation_controller.set_overview(this.overview);
}

Expand Down Expand Up @@ -421,7 +431,7 @@ namespace org.westhoffswelt.pdfpresenter.Window {

public void update() {
if (this.overview != null) {
this.overview.hide();
this.centered_overview.hide();
this.slideViews.show();
}
int current_slide_number = this.presentation_controller.get_current_slide_number();
Expand Down Expand Up @@ -547,12 +557,16 @@ namespace org.westhoffswelt.pdfpresenter.Window {

public void show_overview() {
this.slideViews.hide();
this.overview.show();
if (!overview_added) {
this.fullLayout.pack_start( this.centered_overview, true, true, 0 );
overview_added = true;
}
this.centered_overview.show();
this.overview.current_slide = this.presentation_controller.get_current_user_slide_number();
}

public void hide_overview() {
this.overview.hide();
this.centered_overview.hide();
this.slideViews.show();
}

Expand Down
2 changes: 2 additions & 0 deletions src/pdfpc.vala
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,12 @@ namespace org.westhoffswelt.pdfpresenter {
// been created at this point.
if ( this.presentation_window != null ) {
this.presentation_window.show_all();
this.presentation_window.update();
}

if ( this.presenter_window != null ) {
this.presenter_window.show_all();
this.presenter_window.update();
}


Expand Down

0 comments on commit cdb136e

Please sign in to comment.