+ Antworten
Ergebnis 1 bis 3 von 3

Thema: Eclipse Theme color palette

  1. #1
    User int Themenstarter

    Registriert seit
    13.12.2014
    Fachbeiträge
    47
    Genannt
    0 Post(s)
    Hi Beni,

    I am creating a new GUI application using Docking Frames and a lot of components from my other GUI application. So, I thought it would be a good idea to change up the Eclipse Theme color palette, so that things appear visually different.

    I was playing around with your 'size-and-color' demo and when I change the 'tab.background.focused', the color changes correctly but it is now a solid color. The original medium blue color was gradient and not a solid color. i.e. The tab is lighter blue at the top and gets a little darker blue towards the bottom.

    How can I change the 'tab.background.focused' color and keep the gradient? Can I just change the color palette from medium blue to medium green (or medium orange)? If so, how?

    2nd question: I found the following piece of code (I don't remember where):
    Code:
    ((CEclipseTheme) control.getController().getTheme()).intern().setPaint(new FlatStationPaint());
    But when I use it, I don't see any difference in the GUI components. i.e. the tabs look exactly the same.

    Note: I'm using Docking Frames 1.1.2 Preview 18a.

    Regards,
    Roger

  2. #2
    Projekt-Moderator Docking Frames Megabyte Avatar von Beni
    Registriert seit
    27.08.2006
    Fachbeiträge
    1.929
    Genannt
    8 Post(s)
    An "easy" way to override the default colors is to write your own "ColorBridge". Like in the example below where the colors of the tabs are red and green (if focused and selected).

    Java Code:
    1. package test;
    2.  
    3. import java.awt.Color;
    4.  
    5. import javax.swing.JFrame;
    6.  
    7. import bibliothek.gui.Dockable;
    8. import bibliothek.gui.dock.common.CControl;
    9. import bibliothek.gui.dock.common.CGrid;
    10. import bibliothek.gui.dock.common.ColorMap;
    11. import bibliothek.gui.dock.common.DefaultSingleCDockable;
    12. import bibliothek.gui.dock.common.intern.CommonDockable;
    13. import bibliothek.gui.dock.common.theme.ThemeMap;
    14. import bibliothek.gui.dock.themes.color.TabColor;
    15. import bibliothek.gui.dock.util.Priority;
    16. import bibliothek.gui.dock.util.color.ColorBridge;
    17. import bibliothek.gui.dock.util.color.DockColor;
    18.  
    19. public class MyColors {
    20.     public static void main( String[] args ) {
    21.         JFrame frame = new JFrame( "Test" );
    22.         CControl control = new CControl( frame );
    23.  
    24.         control.setTheme( ThemeMap.KEY_ECLIPSE_THEME );
    25.  
    26.         // override the default ColorBridge. Every color that is used by a tab must first be approved by the bridge.
    27.         control.getController().getColors().publish( Priority.CLIENT, TabColor.KIND_TAB_COLOR,
    28.                 // you could also extend from EclipseTabTransmitter if you would like to keep support for the other colors
    29.                 new ColorBridge() {
    30.                     @Override
    31.                     public void set( String id, Color value, DockColor uiValue ) {
    32.                         // see "BaseTabComponent" for all the "ids" that we may experience here
    33.                         TabColor tab = (TabColor) uiValue;
    34.                         tab.getDockable();
    35.  
    36.                         if( id.equals( "stack.tab.top.selected.focused" ) ) {
    37.                             value = getTopColor( tab.getDockable(), value );
    38.                         } else if( id.equals( "stack.tab.bottom.selected.focused" ) ) {
    39.                             value = getBottomColor( tab.getDockable(), value );
    40.                         }
    41.  
    42.                         uiValue.set( value );
    43.                     }
    44.  
    45.                     @Override
    46.                     public void remove( String id, DockColor uiValue ) {
    47.                         // ignore
    48.                     }
    49.  
    50.                     @Override
    51.                     public void add( String id, DockColor uiValue ) {
    52.                         // ignore
    53.                     }
    54.                 } );
    55.  
    56.         frame.add( control.getContentArea() );
    57.  
    58.         CGrid grid = new CGrid( control );
    59.         grid.add( 0, 0, 1, 1, dockable(  "a", "Aaaa", Color.RED ) );
    60.         grid.add( 1, 0, 1, 1, dockable(  "b", "Bbbb", Color.GREEN ) );
    61.         control.getContentArea().deploy( grid );
    62.  
    63.         frame.setBounds( 50, 50, 800, 800 );
    64.         frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    65.         frame.setVisible( true );
    66.     }
    67.  
    68.     private static DefaultSingleCDockable dockable(  String id, String title, Color color ){
    69.         DefaultSingleCDockable dockable = new DefaultSingleCDockable( id, title );
    70.        
    71.         // let's make use of the existing ColorMap instead of inventing our own collection of colors.
    72.         dockable.getColors().setColor( "myTop", color.brighter() );
    73.         dockable.getColors().setColor( "myBottom", color.darker() );
    74.        
    75.         return dockable;
    76.     }
    77.    
    78.     private static Color getTopColor( Dockable dockable, Color backup ) {
    79.         return getColor( dockable, "myTop", backup );
    80.     }
    81.  
    82.     private static Color getBottomColor( Dockable dockable, Color backup ) {
    83.         return getColor( dockable, "myBottom", backup );
    84.     }
    85.  
    86.     private static Color getColor( Dockable dockable, String id, Color backup ) {
    87.         Color result = null;
    88.  
    89.         if( dockable instanceof CommonDockable ) {
    90.             ColorMap colors = ((CommonDockable) dockable).getDockable().getColors();
    91.             result = colors.getColor( id );
    92.         }
    93.  
    94.         if( result == null ) {
    95.             result = backup;
    96.         }
    97.  
    98.         return result;
    99.     }
    100. }

  3. #3
    User int Themenstarter

    Registriert seit
    13.12.2014
    Fachbeiträge
    47
    Genannt
    0 Post(s)
    Hi Beni,

    Thanks. I'll go and color my world.

    later
    Roger

+ Antworten Thema als "gelöst" markieren

Direkt antworten Direkt antworten

Gib folgenden Captcha-Code ein: 2X9MD4

Aktive Benutzer

Aktive Benutzer

Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)

Ähnliche Themen

  1. How to set the color of tab text (Flat theme)
    Von ThiloBret im Forum DockingFrames
    Antworten: 3
    Letzter Beitrag: 22.10.2016, 10:50
  2. (Eclipse) Color Theme bei Eclipse 4.4 Luna ändert bei Neustart
    Von TheAceOfSpades im Forum IDEs & Tools
    Antworten: 2
    Letzter Beitrag: 11.09.2014, 11:08
  3. Farbsuche in Palette (nearest Color Index)
    Von Spacerat im Forum AWT, Swing, JavaFX & SWT
    Antworten: 52
    Letzter Beitrag: 18.07.2014, 16:09
  4. Eclipse 4.x Theme
    Von Unregistered im Forum DockingFrames
    Antworten: 1
    Letzter Beitrag: 05.03.2012, 09:54
  5. 1.1.0 Eclipse Theme Tab
    Von kkx im Forum DockingFrames
    Antworten: 2
    Letzter Beitrag: 15.03.2011, 06:24

Berechtigungen

  • Neue Themen erstellen: Ja
  • Themen beantworten: Ja
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •