@Override protected void paintComponent(Graphics g) { g.setColor(ButtonlessScrollBarUI.getTrackBackgroundDefault()); g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(ButtonlessScrollBarUI.getTrackBorderColorDefault()); int x2 = getWidth() - 1; int y2 = getHeight() - 1; if (myPos == UPPER_LEFT_CORNER || myPos == UPPER_RIGHT_CORNER) { g.drawLine(0, y2, x2, y2); } if (myPos == LOWER_LEFT_CORNER || myPos == LOWER_RIGHT_CORNER) { g.drawLine(0, 0, x2, 0); } if (myPos == UPPER_LEFT_CORNER || myPos == LOWER_LEFT_CORNER) { g.drawLine(x2, 0, x2, y2); } if (myPos == UPPER_RIGHT_CORNER || myPos == LOWER_RIGHT_CORNER) { g.drawLine(0, 0, 0, y2); } }
@Override protected void paintComponent(Graphics g) { g.setColor(ButtonlessScrollBarUI.getTrackBackground()); g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(ButtonlessScrollBarUI.getTrackBorderColor()); int x2 = getWidth() - 1; int y2 = getHeight() - 1; if (myPos == UPPER_LEFT_CORNER || myPos == UPPER_RIGHT_CORNER) { g.drawLine(0, y2, x2, y2); } if (myPos == LOWER_LEFT_CORNER || myPos == LOWER_RIGHT_CORNER) { g.drawLine(0, 0, x2, 0); } if (myPos == UPPER_LEFT_CORNER || myPos == LOWER_LEFT_CORNER) { g.drawLine(x2, 0, x2, y2); } if (myPos == UPPER_RIGHT_CORNER || myPos == LOWER_RIGHT_CORNER) { g.drawLine(0, 0, 0, y2); } }
/** * This is helper method. It returns height of the top (decrease) scroll bar * button. Please note, that it's possible to return real height only if scroll bar * is instance of BasicScrollBarUI. Otherwise it returns fake (but good enough :) ) * value. */ int getDecScrollButtonHeight() { ScrollBarUI barUI = getUI(); Insets insets = getInsets(); if (barUI instanceof ButtonlessScrollBarUI) { return insets.top + ((ButtonlessScrollBarUI)barUI).getDecrementButtonHeight(); } else if (barUI instanceof BasicScrollBarUI) { try { JButton decrButtonValue = (JButton)decrButtonField.get(barUI); LOG.assertTrue(decrButtonValue != null); return insets.top + decrButtonValue.getHeight(); } catch (Exception exc) { throw new IllegalStateException(exc); } } else { return insets.top + 15; } }
/** * This is helper method. It returns height of the bottom (increase) scroll bar * button. Please note, that it's possible to return real height only if scroll bar * is instance of BasicScrollBarUI. Otherwise it returns fake (but good enough :) ) * value. */ int getIncScrollButtonHeight() { ScrollBarUI barUI = getUI(); Insets insets = getInsets(); if (barUI instanceof ButtonlessScrollBarUI) { return insets.top + ((ButtonlessScrollBarUI)barUI).getIncrementButtonHeight(); } if (barUI instanceof BasicScrollBarUI) { try { JButton incrButtonValue = (JButton)incrButtonField.get(barUI); LOG.assertTrue(incrButtonValue != null); return insets.bottom + incrButtonValue.getHeight(); } catch (Exception exc) { throw new IllegalStateException(exc); } } if (APPLE_LAF_AQUA_SCROLL_BAR_UI_CLASS.equals(barUI.getClass().getName())) { return insets.bottom + 30; } return insets.bottom + 15; }
@Nullable private static Rectangle calcThumbBounds(JScrollBar scrollBar) { ScrollBarUI scrollBarUI = scrollBar.getUI(); if (scrollBarUI instanceof ButtonlessScrollBarUI) { return ((ButtonlessScrollBarUI)scrollBarUI).getThumbBounds(); } return null; }
@Override public void setupCorners() { super.setupCorners(); setBorder(new TablessBorder()); setCorner(getVerticalScrollbarOrientation() == EditorEx.VERTICAL_SCROLLBAR_LEFT ? LOWER_RIGHT_CORNER : LOWER_LEFT_CORNER, new JPanel() { @Override public void paint(@NotNull Graphics g) { if (UISettings.getInstance().PRESENTATION_MODE) { return; } final Rectangle bounds = getBounds(); int width = bounds.width; int height = bounds.height; g.setColor(ButtonlessScrollBarUI.getTrackBackground()); g.fillRect(0, 0, width, height); int shortner = 0; if (myGutterComponent.isFoldingOutlineShown()) { shortner = myGutterComponent.getFoldingAreaWidth() / 2; } g.setColor(myGutterComponent.getBackground()); g.fillRect(0, 0, width - shortner, height); g.setColor(ButtonlessScrollBarUI.getTrackBorderColor()); g.drawLine(width - 1 - shortner, 0, width - 1 - shortner, height); g.drawLine(0, 0, width - 1, 0); } }); }
@Override public void setErrorStripeVisible(boolean val) { if (val) { myEditor.getVerticalScrollBar().setPersistentUI(new MyErrorPanel()); } else { myEditor.getVerticalScrollBar().setPersistentUI(ButtonlessScrollBarUI.createNormal()); } }
@Override public void paint(Graphics g) { ((ApplicationImpl)ApplicationManager.getApplication()).editorPaintStart(); final Rectangle bounds = getBounds(); try { if (UISettings.getInstance().PRESENTATION_MODE) { g.setColor(getEditor().getColorsScheme().getDefaultBackground()); g.fillRect(0, 0, bounds.width, bounds.height); if (myErrorStripeRenderer != null) { myErrorStripeRenderer.paint(this, g, new Rectangle(2, 0, 10, 7)); } } else { g.setColor(ButtonlessScrollBarUI.getTrackBackground()); g.fillRect(0, 0, bounds.width, bounds.height); g.setColor(ButtonlessScrollBarUI.getTrackBorderColor()); g.drawLine(0, 0, 0, bounds.height); if (myErrorStripeRenderer != null) { myErrorStripeRenderer.paint(this, g, new Rectangle(5, 2, ERROR_ICON_WIDTH, ERROR_ICON_HEIGHT)); } } } finally { ((ApplicationImpl)ApplicationManager.getApplication()).editorPaintFinish(); } }
private void paintTrackBasement(Graphics g, Rectangle bounds) { if (UISettings.getInstance().PRESENTATION_MODE) { return; } g.setColor(ButtonlessScrollBarUI.getTrackBackground()); g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height + 1); g.setColor(ButtonlessScrollBarUI.getTrackBorderColor()); int border = isMirrored() ? bounds.x + bounds.width - 1 : bounds.x; g.drawLine(border, bounds.y, border, bounds.y + bounds.height + 1); }
private MyScrollingHelper() { myLeftScroll = new JScrollBar(JScrollBar.HORIZONTAL); myLeftScroll.setUI(ButtonlessScrollBarUI.createNormal()); myLeftEditors = new ArrayList<Editor>(); myRightEditors = new ArrayList<Editor>(); myMaxColumnsLeft = 0; myMaxColumnsRight = 0; myLeftModels = new ArrayList<ScrollingModel>(); myRightModels = new ArrayList<ScrollingModel>(); }
/** * Returns a new instance of {@link ScrollBarUI}. * Do not share it between different scroll bars. * * @param c a target component for this UI * @return a new instance of {@link ScrollBarUI} */ @SuppressWarnings("UnusedParameters") public static ScrollBarUI createUI(JComponent c) { if (Registry.is("ide.scroll.new.layout")) { if (!SystemInfo.isMac) return new DefaultScrollBarUI(); if (Registry.is("mac.scroll.new.ui")) return new MacScrollBarUI(); } return ButtonlessScrollBarUI.createNormal(); }
public void setScrollbarPainter(@NotNull ButtonlessScrollBarUI.ScrollbarRepaintCallback painter) { if (myBaseEditor != null) myBaseEditor.registerScrollBarRepaintCallback(painter); }
protected boolean isOverlaidScrollbar(@Nullable JScrollBar scrollbar) { if (!ButtonlessScrollBarUI.isMacOverlayScrollbarSupported()) return false; ScrollBarUI vsbUI = scrollbar == null ? null : scrollbar.getUI(); return vsbUI instanceof ButtonlessScrollBarUI && !((ButtonlessScrollBarUI)vsbUI).alwaysShowTrack(); }
@Override public void updateUI() { setUI(ButtonlessScrollBarUI.createNormal()); }
LookupUi(LookupImpl lookup, Advertiser advertiser, JBList list, Project project) { myLookup = lookup; myAdvertiser = advertiser; myList = list; myProject = project; myIconPanel.setVisible(false); myIconPanel.setBackground(Color.LIGHT_GRAY); myIconPanel.add(myProcessIcon); JComponent adComponent = advertiser.getAdComponent(); adComponent.setBorder(new EmptyBorder(0, 1, 1, 2 + AllIcons.Ide.LookupRelevance.getIconWidth())); myLayeredPane.mainPanel.add(adComponent, BorderLayout.SOUTH); myScrollBarIncreaseButton = new JButton(); myScrollBarIncreaseButton.setFocusable(false); myScrollBarIncreaseButton.setRequestFocusEnabled(false); myScrollPane = new JBScrollPane(lookup.getList()); myScrollPane.setViewportBorder(JBUI.Borders.empty()); myScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); myScrollPane.getVerticalScrollBar().setPreferredSize(new Dimension(13, -1)); myScrollPane.getVerticalScrollBar().setUI(new ButtonlessScrollBarUI() { @Override protected JButton createIncreaseButton(int orientation) { return myScrollBarIncreaseButton; } }); lookup.getComponent().add(myLayeredPane, BorderLayout.CENTER); //IDEA-82111 fixMouseCheaters(); myLayeredPane.mainPanel.add(myScrollPane, BorderLayout.CENTER); myScrollPane.setBorder(null); mySortingLabel.setBorder(new LineBorder(new JBColor(Color.LIGHT_GRAY, JBColor.background()))); mySortingLabel.setOpaque(true); new ChangeLookupSorting().installOn(mySortingLabel); updateSorting(); myModalityState = ModalityState.stateForComponent(lookup.getEditor().getComponent()); addListeners(); updateScrollbarVisibility(); Disposer.register(lookup, myProcessIcon); Disposer.register(lookup, myHintAlarm); }
@Override public void registerScrollBarRepaintCallback(@Nullable ButtonlessScrollBarUI.ScrollbarRepaintCallback callback) { myDelegate.registerScrollBarRepaintCallback(callback); }
public LookupImpl(Project project, Editor editor, @NotNull LookupArranger arranger) { super(new JPanel(new BorderLayout())); setForceShowAsPopup(true); setCancelOnClickOutside(false); setResizable(true); AbstractPopup.suppressMacCornerFor(getComponent()); myProject = project; myEditor = editor; myArranger = arranger; myPresentableArranger = arranger; myIconPanel.setVisible(false); myCellRenderer = new LookupCellRenderer(this); myList.setCellRenderer(myCellRenderer); myList.setFocusable(false); myList.setFixedCellWidth(50); myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); myList.setBackground(LookupCellRenderer.BACKGROUND_COLOR); myList.getExpandableItemsHandler(); myScrollBarIncreaseButton = new JButton(); myScrollBarIncreaseButton.setFocusable(false); myScrollBarIncreaseButton.setRequestFocusEnabled(false); myScrollPane = new JBScrollPane(myList); myScrollPane.setViewportBorder(new EmptyBorder(0, 0, 0, 0)); myScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); myScrollPane.getVerticalScrollBar().setPreferredSize(new Dimension(13, -1)); myScrollPane.getVerticalScrollBar().setUI(new ButtonlessScrollBarUI() { @Override protected JButton createIncreaseButton(int orientation) { return myScrollBarIncreaseButton; } }); getComponent().add(myLayeredPane, BorderLayout.CENTER); //IDEA-82111 fixMouseCheaters(); myLayeredPane.mainPanel.add(myScrollPane, BorderLayout.CENTER); myScrollPane.setBorder(null); myAdComponent = new Advertiser(); JComponent adComponent = myAdComponent.getAdComponent(); adComponent.setBorder(new EmptyBorder(0, 1, 1, 2 + AllIcons.Ide.LookupRelevance.getIconWidth())); myLayeredPane.mainPanel.add(adComponent, BorderLayout.SOUTH); getComponent().setBorder(new BegPopupMenuBorder()); myIconPanel.setBackground(Color.LIGHT_GRAY); myIconPanel.add(myProcessIcon); myOffsets = new LookupOffsets(editor); final CollectionListModel<LookupElement> model = getListModel(); addEmptyItem(model); updateListHeight(model); addListeners(); mySortingLabel.setBorder(new LineBorder(new JBColor(Color.LIGHT_GRAY, JBColor.background()))); mySortingLabel.setOpaque(true); new ChangeLookupSorting().installOn(mySortingLabel); updateSorting(); myModalityState = ModalityState.stateForComponent(getComponent()); }
/** * Allows to register a callback that will be called one each repaint of the editor vertical scrollbar. * This is needed to allow a parent component draw above the scrollbar components (e.g. in the merge tool), * otherwise the drawings are cleared once the scrollbar gets repainted (which may happen suddenly, because the scrollbar UI uses the * {@link com.intellij.util.ui.Animator} to draw itself. * @param callback callback which will be called from the {@link JComponent#paint(Graphics)} method of * the editor vertical scrollbar. */ void registerScrollBarRepaintCallback(@Nullable ButtonlessScrollBarUI.ScrollbarRepaintCallback callback);