Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;

import com.vogella.tasks.events.TaskEventConstants;
import com.vogella.tasks.model.Task;
Expand All @@ -60,7 +63,8 @@ public class TodoOverviewPart {
private static final String PLUS_ICON = "platform:/plugin/com.vogella.tasks.ui/img/addTask.svg";
private static final int BUTTON_SIZE = 40;
private static final int BUTTON_MARGIN_RIGHT = 12;
private static final int BUTTON_MARGIN_BOTTOM = 24;
private static final int BUTTON_MARGIN_BOTTOM = 12;
private static final int BUTTON_MARGIN_BOTTOM_ABOVE_SCROLLBAR = 24;
private static final int CIRCLE_INSET = 1;

@Inject
Expand Down Expand Up @@ -96,7 +100,6 @@ public void createControls(Composite parent, EMenuService menuService, ECommandS
tableData.right = new FormAttachment(100);
tableData.bottom = new FormAttachment(100);
table.setLayoutData(tableData);
createFloatingButton(parent, table, commandService, handlerService, themeEngine);

// create column for the summary property
TableViewerColumn colSummary = new TableViewerColumn(viewer, SWT.NONE);
Expand All @@ -113,6 +116,8 @@ public void createControls(Composite parent, EMenuService menuService, ECommandS
// Restore column widths if available
TableColumnPersistenceUtil.restoreColumnWidths(viewer, "TodoOverviewPartTable");

createFloatingButton(parent, table, commandService, handlerService, themeEngine);

// use data binding to bind the viewer
writableList = new WritableList<>();
// fill the writable list, when Consumer callback is called. Databinding
Expand Down Expand Up @@ -147,6 +152,7 @@ private void createFloatingButton(Composite parent, Table table, ECommandService
data.bottom = new FormAttachment(100, -BUTTON_MARGIN_BOTTOM);
button.setLayoutData(data);
button.moveAbove(table);
keepAboveScrollBar(parent, table, data);

// a region is the only way to get a non rectangular control over a sibling
Region circle = new Region();
Expand All @@ -170,6 +176,22 @@ private void createFloatingButton(Composite parent, Table table, ECommandService
_ -> handlerService.executeHandler(commandService.createCommand(CREATE_TASK_COMMAND)));
}

private static void keepAboveScrollBar(Composite parent, Table table, FormData data) {
Listener update = _ -> {
ScrollBar bar = table.getHorizontalBar();
int margin = bar != null && bar.getVisible() ? BUTTON_MARGIN_BOTTOM_ABOVE_SCROLLBAR : BUTTON_MARGIN_BOTTOM;
if (data.bottom.offset != -margin) {
data.bottom = new FormAttachment(100, -margin);
parent.layout();
}
};
table.addListener(SWT.Resize, update);
for (TableColumn column : table.getColumns()) {
column.addListener(SWT.Resize, update);
}
update.handleEvent(null);
}

private static int[] circle(int diameter) {
int steps = 64;
double radius = diameter / 2.0;
Expand Down
Loading